mindquantum.core.circuit.SwapParts

View Source On Gitee
class mindquantum.core.circuit.SwapParts(a: Iterable, b: Iterable, maps_ctrl=None)[source]

Swap two different part of quantum circuit, with or without control qubits.

Parameters
  • a (Iterable) – The first part you need to swap.

  • b (Iterable) – The second part you need to swap.

  • maps_ctrl (int, Iterable) – Control the swap by a single qubit or by different qubits or just no control qubit. Default: None.

Examples

>>> from mindquantum.core.circuit import SwapParts
>>> SwapParts([1, 2], [3, 4], 0)
q0: ──■─■───
      ┃ ┃
      ┃ ┃
q1: ──╳─╂───
      ┃ ┃
      ┃ ┃
q2: ──┃─╳───
      ┃ ┃
      ┃ ┃
q3: ──╳─┃───


q4: ────╳───