mindquantum.algorithm.compiler.crx_decompose

Contents

mindquantum.algorithm.compiler.crx_decompose#

mindquantum.algorithm.compiler.crx_decompose(gate: RX)#

Decompose controlled RX gate.

Parameters:

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

Returns:

List[Circuit], all possible decompose solution.

Examples

>>> from mindquantum.algorithm.compiler import crx_decompose
>>> from mindquantum.core.circuit import Circuit
>>> from mindquantum.core.gates import RX
>>> crx = RX(1).on(1, 0)
>>> origin_circ = Circuit() + crx
>>> decomposed_circ = crx_decompose(crx)[0]
>>> origin_circ
q0: ──────■───────

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