QGF#

qualtran.QGF

Galois Field type to represent elements of a finite field.

Inherits From: QDType, QCDType

A Finite Field or Galois Field is a field that contains finite number of elements. The order of a finite field is the number of elements in the field, which is either a prime number or a prime power. For every prime number \(p\) and every positive integer \(m\) there are fields of order \(p^m\), all of which are isomorphic. When m=1, the finite field of order p can be constructed via integers modulo p.

Elements of a Galois Field \(GF(p^m)\) may be conveniently viewed as polynomials \(a_{0} + a_{1}x + ... + a_{m−1}x_{m−1}\), where \(a_0, a_1, ..., a_{m−1} \in F(p)\). \(GF(p^m)\) addition is defined as the component-wise (polynomial) addition over F(p) and multiplication is defined as polynomial multiplication modulo an irreducible polynomial of degree \(m\). The selection of the specific irreducible polynomial affects the representation of the given field, but all fields of a fixed size are isomorphic.

The data type uses the Galois library to perform arithmetic over Galois Fields. By default, the Conway polynomial \(C_{p, m}\) is used as the irreducible polynomial. References Finite Field

[Intro to Prime Fields](https://mhostetter.github.io/galois/latest/tutorials/intro-to-prime-fields/)

[Intro to Extension Fields](https://mhostetter.github.io/galois/latest/tutorials/intro-to-extension-fields/)
characteristic

The characteristic \(p\) of the field \(GF(p^m)\). The characteristic must be prime.

degree

The degree \(m\) of the field \(GF(p^{m})\). The degree must be a positive integer.

irreducible_poly

Optional galois.Poly instance that defines the field arithmetic. This parameter is passed to galois.GF(..., irreducible_poly=irreducible_poly, verify=False).

bitsize

 

gf_type

 

num_bits

 

num_cbits

Number of classical bits required to represent a single instance of this data type.

num_qubits

Number of qubits required to represent a single instance of this data type.

order

 

Methods#

get_classical_domain

View source

Yields all possible classical (computational basis state) values representable by this type.

to_bits

View source

Returns individual bits corresponding to binary representation of x

from_bits

View source

Combine individual bits to form x

from_bits_array

View source

Combine individual bits to form classical values.

Often, converting an array can be performed faster than converting each element individually. This operation accepts any NDArray of bits such that the last dimension equals self.bitsize, and the output array satisfies output_shape = input_shape[:-1].

assert_valid_classical_val

View source

Raises an exception if val is not a valid classical value for this type.

Args

val

A classical value that should be in the domain of this QDType.

debug_str

Optional debugging information to use in exception messages.

assert_valid_classical_val_array

View source

Raises an exception if val_array is not a valid array of classical values for this type.

Often, validation on an array can be performed faster than validating each element individually.

Args

val_array

A numpy array of classical values. Each value should be in the domain of this QDType.

debug_str

Optional debugging information to use in exception messages.

is_symbolic

View source

Returns True if this qdtype is parameterized with symbolic objects.

iteration_length_or_zero

View source

Safe version of iteration length.

Returns the iteration_length if the type has it or else zero.

__ne__

Check equality and either forward a NotImplemented or return the result negated.

__eq__

Method generated by attrs for class QGF.