galois.GF2

class galois.GF2(array, dtype=None, copy=True, order='K', ndmin=0)

A Galois field array over \(\mathrm{GF}(2)\).

Important

This class is a pre-generated galois.FieldArray subclass generated with galois.GF(2) and is included in the API for convenience.

Only the constructor is documented on this page. See galois.FieldArray for all other classmethods and methods for galois.GF2.

See Galois Field Classes for a detailed discussion of the relationship between galois.FieldClass and galois.FieldArray.

See Array Creation for a detailed discussion on creating arrays (with and without copying) from array-like objects, valid NumPy data types, and other galois.FieldArray classmethods.

Examples

This class is equivalent, and in fact identical, to the subclass returned from the class factory galois.GF().

In [1]: galois.GF2 is galois.GF(2)
Out[1]: True

In [2]: print(galois.GF2)
Galois Field:
  name: GF(2)
  characteristic: 2
  degree: 1
  order: 2
  irreducible_poly: x + 1
  is_primitive_poly: True
  primitive_element: 1

The Galois field array class galois.GF2 is a subclass of galois.FieldArray, with galois.FieldClass as its metaclass.

In [3]: isinstance(galois.GF2, galois.FieldClass)
Out[3]: True

In [4]: issubclass(galois.GF2, galois.FieldArray)
Out[4]: True

Create a Galois field array using galois.GF2’s constructor.

In [5]: x = galois.GF2([1, 0, 1, 1]); x
Out[5]: GF([1, 0, 1, 1], order=2)

The Galois field array x is an instance of the Galois field array class galois.GF2.

In [6]: isinstance(x, galois.GF2)
Out[6]: True
__init__(array, dtype=None, copy=True, order='K', ndmin=0)

Creates a Galois field array over \(\mathrm{GF}(p^m)\).

Parameters
array : Union[int, str, Iterable, numpy.ndarray, galois.FieldArray]

The input array-like object to be converted to a Galois field array. See Array Creation for a detailed discussion about creating new arrays and array-like objects.

  • int: A single integer, which is the integer representation of a finite field element, creates a 0-D array (scalar).

  • str: A single string, which is the polynomial representation of a finite field element, creates a 0-D array (scalar).

  • tuple, list: A list or tuple (or nested lists/tuples) of integers or strings (which can be mixed and matched) creates an array of finite field elements from their integer or polynomial representations.

  • numpy.ndarray, galois.FieldArray: A NumPy array of integers creates a copy of the array over this specific field.

dtype : Optional[Union[numpy.dtype, int, object]]

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

copy : bool

The copy keyword argument from numpy.array(). The default is True which makes a copy of the input array.

order : Literal['K', 'A', 'C', 'F']

The order keyword argument from numpy.array(). Valid values are "K" (default), "A", "C", or "F".

ndmin : int

The ndmin keyword argument from numpy.array(). The minimum number of dimensions of the output. The default is 0.


Last update: Apr 03, 2022