mindquantum.algorithm.compiler.cnry_decompose
- mindquantum.algorithm.compiler.cnry_decompose(gate: gates.RY)[源代码]
分解一个受控的
RY
门。样例:
>>> from mindquantum.algorithm.compiler import cnry_decompose >>> from mindquantum.core.circuit import Circuit >>> from mindquantum.core.gates import RY >>> cry = RY(1).on(2, [0, 1]) >>> origin_circ = Circuit() + cry >>> decomposed_circ = cnry_decompose(cry)[0] >>> origin_circ q0: ──────■─────── ┃ ┃ q1: ──────■─────── ┃ ┏━━━┻━━━┓ q2: ──┨ RY(1) ┠─── ┗━━━━━━━┛ >>> decomposed_circ q0: ─────────────────────────────────────────■──────────────────────────────────────────■──── ┃ ┃ ┃ ┃ q1: ────────────────■──────────────────■─────╂──────────────────■─────────────────■─────╂──── ┃ ┃ ┃ ┃ ┃ ┃ ┏━━━━━━━━━┓ ┏━┻━┓ ┏━━━━━━━━━━┓ ┏━┻━┓ ┏━┻━┓ ┏━━━━━━━━━━┓ ┏━┻━┓ ┏━━━━━━━━━┓ ┏━┻━┓ ┏━┻━┓ q2: ──┨ RY(1/4) ┠─┨╺╋╸┠─┨ RY(-1/4) ┠─┨╺╋╸┠─┨╺╋╸┠─┨ RY(-1/4) ┠─┨╺╋╸┠─┨ RY(1/4) ┠─┨╺╋╸┠─┨╺╋╸┠── ┗━━━━━━━━━┛ ┗━━━┛ ┗━━━━━━━━━━┛ ┗━━━┛ ┗━━━┛ ┗━━━━━━━━━━┛ ┗━━━┛ ┗━━━━━━━━━┛ ┗━━━┛ ┗━━━┛