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