qfnn.qf_circ.gates module¶
- class qfnn.qf_circ.gates.ExtendGate¶
Bases:
object
- classmethod ccccx(circ, q1, q2, q3, q4, q5, aux1, aux2)¶
Function cccx : using the basic Toffoli gates and CX,CCX gate to implement ccccx gate
- Parameters
circ – quantum circuit
q1 – control qubits
q2 – control qubits
q3 – control qubits
q4 – control qubits
q5 – target qubits :
aux1 – auxiliary qubits
aux2 – auxiliary qubits
- Returns
the circuit you add the gate to
- Return type
circ
- classmethod cccx(circ, q1, q2, q3, q4, aux1)¶
Function cccx : using the basic Toffoli gates and CX gate to implement cccx gate :param circ: quantum circuit :param q1: control qubits :param q2: control qubits :param q3: control qubits :param q4: target qubits : :param aux1: auxiliary qubits
- Returns
the circuit you add the gate to
- Return type
circ
- classmethod cccz(circ, q1, q2, q3, q4, aux1, aux2)¶
Function cccx : using the basic Toffoli gates and CZ gate to implement cccz gate
- Parameters
circ – quantum circuit
q1 – control qubits
q2 – control qubits
q3 – control qubits
q4 – target qubits :
aux1 – auxiliary qubits
aux2 – auxiliary qubits
- Returns
the circuit you add the gate to
- Return type
circ
- classmethod ccz(circ, q1, q2, q3, aux1)¶
Function ccz : using the basic Toffoli gates and CZ gate to implement ccz gate, which will flip the sign of state |111>
- Parameters
circ – quantum circuit
q1 – control qubits
q2 – control qubits
q3 – target qubits :
aux1 – auxiliary qubits
- Returns
the circuit you add the gate to
- Return type
circ
- classmethod cnx(circ, q, aux, q_num)¶
Function cnz : using the basic Toffoli gates and CZ gate to implement cc..cx gate,which includes n control gates.
- Parameters
circ – quantum circuit
q – qubits list. The last is target qubits
aux – auxiliary qubits
q_num – the number of qubits in q.
- classmethod cnz(circ, q, aux, q_num)¶
Function cnz : using the basic Toffoli gates and CZ gate to implement cc..cz gate,which includes n control gates.
- Parameters
circ – quantum circuit
q – qubits list. The last is target qubits
aux – auxiliary qubits
q_num – the number of qubits in q.
- classmethod neg_weight_gate(circ, qubits, aux, state)¶
Function neg_weight_gate : adding NOT(X) gate before the qubits associated with 0 state. For example, if we want to flip the sign of |1101>, we add X gate for q2 beforethe cccz gate, as follows.
- Parameters
circ – quantum circuit
qubits – the register of input qubits
aux – auxiliary qubits
state – a string that represents the state of the qubits,such as ‘1101’