mindquantum.algorithm.compiler.abc_decompose
- mindquantum.algorithm.compiler.abc_decompose(gate: QuantumGate, return_u3: bool = True)[source]
Decompose two-qubit controlled gate via ABC decomposition.
- Parameters
gate (
QuantumGate
) – quantum gate with 1 control bit and 1 target bit.return_u3 (bool) – return gates in form of
U3
ifTrue
, otherwise returnUnivMathGate
. Default:True
.
- Returns
Circuit
, including at most 2 CNOT gates and 4 single-qubit gates.
Examples
>>> import mindquantum as mq >>> from mindquantum.algorithm.compiler.decompose import abc_decompose >>> from scipy.stats import unitary_group >>> g = mq.UnivMathGate('U', unitary_group.rvs(2, random_state=123)).on(1, 0) >>> print(mq.Circuit() + g) q0: ────■───── ┃ ┏━┻━┓ q1: ──┨ U ┠─── ┗━━━┛ >>> circ_decomposed = abc_decompose(g) >>> print(circ_decomposed) ┏━━━━━━━━━━━━┓ q0: ───────────────────■──────────────────────────────────────■───┨ RZ(1.1469) ┠──────────────────── ┃ ┃ ┗━━━━━━━━━━━━┛ ┏━━━━━━━━━━━━┓ ┏━┻━┓ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┏━┻━┓ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ q1: ──┨ RZ(2.6016) ┠─┨╺╋╸┠─┨ U3(θ=1.1043, φ=π, λ=-0.6572) ┠─┨╺╋╸┠─┨ U3(θ=1.1043, φ=-5.086, λ=0) ┠─── ┗━━━━━━━━━━━━┛ ┗━━━┛ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ ┗━━━┛ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛