mindquantum.algorithm.compiler.cryy_decompose

View Source On Gitee
mindquantum.algorithm.compiler.cryy_decompose(gate: gates.Ryy)[source]

Decompose Ryy gate with control qubits.

Parameters

gate (Ryy) – a Ryy gate.

Returns

List[Circuit], all possible decompose solution.

Examples

>>> from mindquantum.algorithm.compiler import cryy_decompose
>>> from mindquantum.core.circuit import Circuit
>>> from mindquantum.core.gates import Ryy
>>> cryy = Ryy(2).on([0, 1], [2, 3])
>>> origin_circ = Circuit() + cryy
>>> decomposed_circ = cryy_decompose(cryy)[0]
>>> origin_circ
      ┏━━━━━━━━┓
q0: ──┨        ┠───
      ┃        ┃
      ┃ Ryy(2) ┃
q1: ──┨        ┠───
      ┗━━━━┳━━━┛

q2: ───────■───────


q3: ───────■───────
>>> decomposed_circ
      ┏━━━━━━━━━┓                                                ┏━━━━━━━━━━┓
q0: ──┨ RX(π/2) ┠───────────────■───────────────■────────────────┨ RX(-π/2) ┠───
      ┗━━━━┳━━━━┛               ┃               ┃                ┗━━━━━┳━━━━┛
           ┃      ┏━━━━━━━━━┓ ┏━┻━┓ ┏━━━━━━━┓ ┏━┻━┓ ┏━━━━━━━━━━┓       ┃
q1: ───────╂──────┨ RX(π/2) ┠─┨╺╋╸┠─┨ RZ(2) ┠─┨╺╋╸┠─┨ RX(-π/2) ┠───────╂────────
           ┃      ┗━━━━┳━━━━┛ ┗━┳━┛ ┗━━━┳━━━┛ ┗━┳━┛ ┗━━━━━┳━━━━┛       ┃
           ┃           ┃        ┃       ┃       ┃         ┃            ┃
q2: ───────■───────────■────────■───────■───────■─────────■────────────■────────
           ┃           ┃        ┃       ┃       ┃         ┃            ┃
           ┃           ┃        ┃       ┃       ┃         ┃            ┃
q3: ───────■───────────■────────■───────■───────■─────────■────────────■────────