galois.GroupMeta¶
- class galois.GroupMeta(name, bases, namespace, **kwargs)¶
Defines a metaclass for all
galois.GroupArray
classes.Constructors
Methods
compile
(mode[, target])Recompile the just-in-time compiled numba ufuncs with a new calculation mode or target.
Attributes
The default ufunc arithmetic mode for this Galois field.
List of valid integer
numpy.dtype
objects that are compatible with this group, ring, or field.A generator of the group, if it exists.
A list of all generators of the group.
The group identity element \(e\), such that \(a + e = a\) for \(a, e \in (\mathbb{Z}/n\mathbb{Z}){^+}\) and \(a * e = a\) for \(a, e \in (\mathbb{Z}/n\mathbb{Z}){^\times}\).
Indicates if the group is abelian.
Indicates if the group is cyclic.
The modulus \(n\) of the group \((\mathbb{Z}/n\mathbb{Z}){^+}\) or \((\mathbb{Z}/n\mathbb{Z}){^\times}\).
The expanded name of the finite group, ring, or field.
The group operator, either
"+"
or"*"
.The order of the group, which equals the number of elements in the group.
A formatted string displaying relevant properties of group, ring, or field.
The set of group elements.
The abbreviated name of the finite group, ring, or field.
The algebraic structure of the array class.
The mode for ufunc compilation, either
"jit-lookup"
,"jit-calculate"
,"python-calculate"
.All supported ufunc modes for this Galois field array class.
The numba target for the JIT-compiled ufuncs, either
"cpu"
,"parallel"
, or"cuda"
.All supported ufunc targets for this Galois field array class.
- compile(mode, target='cpu')¶
Recompile the just-in-time compiled numba ufuncs with a new calculation mode or target.
- Parameters
mode (str) – The method of field computation, either
"jit-lookup"
,"jit-calculate"
,"python-calculate"
. The “jit-lookup” mode will use Zech log, log, and anti-log lookup tables for speed. The “jit-calculate” mode will not store any lookup tables, but perform field arithmetic on the fly. The “jit-calculate” mode is designed for large fields that cannot store lookup tables in RAM. Generally, “jit-calculate” is slower than “jit-lookup”. The “python-calculate” mode is reserved for extremely large fields. In this mode the ufuncs are not JIT-compiled, but are pur python functions operating on python ints. The list of valid modes for this field is ingalois.FieldMeta.ufunc_modes
.target (str, optional) – The
target
keyword argument fromnumba.vectorize
, either"cpu"
,"parallel"
, or"cuda"
. The default is"cpu"
. For extremely large fields the only supported target is"cpu"
(which doesn’t use numba it uses pure python to calculate the field arithmetic). The list of valid targets for this field is ingalois.FieldMeta.ufunc_targets
.
- property default_ufunc_mode¶
The default ufunc arithmetic mode for this Galois field.
Examples
In [298]: galois.GF(2).default_ufunc_mode Out[298]: 'jit-calculate' In [299]: galois.GF(2**8).default_ufunc_mode Out[299]: 'jit-lookup' In [300]: galois.GF(31).default_ufunc_mode Out[300]: 'jit-lookup' In [301]: galois.GF(2**100).default_ufunc_mode Out[301]: 'python-calculate'
- Type
- property dtypes¶
List of valid integer
numpy.dtype
objects that are compatible with this group, ring, or field.Examples
In [302]: G = galois.Group(16, "+"); G.dtypes Out[302]: [numpy.uint8, numpy.uint16, numpy.uint32, numpy.int8, numpy.int16, numpy.int32, numpy.int64] In [303]: G = galois.Group(16, "*"); G.dtypes Out[303]: [numpy.uint8, numpy.uint16, numpy.uint32, numpy.int8, numpy.int16, numpy.int32, numpy.int64] In [304]: GF = galois.GF(2); GF.dtypes Out[304]: [numpy.uint8, numpy.uint16, numpy.uint32, numpy.int8, numpy.int16, numpy.int32, numpy.int64] In [305]: GF = galois.GF(2**8); GF.dtypes Out[305]: [numpy.uint8, numpy.uint16, numpy.uint32, numpy.int16, numpy.int32, numpy.int64] In [306]: GF = galois.GF(31); GF.dtypes Out[306]: [numpy.uint8, numpy.uint16, numpy.uint32, numpy.int8, numpy.int16, numpy.int32, numpy.int64] In [307]: GF = galois.GF(7**5); GF.dtypes Out[307]: [numpy.uint16, numpy.uint32, numpy.int16, numpy.int32, numpy.int64]
For algebraic structures that cannot be represented by
numpy.int64
, the only valid dtype isnumpy.object_
.In [308]: G = galois.Group(10**20, "*"); G.dtypes Out[308]: [numpy.object_] In [309]: GF = galois.GF(2**100); GF.dtypes Out[309]: [numpy.object_] In [310]: GF = galois.GF(36893488147419103183); GF.dtypes Out[310]: [numpy.object_]
- Type
- property generator¶
A generator of the group, if it exists. The group must be cyclic for a generator to exist. If a generator exists, the group can be represented as \(G = \{g^0, g^1, \dots, g^{\phi(n)-1}\}\).
Examples
In [311]: G = galois.Group(16, "+"); G.generator Out[311]: ℤn+(1, n=16) # This group doesn't have a generator and returns None In [312]: G = galois.Group(16, "*"); G.generator In [313]: G = galois.Group(17, "*"); G.generator Out[313]: ℤn*(3, n=17)
- Type
- property generators¶
A list of all generators of the group. The group must be cyclic for a generator to exist. If a generator exists, the group can be represented as \(G = \{g^0, g^1, \dots, g^{\phi(n)-1}\}\)
Examples
In [314]: G = galois.Group(16, "+"); G.generators Out[314]: ℤn+([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], n=16) In [315]: G = galois.Group(16, "*"); G.generators Out[315]: ℤn*([], n=16) In [316]: G = galois.Group(17, "*"); G.generators Out[316]: ℤn*([ 3, 5, 6, 7, 10, 11, 12, 14], n=17)
- Type
- property identity¶
The group identity element \(e\), such that \(a + e = a\) for \(a, e \in (\mathbb{Z}/n\mathbb{Z}){^+}\) and \(a * e = a\) for \(a, e \in (\mathbb{Z}/n\mathbb{Z}){^\times}\).
Examples
In [317]: G = galois.Group(16, "+"); G.identity Out[317]: ℤn+(0, n=16) In [318]: G = galois.Group(16, "*"); G.identity Out[318]: ℤn*(1, n=16)
- Type
- property is_abelian¶
Indicates if the group is abelian. A group is abelian if the order of elements in the group operation does not matter.
Examples
In [319]: G = galois.Group(16, "+") In [320]: G.is_abelian Out[320]: True In [321]: a, b = G.Random(), G.Random() In [322]: a + b Out[322]: ℤn+(11, n=16) In [323]: b + a Out[323]: ℤn+(11, n=16)
In [324]: G = galois.Group(16, "*") In [325]: G.is_abelian Out[325]: True In [326]: a, b = G.Random(), G.Random() In [327]: a * b Out[327]: ℤn*(1, n=16) In [328]: b * a Out[328]: ℤn*(1, n=16)
- Type
- property is_cyclic¶
Indicates if the group is cyclic. A group is cyclic if it can be generated by a generator element \(g\) such that \(G = \{g^0, g^1, \dots, g^{\phi(n)-1}\}\).
Examples
In [329]: G = galois.Group(16, "+"); G.is_cyclic Out[329]: True In [330]: G = galois.Group(16, "*"); G.is_cyclic Out[330]: False In [331]: G = galois.Group(17, "*"); G.is_cyclic Out[331]: True
- Type
- property modulus¶
The modulus \(n\) of the group \((\mathbb{Z}/n\mathbb{Z}){^+}\) or \((\mathbb{Z}/n\mathbb{Z}){^\times}\).
Examples
In [332]: G = galois.Group(16, "+"); G.modulus Out[332]: 16 In [333]: G = galois.Group(16, "*"); G.modulus Out[333]: 16
- Type
- property name¶
The expanded name of the finite group, ring, or field.
Examples
In [334]: G = galois.Group(16, "+"); G.name Out[334]: '(ℤ/16ℤ)+' In [335]: G = galois.Group(16, "*"); G.name Out[335]: '(ℤ/16ℤ)*' In [336]: GF = galois.GF(2**4); GF.name Out[336]: 'GF(2^4)'
- Type
- property operator¶
The group operator, either
"+"
or"*"
.Examples
In [337]: G = galois.Group(16, "+"); G.operator Out[337]: '+' In [338]: G = galois.Group(16, "*"); G.operator Out[338]: '*'
- Type
- property order¶
The order of the group, which equals the number of elements in the group.
Examples
In [339]: G = galois.Group(16, "+"); G.order Out[339]: 16 In [340]: G = galois.Group(16, "*"); G.order Out[340]: 8
- Type
- property properties¶
A formatted string displaying relevant properties of group, ring, or field.
Examples
In [341]: G = galois.Group(16, "+"); print(G.properties) (ℤ/16ℤ)+: structure: Finite Additive Group modulus: 16 order: 16 generator: 1 is_cyclic: True is_abelian: True In [342]: G = galois.Group(16, "*"); print(G.properties) (ℤ/16ℤ)*: structure: Finite Multiplicative Group modulus: 16 order: 8 generator: None is_cyclic: False is_abelian: True
In [343]: GF = galois.GF(2); print(GF.properties) GF(2): structure: Finite Field characteristic: 2 degree: 1 order: 2 In [344]: GF = galois.GF(2**8); print(GF.properties) GF(2^8): structure: Finite Field characteristic: 2 degree: 8 order: 256 irreducible_poly: Poly(x^8 + x^4 + x^3 + x^2 + 1, GF(2)) is_primitive_poly: True primitive_element: GF(2, order=2^8) In [345]: GF = galois.GF(31); print(GF.properties) GF(31): structure: Finite Field characteristic: 31 degree: 1 order: 31 In [346]: GF = galois.GF(7**5); print(GF.properties) GF(7^5): structure: Finite Field characteristic: 7 degree: 5 order: 16807 irreducible_poly: Poly(x^5 + x + 4, GF(7)) is_primitive_poly: True primitive_element: GF(7, order=7^5)
- Type
- property set¶
The set of group elements.
Examples
In [347]: G = galois.Group(16, "+"); G.set Out[347]: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} In [348]: G = galois.Group(16, "*"); G.set Out[348]: {1, 3, 5, 7, 9, 11, 13, 15} In [349]: G = galois.Group(17, "*"); G.set Out[349]: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}
- Type
- property short_name¶
The abbreviated name of the finite group, ring, or field.
Examples
In [350]: G = galois.Group(16, "+"); G.short_name Out[350]: 'ℤn+' In [351]: G = galois.Group(16, "*"); G.short_name Out[351]: 'ℤn*' In [352]: GF = galois.GF(2**4); GF.short_name Out[352]: 'GF'
- Type
- property structure¶
The algebraic structure of the array class.
Examples
In [353]: G = galois.Group(16, "+"); G.structure Out[353]: 'Finite Additive Group' In [354]: G = galois.Group(16, "*"); G.structure Out[354]: 'Finite Multiplicative Group' In [355]: GF = galois.GF(2**4); GF.structure Out[355]: 'Finite Field'
- Type
- property ufunc_mode¶
The mode for ufunc compilation, either
"jit-lookup"
,"jit-calculate"
,"python-calculate"
.Examples
In [356]: galois.GF(2).ufunc_mode Out[356]: 'jit-calculate' In [357]: galois.GF(2**8).ufunc_mode Out[357]: 'jit-lookup' In [358]: galois.GF(31).ufunc_mode Out[358]: 'jit-lookup' # galois.GF(7**5).ufunc_mode
- Type
- property ufunc_modes¶
All supported ufunc modes for this Galois field array class.
Examples
In [359]: galois.GF(2).ufunc_modes Out[359]: ['jit-calculate'] In [360]: galois.GF(2**8).ufunc_modes Out[360]: ['jit-lookup', 'jit-calculate'] In [361]: galois.GF(31).ufunc_modes Out[361]: ['jit-lookup', 'jit-calculate'] In [362]: galois.GF(2**100).ufunc_modes Out[362]: ['python-calculate']
- Type
- property ufunc_target¶
The numba target for the JIT-compiled ufuncs, either
"cpu"
,"parallel"
, or"cuda"
.Examples
In [363]: galois.GF(2).ufunc_target Out[363]: 'cpu' In [364]: galois.GF(2**8).ufunc_target Out[364]: 'cpu' In [365]: galois.GF(31).ufunc_target Out[365]: 'cpu' # galois.GF(7**5).ufunc_target
- Type
- property ufunc_targets¶
All supported ufunc targets for this Galois field array class.
Examples
In [366]: galois.GF(2).ufunc_targets Out[366]: ['cpu', 'parallel', 'cuda'] In [367]: galois.GF(2**8).ufunc_targets Out[367]: ['cpu', 'parallel', 'cuda'] In [368]: galois.GF(31).ufunc_targets Out[368]: ['cpu', 'parallel', 'cuda'] In [369]: galois.GF(2**100).ufunc_targets Out[369]: ['cpu']
- Type