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: ────────────