QGFPoly#
qualtran.QGFPoly
View source on GitHub
|
Univariate Polynomials with coefficients in a Galois Field GF(\(p^m\)).
Inherits From: QDType, QCDType
qualtran.QGFPoly(
degree, qgf
)
This data type represents a degree-\(n\) univariate polynomials \(f(x)=\sum_{i=0}^{n} a_i x^{i}\) where the coefficients \(a_{i}\) of the polynomial belong to a Galois Field \(GF(p^{m})\).
The data type uses the Galois library to perform arithmetic over polynomials defined over Galois Fields using the galois.Poly. References Polynomials over finite fields
[Polynomial Arithmetic](https://mhostetter.github.io/galois/latest/basic-usage/poly-arithmetic/)
Attributes
degreeThe degree \(n\) of the univariate polynomial \(f(x)\) represented by this type.
qgfAn instance of
QGFthat represents the galois field \(GF(p^m)\) over which the univariate polynomial \(f(x)\) is defined.bitsizenum_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.
Methods#
get_classical_domain
get_classical_domain() -> Iterable[Any]
Yields all possible classical (computational basis state) values representable by this type.
to_gf_coefficients
to_gf_coefficients(
f_x: galois.Poly
) -> galois.Array
Returns a big-endian array of coefficients of the polynomial f(x).
from_gf_coefficients
from_gf_coefficients(
f_x: galois.Array
) -> galois.Poly
Expects a big-endian array of coefficients that represent a polynomial f(x).
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
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.
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 QGFPoly.
View source on GitHub