mindquantum.core.gates.U3
- class mindquantum.core.gates.U3(theta: ParameterResolver, phi: ParameterResolver, lamda: ParameterResolver)[source]
U3 gate represent arbitrary single qubit gate.
U3 gate with matrix as:
\[\begin{split}{\rm U3}(\theta, \phi, \lambda) =\begin{pmatrix}\cos(\theta/2)&-e^{i\lambda}\sin(\theta/2)\\ e^{i\phi}\sin(\theta/2)&e^{i(\phi+\lambda)}\cos(\theta/2)\end{pmatrix}\end{split}\]It can be decomposed as:
\[U3(\theta, \phi, \lambda) = RZ(\phi) RX(-\pi/2) RZ(\theta) RX(\pi/2) RZ(\lambda)\]- Parameters
theta (Union[numbers.Number, dict, ParameterResolver]) – First parameter for U3 gate.
phi (Union[numbers.Number, dict, ParameterResolver]) – Second parameter for U3 gate.
lamda (Union[numbers.Number, dict, ParameterResolver]) – Third parameter for U3 gate.
Examples
>>> from mindquantum.core.gates import U3 >>> U3('theta','phi','lambda').on(0, 1) U3(θ=theta, φ=phi, λ=lambda|0 <-: 1)
- hermitian()[source]
Get hermitian form of U3 gate.
Examples
>>> from mindquantum.core.gates import U3 >>> u3 = U3('a', 'b', 0.5).on(0) >>> u3.hermitian() U3(θ=-a, φ=-1/2, λ=-b|0)
- property lamda: mindquantum.core.parameterresolver.parameterresolver.ParameterResolver
Get lamda parameter of U3 gate.
- Returns
ParameterResolver, the lamda.
- matrix(pr: ParameterResolver = None, full=False)[source]
Get the matrix of U3 gate.
- Parameters
pr (Union[ParameterResolver, dict]) – The parameter for U3 gate.
full (bool) – Whether to get the full matrix of this gate (the gate should be acted on some qubits). Default:
False
.
- property phi: mindquantum.core.parameterresolver.parameterresolver.ParameterResolver
Get phi parameter of U3 gate.
- Returns
ParameterResolver, the phi.
- property theta: mindquantum.core.parameterresolver.parameterresolver.ParameterResolver
Get theta parameter of U3 gate.
- Returns
ParameterResolver, the theta.