mindquantum.algorithm.compiler.crxx_decompose

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

Decompose Rxx gate with control qubits.

Parameters

gate (Rxx) – a Rxx gate.

Returns

List[Circuit], all possible decompose solution.

Examples

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

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


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