Japanese
言語
English
Bengali
French
German
Japanese
Korean
Portuguese
Spanish
Tamil

qiskit.circuit.QuantumCircuit.compose

QuantumCircuit.compose(other, qubits=None, clbits=None, front=False, inplace=False, wrap=False)[ソース]

Compose circuit with other circuit or instruction, optionally permuting wires.

other can be narrower or of equal width to self.

パラメータ
  • other (qiskit.circuit.Instruction or QuantumCircuit) – (sub)circuit or instruction to compose onto self. If not a QuantumCircuit, this can be anything that append will accept.

  • qubits (list[Qubit|int]) – qubits of self to compose onto.

  • clbits (list[Clbit|int]) – clbits of self to compose onto.

  • front (bool) – If True, front composition will be performed. This is not possible within control-flow builder context managers.

  • inplace (bool) – If True, modify the object. Otherwise return composed circuit.

  • wrap (bool) – If True, wraps the other circuit into a gate (or instruction, depending on whether it contains only unitary instructions) before composing it onto self.

戻り値

the composed circuit (returns None if inplace==True).

戻り値の型

QuantumCircuit

例外
  • CircuitError – if no correct wire mapping can be made between the two circuits, such as if other is wider than self.

  • CircuitError – if trying to emit a new circuit while self has a partially built control-flow context active, such as the context-manager forms of if_test(), for_loop() and while_loop().

  • CircuitError – if trying to compose to the front of a circuit when a control-flow builder block is active; there is no clear meaning to this action.

サンプル

>>> lhs.compose(rhs, qubits=[3, 2], inplace=True)
            ┌───┐                   ┌─────┐                ┌───┐
lqr_1_0: ───┤ H ├───    rqr_0: ──■──┤ Tdg ├    lqr_1_0: ───┤ H ├───────────────
            ├───┤              ┌─┴─┐└─────┘                ├───┤
lqr_1_1: ───┤ X ├───    rqr_1: ┤ X ├───────    lqr_1_1: ───┤ X ├───────────────
         ┌──┴───┴──┐           └───┘                    ┌──┴───┴──┐┌───┐
lqr_1_2: ┤ U1(0.1) ├  +                     =  lqr_1_2: ┤ U1(0.1) ├┤ X ├───────
         └─────────┘                                    └─────────┘└─┬─┘┌─────┐
lqr_2_0: ─────■─────                           lqr_2_0: ─────■───────■──┤ Tdg ├
            ┌─┴─┐                                          ┌─┴─┐        └─────┘
lqr_2_1: ───┤ X ├───                           lqr_2_1: ───┤ X ├───────────────
            └───┘                                          └───┘
lcr_0: 0 ═══════════                           lcr_0: 0 ═══════════════════════

lcr_1: 0 ═══════════                           lcr_1: 0 ═══════════════════════