qat.lang.AQASM.arithmetic

This module implements agnostic / high-level arithmetic routines, inspired from [AVBE96].

Warning

Most of these AbstractGates/methods require lower level routines that should be linked during the circuit extraction.

reg_size = 10
constant = 8
modulo = 15
gate = add_const_mod(reg_size, constant, modulo)

prog = Program()
qbits = prog.qalloc(gate.arity)
prog.apply(gate, qbits)
circuit = prog.to_circ()

# This circuit will crash at simulation, since it contains high level
# gates with no implementation

circuit_qft = prog.to_circ(link=[qat.lang.AQASM.qftarith])
# This will link an implementation for the abstract gates used in
# our high level gate. This circuit should not crash when simulated.

circuit_class = prog.to_circ(link=[qat.lang.AQASM.classarith])
# Same thing, but using carry-based arithmetic instead of qft-based.

qat.lang.AQASM.arithmetic.add_const_mod()

Modular constant adder

qat.lang.AQASM.arithmetic.add_mod()

Modular adder

qat.lang.AQASM.arithmetic.modular_exp()

Modular exponantiation

qat.lang.AQASM.arithmetic.mult_const_mod()

Modular constant multiplication

qat.lang.AQASM.arithmetic.mult_const()

Constant multiplication

References

AVBE96

Vlatko Vedral, Adriano Barenco, and Artur Ekert. Quantum networks for elementary arithmetic operations. Phys. Rev. A, 54:147–153, Jul 1996. URL: https://link.aps.org/doi/10.1103/PhysRevA.54.147, doi:10.1103/PhysRevA.54.147.