Polynomials over GF(\(p^m\)) - Split and Join#

from qualtran import Bloq, CompositeBloq, BloqBuilder, Signature, Register
from qualtran import QBit, QInt, QUInt, QAny
from qualtran.drawing import show_bloq, show_call_graph, show_counts_sigma
from typing import *
import numpy as np
import sympy
import cirq

GFPolySplit#

Split a register representing coefficients of a polynomial into an array of QGF types.

A register of type QGFPoly represents a univariate polynomial \(f(x)\) with coefficients in a galois field GF(\(p^m\)). Given an input quantum register representing a degree \(n\) polynomial \(f(x)\), this bloq splits it into \(n + 1\) registers of type \(QGF(p, m)\).

Given a polynomial

\[\begin{split} f(x) = \sum_{i = 0}^{n} a_{i} x^{i} \\ \forall a_{i} \in GF(p^m) \end{split}\]

the bloq splits it into a big-endian representation such that

\[ \ket{f(x)} \xrightarrow{\text{split}} \ket{a_{n}}\ket{a_{n - 1}} \cdots \ket{a_0} \]

See GFPolyJoin for the inverse operation.

Parameters#

  • dtype: An instance of QGFPoly type that represents a degree \(n\) polynomial defined over a galois field GF(\(p^m\)).

Registers#

  • reg: The register to be split. On its left, it is of the type qgf_poly. On the right, it is an array of QGFs of shape (qgf_poly.degree + 1,).

from qualtran.bloqs.gf_poly_arithmetic import GFPolySplit

Example Instances#

from qualtran import QGF, QGFPoly

gf_poly_split = GFPolySplit(QGFPoly(4, QGF(2, 3)))

Graphical Signature#

from qualtran.drawing import show_bloqs
show_bloqs([gf_poly_split],
           ['`gf_poly_split`'])

GFPolyJoin#

Join \(n+1\) registers representing coefficients of a polynomial into a QGFPoly type.

A register of type QGFPoly represents a univariate polynomial \(f(x)\) with coefficients in a galois field GF(\(p^m\)). Given an input quantum register of shape (n + 1,) and type QGF representing coefficients of a degree \(n\) polynomial \(f(x)\), this bloq joins it into a register of type QGFPoly.

Given a polynomial

\[\begin{split} f(x) = \sum_{i = 0}^{n} a_{i} x^{i} \\ \forall a_{i} \in GF(p^m) \end{split}\]

the bloq joins registers representing coefficients of the polynomial in big-endian representation such that

\[ \ket{a_{n}}\ket{a_{n - 1}} \cdots \ket{a_0} \xrightarrow{\text{join}} \ket{f(x)} \]

See GFPolySplit for the inverse operation.

Parameters#

  • dtype: An instance of QGFPoly type that represents a degree \(n\) polynomial defined over a galois field GF(\(p^m\)).

Registers#

  • reg: The register to be joined. On its left, it is an array of QGFs of shape (qgf_poly.degree + 1,). On the right, it is of the type qgf_poly.

from qualtran.bloqs.gf_poly_arithmetic import GFPolyJoin

Example Instances#

from qualtran import QGF, QGFPoly

gf_poly_join = GFPolyJoin(QGFPoly(4, QGF(2, 3)))

Graphical Signature#

from qualtran.drawing import show_bloqs
show_bloqs([gf_poly_join],
           ['`gf_poly_join`'])