cutqc2.library.Arithmetic package¶
Submodules¶
cutqc2.library.Arithmetic.ripple_carry_adder module¶
Teague Tomesh - 2/10/2020
Implementation of an n-bit ripple-carry adder.
Based on the specification given in Cuccaro, Draper, Kutin, Moulton. (https://arxiv.org/abs/quant-ph/0410184v1)
- class cutqc2.library.Arithmetic.ripple_carry_adder.RCAdder(nbits=None, a=0, b=0, use_toffoli=False, barriers=False, measure=False, regname=None)[source]¶
Bases:
objectAn n-bit ripple-carry adder can be generated using an instance of the RCAdder class by calling the gen_circuit() method.
- This adder circuit uses 1 ancilla qubit to add together two values
a = a_(n-1)…a_0 and b = b_(n-1)…a_0
- and store their sum
s = s_n…s_0
in the registers which initially held the b value.
The adder circuit uses 2 + binary_len(a) + binary_len(b) qubits. The initial carry value is stored in the qubit at index = 0. The binary value of a_i is stored in the qubit at index = 2*i + 2 The binary value of b_i is stored in the qubit at index = 2*i + 1 The high bit, s_n, is stored in the last qubit at index = num_qubits - 1
- nbits¶
size, in bits, of the numbers the adder can handle
- Type:
int
- nq¶
number of qubits needed to construct the adder circuit
- Type:
int
- a, b
optional parameters to specify the numbers the adder should add. Will throw an exception if the length of the bitstring representations of a or b are greater than nbits.
- Type:
int
- use_toffoli¶
Should the toffoli gate be used in the generated circuit or should it first be decomposed
- Type:
bool
- barriers¶
should barriers be included in the generated circuit
- Type:
bool
- regname¶
optional string to name the quantum and classical registers. This allows for the easy concatenation of multiple QuantumCircuits.
- Type:
str
- qr¶
Qiskit QuantumRegister holding all of the quantum bits
- Type:
QuantumRegister
- circ¶
Qiskit QuantumCircuit that represents the uccsd circuit
- Type:
QuantumCircuit