mindquantum.core.circuit.UN

View Source On Gitee
class mindquantum.core.circuit.UN(gate: BasicGate, maps_obj, maps_ctrl=None)[source]

Map a quantum gate to different objective qubits and control qubits.

Parameters
  • gate (BasicGate) – A quantum gate.

  • maps_obj (Union[int, list[int]]) – Objective qubits.

  • maps_ctrl (Union[int, list[int]]) – Control qubits. Default: None.

Returns

Circuit, Return a quantum circuit.

Examples

>>> from mindquantum.core.circuit import UN
>>> from mindquantum.core.gates import X
>>> circuit1 = UN(X, maps_obj = [0, 1], maps_ctrl = [2, 3])
>>> print(circuit1)
      ┏━━━┓
q0: ──┨╺╋╸┠─────────
      ┗━┳━┛
        ┃   ┏━━━┓
q1: ────╂───┨╺╋╸┠───
        ┃   ┗━┳━┛
        ┃     ┃
q2: ────■─────╂─────


q3: ──────────■─────
>>> from mindquantum.core.gates import SWAP
>>> circuit2 = UN(SWAP, maps_obj =[[0, 1], [2, 3]]).x(2, 1)
>>> print(circuit2)
q0: ──╳─────────


q1: ──╳───■─────

        ┏━┻━┓
q2: ──╳─┨╺╋╸┠───
      ┃ ┗━━━┛

q3: ──╳─────────