mindquantum.algorithm.compiler.swap_decompose

查看源文件
mindquantum.algorithm.compiler.swap_decompose(gate: gates.SWAPGate)[源代码]

分解一个 SWAPGate 门。

参数:
返回:

List[Circuit],可能的分解方式。

样例:

>>> from mindquantum.algorithm.compiler.decompose import swap_decompose
>>> from mindquantum.core.circuit import Circuit
>>> from mindquantum.core.gates import SWAP
>>> swap = SWAP.on([1, 0])
>>> origin_circ = Circuit() + swap
>>> decomposed_circ = swap_decompose(swap)[0]
>>> origin_circ
q0: ──╳───


q1: ──╳───
>>> decomposed_circ
      ┏━━━┓       ┏━━━┓
q0: ──┨╺╋╸┠───■───┨╺╋╸┠───
      ┗━┳━┛   ┃   ┗━┳━┛
        ┃   ┏━┻━┓   ┃
q1: ────■───┨╺╋╸┠───■─────
            ┗━━━┛