mindquantum.algorithm.compiler.ch_decompose

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

Decompose controlled HGate gate.

Parameters

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

Returns

List[Circuit], all possible decompose solution.

Examples

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

      ┏━┻━┓
q1: ──┨ H ┠───
      ┗━━━┛
>>> decomposed_circ
q0: ──────────────────────■─────────────────────────

      ┏━━━┓ ┏━━━┓ ┏━━━┓ ┏━┻━┓ ┏━━━━┓ ┏━━━┓ ┏━━━━┓
q1: ──┨ S ┠─┨ H ┠─┨ T ┠─┨╺╋╸┠─┨ T† ┠─┨ H ┠─┨ S† ┠───
      ┗━━━┛ ┗━━━┛ ┗━━━┛ ┗━━━┛ ┗━━━━┛ ┗━━━┛ ┗━━━━┛