galois.Group

class galois.Group(modulus, operator)

Factory function to construct a finite group array class of type \((\mathbb{Z}/n\mathbb{Z}){^+}\) or \((\mathbb{Z}/n\mathbb{Z}){^\times}\).

The created class will be a subclass of galois.GroupArray with metaclass galois.GroupMeta. The galois.GroupArray inheritance provides the numpy.ndarray functionality. The galois.GroupMeta metaclass provides a variety of class attributes and methods relating to the finite group.

Parameters
  • modulus (int) – The modulus \(n\) of the group.

  • operator (str) – The group operation, either "+" or "*".

Returns

A new finite group array class that is a subclass of galois.GroupArray with galois.GroupMeta metaclass.

Return type

galois.GroupMeta

Examples

Construct a finite group array class for the additive group \((\mathbb{Z}/16\mathbb{Z}){^+}\)

In [267]: G = galois.Group(16, "+")

In [268]: print(G.properties)
(ℤ/16ℤ)+:
  structure: Finite Additive Group
  modulus: 16
  order: 16
  generator: 1
  is_cyclic: True
  is_abelian: True

In [269]: G.Elements()
Out[269]: 
ℤn+([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15],
    n=16)

In [270]: a = G.Random(5); a
Out[270]: ℤn+([3, 0, 9, 5, 2], n=16)

In [271]: b = G.Random(5); b
Out[271]: ℤn+([5, 1, 9, 3, 7], n=16)

In [272]: a + b
Out[272]: ℤn+([8, 1, 2, 8, 9], n=16)

Construct a finite group array class for the multiplicative group \((\mathbb{Z}/16\mathbb{Z}){^\times}\)

In [273]: G = galois.Group(16, "*")

# Notice this group is not cyclic
In [274]: print(G.properties)
(ℤ/16ℤ)*:
  structure: Finite Multiplicative Group
  modulus: 16
  order: 8
  generator: None
  is_cyclic: False
  is_abelian: True

In [275]: G.Elements()
Out[275]: ℤn*([ 1,  3,  5,  7,  9, 11, 13, 15], n=16)

In [276]: a = G.Random(5); a
Out[276]: ℤn*([1, 7, 3, 5, 7], n=16)

In [277]: b = G.Random(5); b
Out[277]: ℤn*([ 3,  9, 13,  5, 15], n=16)

In [278]: a * b
Out[278]: ℤn*([ 3, 15,  7,  9,  9], n=16)
classes = {(16, '*'): <class 'numpy.ndarray over (ℤ/16ℤ)*'>, (16, '+'): <class 'numpy.ndarray over (ℤ/16ℤ)+'>, (17, '*'): <class 'numpy.ndarray over (ℤ/17ℤ)*'>, (36, '+'): <class 'numpy.ndarray over (ℤ/36ℤ)+'>, (100000000000000000000, '*'): <class 'numpy.ndarray over (ℤ/100000000000000000000ℤ)*'>}