galois.FieldArray(x: ElementLike | ArrayLike, dtype: DTypeLike | None = None, copy: bool = True, order: 'K' | 'A' | 'C' | 'F' = 'K', ndmin: int = 0)

Creates an array over \(\mathrm{GF}(p^m)\).

Parameters:
x: ElementLike | ArrayLike

A finite field scalar or array.

dtype: DTypeLike | None = None

The numpy.dtype of the array elements. The default is None which represents the smallest unsigned data type for this FieldArray subclass (the first element in dtypes).

copy: bool = True

The copy keyword argument from numpy.array(). The default is True.

order: 'K' | 'A' | 'C' | 'F' = 'K'

The order keyword argument from numpy.array(). The default is "K".

ndmin: int = 0

The ndmin keyword argument from numpy.array(). The default is 0.

Examples

Create a FieldArray subclass for \(\mathrm{GF}(3^5)\).

In [1]: GF = galois.GF(3**5)

In [2]: print(GF.properties)
Galois Field:
  name: GF(3^5)
  characteristic: 3
  degree: 5
  order: 243
  irreducible_poly: x^5 + 2x + 1
  is_primitive_poly: True
  primitive_element: x

In [3]: alpha = GF.primitive_element; alpha
Out[3]: GF(3, order=3^5)
In [4]: GF = galois.GF(3**5, repr="poly")

In [5]: print(GF.properties)
Galois Field:
  name: GF(3^5)
  characteristic: 3
  degree: 5
  order: 243
  irreducible_poly: x^5 + 2x + 1
  is_primitive_poly: True
  primitive_element: x

In [6]: alpha = GF.primitive_element; alpha
Out[6]: GF(α, order=3^5)
In [7]: GF = galois.GF(3**5, repr="power")

In [8]: print(GF.properties)
Galois Field:
  name: GF(3^5)
  characteristic: 3
  degree: 5
  order: 243
  irreducible_poly: x^5 + 2x + 1
  is_primitive_poly: True
  primitive_element: x

In [9]: alpha = GF.primitive_element; alpha
Out[9]: GF(α, order=3^5)

Create a finite field scalar from its integer representation, polynomial representation, or a power of the primitive element.

In [10]: GF(17)
Out[10]: GF(17, order=3^5)

In [11]: GF("x^2 + 2x + 2")
Out[11]: GF(17, order=3^5)

In [12]: alpha ** 222
Out[12]: GF(17, order=3^5)
In [13]: GF(17)
Out[13]: GF(α^2 + 2α + 2, order=3^5)

In [14]: GF("x^2 + 2x + 2")
Out[14]: GF(α^2 + 2α + 2, order=3^5)

In [15]: alpha ** 222
Out[15]: GF(α^2 + 2α + 2, order=3^5)
In [16]: GF(17)
Out[16]: GF(α^222, order=3^5)

In [17]: GF("x^2 + 2x + 2")
Out[17]: GF(α^222, order=3^5)

In [18]: alpha ** 222
Out[18]: GF(α^222, order=3^5)

Create a finite field array from its integer representation, polynomial representation, or powers of the primitive element.

In [19]: GF([17, 4, 148, 205])
Out[19]: GF([ 17,   4, 148, 205], order=3^5)

In [20]: GF([["x^2 + 2x + 2", 4], ["x^4 + 2x^3 + x^2 + x + 1", 205]])
Out[20]: 
GF([[ 17,   4],
    [148, 205]], order=3^5)

In [21]: alpha ** np.array([[222, 69], [54, 24]])
Out[21]: 
GF([[ 17,   4],
    [148, 205]], order=3^5)
In [22]: GF([17, 4, 148, 205])
Out[22]: 
GF([             α^2 + 2α + 2,                     α + 1,
     α^4 + 2α^3 + α^2 + α + 1, 2α^4 + α^3 + α^2 + 2α + 1], order=3^5)

In [23]: GF([["x^2 + 2x + 2", 4], ["x^4 + 2x^3 + x^2 + x + 1", 205]])
Out[23]: 
GF([[             α^2 + 2α + 2,                     α + 1],
    [ α^4 + 2α^3 + α^2 + α + 1, 2α^4 + α^3 + α^2 + 2α + 1]], order=3^5)

In [24]: alpha ** np.array([[222, 69], [54, 24]])
Out[24]: 
GF([[             α^2 + 2α + 2,                     α + 1],
    [ α^4 + 2α^3 + α^2 + α + 1, 2α^4 + α^3 + α^2 + 2α + 1]], order=3^5)
In [25]: GF([17, 4, 148, 205])
Out[25]: GF([α^222,  α^69,  α^54,  α^24], order=3^5)

In [26]: GF([["x^2 + 2x + 2", 4], ["x^4 + 2x^3 + x^2 + x + 1", 205]])
Out[26]: 
GF([[α^222,  α^69],
    [ α^54,  α^24]], order=3^5)

In [27]: alpha ** np.array([[222, 69], [54, 24]])
Out[27]: 
GF([[α^222,  α^69],
    [ α^54,  α^24]], order=3^5)