qat.lang.AQASM.classarith.cuccaro_add

qat.lang.AQASM.classarith.cuccaro_add(reg_size: int, reg_size_2: int)

Implementation based on [CCDKM04]. Builds a circuit performing an addition using two qbits registers. The addition is done ‘in place’. Only the content of the first register is changed:

\[|a\rangle|b\rangle \mapsto |a + b\rangle|b\rangle\]

All additions, unless specified, are modulo \(2^n\) where n is the size of the register holding the result.

The circuit has size \(6n\) (\(2n\) Toffoli and \(4n\) CNOT).

Parameters
  • reg_size (int) – the number of qbits on which to perform the addition

  • reg_size_2 (int) – the number of qbits holding the value of the number to add

Warning

This routine has public arity reg_size + reg_size_2 but uses 1 additional qubit (it will be automatically allocated at circuit generation time, in the to_circ() method).