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