mindquantum.algorithm.compiler.cswap_decompose

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

分解一个受控的 SWAPGate 门。

参数:
返回:

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

样例:

>>> from mindquantum.algorithm.compiler.decompose import cswap_decompose
>>> from mindquantum.core import Circuit, SWAP
>>> cswap = SWAP.on([1, 2], 0)
>>> origin_circ = Circuit() + cswap
>>> decomposed_circ = cswap_decompose(cswap)[0]
>>> origin_circ
q0: ──■───


q1: ──╳───


q2: ──╳───
>>> decomposed_circ
q0: ──────────■───────────

      ┏━━━┓   ┃   ┏━━━┓
q1: ──┨╺╋╸┠───■───┨╺╋╸┠───
      ┗━┳━┛   ┃   ┗━┳━┛
        ┃   ┏━┻━┓   ┃
q2: ────■───┨╺╋╸┠───■─────
            ┗━━━┛