qrisp.QuantumCircuit.append#

QuantumCircuit.append(operation_or_instruction, qubits=[], clbits=[])[source]#

Method for appending Operation or Instruction objects to the QuantumCircuit.

The parameter qubits can be an integer, a list of integers, a Qubit object or a list of Qubit objects. The same is valid for the clbit parameter.

If given an Instruction object instead of an Operation, the given qubit and clbit parameters are ignored.

Parameters
operation_or_instructionOperation or Instruction

The operation or instruction to be appended to the QuantumCircuit.

qubitsinteger, list[integer], Qubit, list[Qubit], optional

The qubits on which to apply the operation. The default is [].

clbitsinteger, list[integer], Clbit, list[Clbit], optional

The classical bits on which to apply the operation. The default is [].

Examples

We create a \(H^{\otimes 4}\) gate and append it to every second qubit of another QuantumCircuit:

>>> from qrisp import QuantumCircuit
>>> multi_h_qc = QuantumCircuit(4, name = "multi h")
>>> multi_h_qc.h(range(4))
>>> multi_h = multi_h_qc.to_gate()
>>> qc = QuantumCircuit(8)
>>> qc.append(multi_h, [2*i for i in range(4)])
>>> print(qc)
       ┌──────────┐
 qb_4: ┤0         ├
       │          │
 qb_5: ┤          ├
       │          │
 qb_6: ┤1         ├
       │          │
 qb_7: ┤  multi h ├
       │          │
 qb_8: ┤2         ├
       │          │
 qb_9: ┤          ├
       │          │
qb_10: ┤3         ├
       └──────────┘
qb_11: ────────────