mindquantum.core.gates.Rn

View Source On Gitee
class mindquantum.core.gates.Rn(alpha: ParameterResolver, beta: ParameterResolver, gamma: ParameterResolver)[source]

Pauli rotate about a arbitrary axis in bloch sphere.

The matrix expression is:

\[\begin{split}\begin{aligned} {\rm Rn}(\alpha, \beta, \gamma) &= e^{-i(\alpha \sigma_x + \beta \sigma_y + \gamma \sigma_z)/2}\\ &= \cos(f/2)I-i\sin(f/2)(\alpha \sigma_x + \beta \sigma_y + \gamma \sigma_z)/f\\ &\text{where } f=\sqrt{\alpha^2 + \beta^2 + \gamma^2} \end{aligned}\end{split}\]
Parameters

Examples

>>> import numpy as np
>>> from mindquantum.core.parameterresolver import ParameterResolver
>>> from mindquantum.core.gates import Rn
>>> theta = ParameterResolver('theta')/np.sqrt(3)
>>> Rn(theta, theta, theta).on(0, 1)
Rn(α=0.5774*theta, β=0.5774*theta, γ=0.5774*theta|0 <-: 1)
property alpha: mindquantum.core.parameterresolver.parameterresolver.ParameterResolver

Get alpha parameter of Rn gate.

Returns

ParameterResolver, the alpha.

property beta: mindquantum.core.parameterresolver.parameterresolver.ParameterResolver

Get beta parameter of Rn gate.

Returns

ParameterResolver, the beta.

property gamma: mindquantum.core.parameterresolver.parameterresolver.ParameterResolver

Get gamma parameter of Rn gate.

Returns

ParameterResolver, the gamma.

get_cpp_obj()[source]

Construct cpp obj.

hermitian()[source]

Get hermitian form of Rn gate.

Examples

>>> from mindquantum.core.gates import Rn
>>> rn = Rn('a', 'b', 0.5).on(0)
>>> rn.hermitian()
Rn(α=-a, β=-b, γ=-1/2|0)
matrix(pr: ParameterResolver = None, full=False)[source]

Get the matrix of Rn gate.

Parameters
  • pr (Union[ParameterResolver, dict]) – The parameter for Rn gate.

  • full (bool) – Whether to get the full matrix of this gate (the gate should be acted on some qubits). Default: False.