galois.GF¶
-
galois.
GF
(order, prim_poly=None, target='cpu', mode='auto', rebuild=False)[source]¶ Factory function to construct Galois field array classes of type \(\mathrm{GF}(p^m)\).
- Parameters
order (int) – The order \(p^m\) of the field \(\mathrm{GF}(p^m)\). Order must be a prime power.
prim_poly (galois.Poly, optional) – The primitive polynomial of the field. Default is
None
which will use the Conway polynomial obtained fromgalois.conway_poly
.target (str) – The
target
keyword argument fromnumba.vectorize
, either"cpu"
,"parallel"
, or"cuda"
.mode (str, optional) – The type of field computation, either
"auto"
,"lookup"
, or"calculate"
. The default is"auto"
. The “lookup” mode will use Zech log, log, and anti-log lookup tables for speed. The “calculate” mode will not store any lookup tables, but perform field arithmetic on the fly. The “calculate” mode is designed for large fields that cannot store lookup tables in RAM. Generally, “calculate” will be slower than “lookup”. The “auto” mode will determine whether to use “lookup” or “calculate” based on the field size. For “auto”, field’s withorder <= 2**16
will use the “lookup” mode.rebuild (bool, optional) – Indicates whether to force a rebuild of the lookup tables. The default is
False
.
- Returns
A new Galois field array class that is a subclass of
galois.GFArray
.- Return type
Examples
Construct various Galois field array classes.
# Construct a GF(2^m) class In [5]: GF256 = galois.GF(2**8); print(GF256) <class 'numpy.ndarray' over GF(2^8)> # Construct a GF(p) class In [6]: GF571 = galois.GF(571); print(GF571) <class 'numpy.ndarray' over GF(571)> # Construct a very large GF(2^m) class In [7]: GF2m = galois.GF(2**100); print(GF2m) <class 'numpy.ndarray' over GF(2^100)> # Construct a very large GF(p) class In [8]: GFp = galois.GF(36893488147419103183); print(GFp) <class 'numpy.ndarray' over GF(36893488147419103183)>
See
galois.GFArray
for more examples of what Galois field arrays can do.