class galois.FieldArray(galois.Array)

An abstract ndarray subclass over $$\mathrm{GF}(p^m)$$.

Abstract

FieldArray is an abstract base class and cannot be instantiated directly. Instead, FieldArray subclasses are created using the class factory GF().

Examples

Create a FieldArray subclass over $$\mathrm{GF}(3^5)$$ using the class factory GF().

In : GF = galois.GF(3**5)

In : issubclass(GF, galois.FieldArray)
Out: True

In : 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 : GF = galois.GF(3**5, repr="poly")

In : issubclass(GF, galois.FieldArray)
Out: True

In : 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 : GF = galois.GF(3**5, repr="power")

In : issubclass(GF, galois.FieldArray)
Out: True

In : 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


Create a FieldArray instance using GF’s constructor.

In : x = GF([44, 236, 206, 138]); x
Out: GF([ 44, 236, 206, 138], order=3^5)

In : isinstance(x, GF)
Out: True

In : x = GF([44, 236, 206, 138]); x
Out:
GF([       α^3 + α^2 + 2α + 2,    2α^4 + 2α^3 + 2α^2 + 2,
2α^4 + α^3 + α^2 + 2α + 2,            α^4 + 2α^3 + α], order=3^5)

In : isinstance(x, GF)
Out: True

In : x = GF([44, 236, 206, 138]); x
Out: GF([α^143, α^204,  α^55, α^113], order=3^5)

In : isinstance(x, GF)
Out: True


## Constructors¶

FieldArray(x: , ...)

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

classmethod Identity(size: int, ...) Self

Creates an $$n \times n$$ identity matrix.

classmethod Ones(...) Self

Creates an array of all ones.

classmethod Random(shape: ShapeLike = (), ...) Self

Creates an array with random elements.

classmethod Range(stop, ...) Self

Creates a 1-D array with a range of elements.

classmethod Vandermonde(rows, ...) Self

Creates an $$m \times n$$ Vandermonde matrix of $$a \in \mathrm{GF}(q)$$.

classmethod Zeros(...) Self

Creates an array of all zeros.

## Conversions¶

classmethod Vector(...)

Converts length-$$m$$ vectors over the prime subfield $$\mathrm{GF}(p)$$ to an array over $$\mathrm{GF}(p^m)$$.

vector(dtype: = None)

Converts an array over $$\mathrm{GF}(p^m)$$ to length-$$m$$ vectors over the prime subfield $$\mathrm{GF}(p)$$.

## Elements¶

class property elements : FieldArray

All of the finite field’s elements $$\{0, \dots, p^m-1\}$$.

class property non_squares : FieldArray

All non-squares in the Galois field.

class property primitive_element : FieldArray

A primitive element $$\alpha$$ of the Galois field $$\mathrm{GF}(p^m)$$.

class property primitive_elements : FieldArray

All primitive elements $$\alpha$$ of the Galois field $$\mathrm{GF}(p^m)$$.

classmethod primitive_root_of_unity(n: int) Self

Finds a primitive $$n$$-th root of unity in the finite field.

classmethod primitive_roots_of_unity(n: int) Self

Finds all primitive $$n$$-th roots of unity in the finite field.

class property squares : FieldArray

All squares in the finite field.

class property units : FieldArray

All of the finite field’s units $$\{1, \dots, p^m-1\}$$.

## String representation¶

__repr__() str

Displays the array specifying the class and finite field order.

__str__() str

Displays the array without specifying the class or finite field order.

classmethod arithmetic_table(...) str

Generates the specified arithmetic table for the finite field.

class property properties : str

A formatted string of relevant properties of the Galois field.

classmethod repr_table(...) str

Generates a finite field element representation table comparing the power, polynomial, vector, and integer representations.

## Element representation¶

class property element_repr : Literal[int] | Literal[poly] | Literal[power]

The current finite field element representation.

classmethod repr(...)

Sets the element representation for all arrays from this FieldArray subclass.

## Arithmetic compilation¶

class property default_ufunc_mode : Literal[jit - lookup] | typing.Literal[jit - calculate] | typing.Literal[python - calculate]

The default ufunc compilation mode for this FieldArray subclass.

class property dtypes : list[np.dtype]

List of valid integer numpy.dtype values that are compatible with this finite field.

class property ufunc_mode : Literal[jit - lookup] | typing.Literal[jit - calculate] | typing.Literal[python - calculate]

The current ufunc compilation mode for this FieldArray subclass.

class property ufunc_modes : list[str]

All supported ufunc compilation modes for this FieldArray subclass.

classmethod compile(mode)

Recompile the just-in-time compiled ufuncs for a new calculation mode.

## Methods¶

Computes the additive order of each element in $$x$$.

characteristic_poly() Poly

Computes the characteristic polynomial of a finite field element $$a$$ or a square matrix $$\mathbf{A}$$.

field_norm()

Computes the field norm $$\mathrm{N}_{L / K}(x)$$ of the elements of $$x$$.

field_trace()

Computes the field trace $$\mathrm{Tr}_{L / K}(x)$$ of the elements of $$x$$.

log(base: = None)

Computes the discrete logarithm of the array $$x$$ base $$\beta$$.

minimal_poly() Poly

Computes the minimal polynomial of a finite field element $$a$$.

multiplicative_order()

Computes the multiplicative order $$\textrm{ord}(x)$$ of each element in $$x$$.

## Linear algebra¶

column_space() Self

Computes the column space of the matrix $$\mathbf{A}$$.

left_null_space() Self

Computes the left null space of the matrix $$\mathbf{A}$$.

lu_decompose() tuple[Self, Self]

Decomposes the input array into the product of lower and upper triangular matrices.

null_space() Self

Computes the null space of the matrix $$\mathbf{A}$$.

plu_decompose() tuple[Self, Self, Self]

Decomposes the input array into the product of lower and upper triangular matrices using partial pivoting.

row_reduce(ncols: = None, ...) Self

Performs Gaussian elimination on the matrix to achieve reduced row echelon form (RREF).

row_space() Self

Computes the row space of the matrix $$\mathbf{A}$$.

## Properties¶

class property characteristic : int

The prime characteristic $$p$$ of the Galois field $$\mathrm{GF}(p^m)$$.

class property degree : int

The extension degree $$m$$ of the Galois field $$\mathrm{GF}(p^m)$$.

class property irreducible_poly : Poly

The irreducible polynomial $$f(x)$$ of the Galois field $$\mathrm{GF}(p^m)$$.

class property name : str

The finite field’s name as a string GF(p) or GF(p^m).

class property order : int

The order $$p^m$$ of the Galois field $$\mathrm{GF}(p^m)$$.

class property prime_subfield :

The prime subfield $$\mathrm{GF}(p)$$ of the extension field $$\mathrm{GF}(p^m)$$.

## Attributes¶

class property is_extension_field : bool

Indicates if the finite field is an extension field, having prime power order.

class property is_prime_field : bool

Indicates if the finite field is a prime field, having prime order.

class property is_primitive_poly : bool

Indicates whether the irreducible_poly is a primitive polynomial.

is_square()

Determines if the elements of $$x$$ are squares in the finite field.