mindquantum.algorithm.compiler.cnrz_decompose
- mindquantum.algorithm.compiler.cnrz_decompose(gate: gates.RZ)[source]
Decompose controlled
RZ
gate.- Parameters
- Returns
List[
Circuit
], all possible decompose solution.
Examples
>>> 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) ┠─┨╺╋╸┠─┨╺╋╸┠── ┗━━━━━━━━━┛ ┗━━━┛ ┗━━━━━━━━━━┛ ┗━━━┛ ┗━━━┛ ┗━━━━━━━━━━┛ ┗━━━┛ ┗━━━━━━━━━┛ ┗━━━┛ ┗━━━┛