mindquantum.algorithm.compiler.cs_decompose

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

Decompose controlled SGate gate.

Parameters

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

Returns

List[Circuit], all possible decompose solution.

Examples

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

      ┏━┻━┓
q1: ──┨ S ┠───
      ┗━━━┛
>>> decomposed_circ
      ┏━━━┓
q0: ──┨ T ┠───■────────────■─────
      ┗━━━┛   ┃            ┃
      ┏━━━┓ ┏━┻━┓ ┏━━━━┓ ┏━┻━┓
q1: ──┨ T ┠─┨╺╋╸┠─┨ T† ┠─┨╺╋╸┠───
      ┗━━━┛ ┗━━━┛ ┗━━━━┛ ┗━━━┛