qrisp.QuantumCircuit.append#
- QuantumCircuit.append(operation_or_instruction: Operation | Instruction, qubits: Sequence[QubitLike] | None = None, clbits: Sequence[ClbitLike] | None = None)[source]#
Append an
OperationorInstructionto this QuantumCircuit.Each qubit or classical-bit argument may be specified as a
Qubit/Clbitobject, an integer index intoself.qubits/self.clbits, or a (possibly nested) list thereof. When a list argument contains n elements, the operation is broadcast and applied n times β once per element β with the remaining scalar arguments reused for every application.If an
Instructionis given instead of anOperation, the qubits and clbits arguments are ignored; the instructionβs own qubit and classical-bit lists are used directly.- Parameters:
- operation_or_instructionOperation or Instruction
The operation or instruction to append.
- qubitsQubitLike, optional
The qubit(s) on which to apply the operation. The default is
[].- clbitsClbitLike, optional
The classical bit(s) on which to apply the operation. The default is
[].
- Returns:
- None
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) >>> multi_h_qc.h(range(4)) >>> multi_h = multi_h_qc.to_gate(name="multi h") >>> 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: ββββββββββββ