GF(\(2^m\)) Addition#

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

GF2Addition#

In place addition over GF(\(2^m\)).

The bloq implements in place addition of two quantum registers storing elements from GF(\(2^m\)). Addition in GF(\(2^m\)) simply reduces to a component wise XOR, which can be implemented via CNOT gates. The addition is performed in-place such that

\[ |x\rangle |y\rangle \rightarrow |x\rangle |x + y\rangle \]

Parameters#

  • bitsize: The degree \(m\) of the galois field \(GF(2^m)\). Also corresponds to the number of qubits in each of the two input registers x and y that should be added.

Registers#

  • x: Input THRU register of size \(m\) that stores elements from \(GF(2^m)\).

  • y: Input THRU register of size \(m\) that stores elements from \(GF(2^m)\).

from qualtran.bloqs.gf_arithmetic import GF2Addition

Example Instances#

gf16_addition = GF2Addition(4)
import sympy

m = sympy.Symbol('m')
gf2_addition_symbolic = GF2Addition(m)

Graphical Signature#

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

Call Graph#

from qualtran.resource_counting.generalizers import ignore_split_join
gf16_addition_g, gf16_addition_sigma = gf16_addition.call_graph(max_depth=1, generalizer=ignore_split_join)
show_call_graph(gf16_addition_g)
show_counts_sigma(gf16_addition_sigma)
../../_images/8aaefdbed84e883478f68e3a907b1a3fe2533e3156a2f410314c1b5c2e8cc876.svg

Counts totals:

  • CNOT: 4