mindquantum.algorithm.compiler.crz_decompose

Contents

mindquantum.algorithm.compiler.crz_decompose#

mindquantum.algorithm.compiler.crz_decompose(gate: RZ)#

Decompose controlled RZ gate.

Parameters:

gate (RZ) – a RZ gate with one control qubits.

Returns:

List[Circuit], all possible decompose solution.

Examples

>>> from mindquantum.algorithm.compiler import crz_decompose
>>> from mindquantum.core.circuit import Circuit
>>> from mindquantum.core.gates import X, RZ
>>> crz = RZ(1).on(1, 0)
>>> origin_circ = Circuit() + crz
>>> decomposed_circ = crz_decompose(crz)[0]
>>> origin_circ
q0: ──────■───────

      ┏━━━┻━━━┓
q1: ──┨ RZ(1) ┠───
      ┗━━━━━━━┛
>>> decomposed_circ
q0: ────────────────■──────────────────■─────
                    ┃                  ┃
      ┏━━━━━━━━━┓ ┏━┻━┓ ┏━━━━━━━━━━┓ ┏━┻━┓
q1: ──┨ RZ(1/2) ┠─┨╺╋╸┠─┨ RZ(-1/2) ┠─┨╺╋╸┠───
      ┗━━━━━━━━━┛ ┗━━━┛ ┗━━━━━━━━━━┛ ┗━━━┛