QGF#
qualtran.QGF
View source on GitHub
|
Galois Field type to represent elements of a finite field.
Inherits From: QDType, QCDType
qualtran.QGF(
characteristic, degree, irreducible_poly=NOTHING
)
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/)
Attributes
characteristicThe characteristic \(p\) of the field \(GF(p^m)\). The characteristic must be prime.
degreeThe degree \(m\) of the field \(GF(p^{m})\). The degree must be a positive integer.
irreducible_polyOptional galois.Poly instance that defines the field arithmetic. This parameter is passed to
galois.GF(..., irreducible_poly=irreducible_poly, verify=False).bitsizegf_typenum_bitsnum_cbitsNumber of classical bits required to represent a single instance of this data type.
num_qubitsNumber of qubits required to represent a single instance of this data type.
order
Methods#
get_classical_domain
get_classical_domain() -> Iterable[Any]
Yields all possible classical (computational basis state) values representable by this type.
to_bits
to_bits(
x
) -> List[int]
Returns individual bits corresponding to binary representation of x
from_bits
from_bits(
bits: Sequence[int]
)
Combine individual bits to form x
from_bits_array
from_bits_array(
bits_array: NDArray[np.uint8]
)
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
assert_valid_classical_val(
val: Any, debug_str: str = 'val'
)
Raises an exception if val is not a valid classical value for this type.
Args
valA classical value that should be in the domain of this QDType.
debug_strOptional debugging information to use in exception messages.
assert_valid_classical_val_array
assert_valid_classical_val_array(
val_array: NDArray[Any], debug_str: str = 'val'
)
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_arrayA numpy array of classical values. Each value should be in the domain of this QDType.
debug_strOptional debugging information to use in exception messages.
is_symbolic
is_symbolic() -> bool
Returns True if this qdtype is parameterized with symbolic objects.
iteration_length_or_zero
iteration_length_or_zero() -> qualtran.symbolics.SymbolicInt
Safe version of iteration length.
Returns the iteration_length if the type has it or else zero.
__ne__
__ne__(
other
)
Check equality and either forward a NotImplemented or return the result negated.
__eq__
__eq__(
other
)
Method generated by attrs for class QGF.
View source on GitHub