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