mindquantum.algorithm.compiler.cswap_decompose
- mindquantum.algorithm.compiler.cswap_decompose(gate: gates.SWAPGate)[源代码]
分解一个受控的
SWAPGate
门。样例:
>>> 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: ────■───┨╺╋╸┠───■───── ┗━━━┛