mindquantum.core.gates

Gate module that provides different quantum gate.

Base Class

mindquantum.core.gates.BasicGate

BasicGate is the base class of all gates.

mindquantum.core.gates.NoneParameterGate

Base class for non-parametric gates.

mindquantum.core.gates.ParameterGate

Gate that is parameterized.

mindquantum.core.gates.QuantumGate

Base class for quantum gates.

mindquantum.core.gates.NoiseGate

Noise gate class.

Quantum Gate

API Name

Description

Math

mindquantum.core.gates.CNOTGate

Control-X gate.

No formula yet.

mindquantum.core.gates.FSim

FSim gate represent fermionic simulation gate.

\({\rm FSim}(\theta, \phi) =\begin{pmatrix}1 & 0 & 0 & 0\\0 & \cos(\theta) & -i\sin(\theta) & 0\\0 & -i\sin(\theta) & \cos(\theta) & 0\\0 & 0 & 0 & e^{-i\phi}\\\end{pmatrix}\)

mindquantum.core.gates.GlobalPhase

Global phase gate.

\({\rm GlobalPhase}=\begin{pmatrix}\exp(-i\theta)&0\\0&\exp(-i\theta)\end{pmatrix}\)

mindquantum.core.gates.HGate

Hadamard gate.

\({\rm H}=\frac{1}{\sqrt{2}}\begin{pmatrix}1&1\\1&-1\end{pmatrix}\)

mindquantum.core.gates.IGate

Identity gate.

\({\rm I}=\begin{pmatrix}1&0\\0&1\end{pmatrix}\)

mindquantum.core.gates.ISWAPGate

ISWAP gate.

No formula yet.

mindquantum.core.gates.Measure

Measurement gate that measure quantum qubits.

No formula yet.

mindquantum.core.gates.PhaseShift

Phase shift gate.

\({\rm PhaseShift}=\begin{pmatrix}1&0\\0&\exp(i\theta)\end{pmatrix}\)

mindquantum.core.gates.Rn

Pauli rotate about a arbitrary axis in bloch sphere.

\(\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}\)

mindquantum.core.gates.RX

Rotation gate around x-axis.

\({\rm RX}=\begin{pmatrix}\cos(\theta/2)&-i\sin(\theta/2)\\-i\sin(\theta/2)&\cos(\theta/2)\end{pmatrix}\)

mindquantum.core.gates.Rxx

Rxx gate.

\(Rxx(\theta) = \exp{\left(-i\frac{\theta}{2} X\otimes X\right)} =\begin{pmatrix}\cos{\frac{\theta}{2}} & 0 & 0 & -i\sin{\frac{\theta}{2}}\\0 & \cos{\frac{\theta}{2}} & -i\sin{\frac{\theta}{2}} & 0\\0 & -i\sin{\frac{\theta}{2}} & \cos{\frac{\theta}{2}} & 0\\-i\sin{\frac{\theta}{2}} & 0 & 0 & \cos{\frac{\theta}{2}}\\\end{pmatrix}\)

mindquantum.core.gates.Rxy

Rxy gate.

\(Rxy(\theta) = \exp{\left(-i\frac{\theta}{2} Y\otimes X\right)} =\begin{pmatrix}\cos{\frac{\theta}{2}} & 0 & 0 & -\sin{\frac{\theta}{2}}\\0 & \cos{\frac{\theta}{2}} & -\sin{\frac{\theta}{2}} & 0\\0 & \sin{\frac{\theta}{2}} & \cos{\frac{\theta}{2}} & 0\\\sin{\frac{\theta}{2}} & 0 & 0 & \cos{\frac{\theta}{2}}\\\end{pmatrix}\)

mindquantum.core.gates.Rxz

Rxz gate.

\(Rxz(\theta) = \exp{\left(-i\frac{\theta}{2} Z\otimes X\right)} =\begin{pmatrix}\cos{\frac{\theta}{2}} & -i\sin{\frac{\theta}{2}} & 0 & 0\\-i\sin{\frac{\theta}{2}} & \cos{\frac{\theta}{2}} & 0 & 0\\0 & 0 & \cos{\frac{\theta}{2}} & i\sin{\frac{\theta}{2}}\\0 & 0 & i\sin{\frac{\theta}{2}} & \cos{\frac{\theta}{2}}\\\end{pmatrix}\)

mindquantum.core.gates.RY

Rotation gate around y-axis.

\({\rm RY}=\begin{pmatrix}\cos(\theta/2)&-\sin(\theta/2)\\\sin(\theta/2)&\cos(\theta/2)\end{pmatrix}\)

mindquantum.core.gates.Ryy

Ryy gate.

\(Ryy(\theta) = \exp{\left(-i\frac{\theta}{2} Y\otimes Y\right)} =\begin{pmatrix}\cos{\frac{\theta}{2}} & 0 & 0 & i\sin{\frac{\theta}{2}}\\0 & \cos{\frac{\theta}{2}} & -i\sin{\frac{\theta}{2}} & 0\\0 & -i\sin{\frac{\theta}{2}} & \cos{\frac{\theta}{2}} & 0\\i\sin{\frac{\theta}{2}} & 0 & 0 & \cos{\frac{\theta}{2}}\\\end{pmatrix}\)

mindquantum.core.gates.Ryz

Ryz gate.

\(Ryz(\theta) = \exp{\left(-i\frac{\theta}{2} Z\otimes Y\right)} =\begin{pmatrix}\cos{\frac{\theta}{2}} & -\sin{\frac{\theta}{2}} & 0 & 0\\\sin{\frac{\theta}{2}} & \cos{\frac{\theta}{2}} & 0 & 0\\0 & 0 & \cos{\frac{\theta}{2}} & \sin{\frac{\theta}{2}}\\0 & 0 & -\sin{\frac{\theta}{2}} & \cos{\frac{\theta}{2}}\\\end{pmatrix}\)

mindquantum.core.gates.RZ

Rotation gate around z-axis.

\({\rm RZ}=\begin{pmatrix}\exp(-i\theta/2)&0\\0&\exp(i\theta/2)\end{pmatrix}\)

mindquantum.core.gates.Rzz

Rzz gate.

\(Rzz(\theta) = \exp{\left(-i\frac{\theta}{2} Z\otimes Z\right)} =\begin{pmatrix}e^{-i\frac{\theta}{2}} & 0 & 0 & 0\\0 & e^{i\frac{\theta}{2}} & 0 & 0\\0 & 0 & e^{i\frac{\theta}{2}} & 0\\0 & 0 & 0 & e^{-i\frac{\theta}{2}}\\\end{pmatrix}\)

mindquantum.core.gates.RotPauliString

Arbitrary pauli string rotation.

\(U(\theta)=e^{-i\theta P/2}, P=\otimes_i\sigma_i, \text{where } \sigma \in \{X, Y, Z\}\)

mindquantum.core.gates.SGate

S gate.

\({\rm S}=\begin{pmatrix}1&0\\0&i\end{pmatrix}\)

mindquantum.core.gates.SWAPGate

SWAP gate that swap two different qubits.

No formula yet.

mindquantum.core.gates.SWAPalpha

SWAP alpha gate.

\(\text{SWAP}(\alpha) =\begin{pmatrix}1 & 0 & 0 & 0\\0 & \frac{1}{2}\left(1+e^{i\pi\alpha}\right) & \frac{1}{2}\left(1-e^{i\pi\alpha}\right) & 0\\0 & \frac{1}{2}\left(1-e^{i\pi\alpha}\right) & \frac{1}{2}\left(1+e^{i\pi\alpha}\right) & 0\\0 & 0 & 0 & 1\\\end{pmatrix}\)

mindquantum.core.gates.SXGate

Sqrt X (SX) gate.

\({\rm SX}=\frac{1}{2}\begin{pmatrix}1+i&1-i\\1-i&1+i\end{pmatrix}\)

mindquantum.core.gates.TGate

T gate.

\({\rm T}=\begin{pmatrix}1&0\\0&(1+i)/\sqrt(2)\end{pmatrix}\)

mindquantum.core.gates.U3

U3 gate represent arbitrary single qubit gate.

\({\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}\)

mindquantum.core.gates.XGate

Pauli-X gate.

\({\rm X}=\begin{pmatrix}0&1\\1&0\end{pmatrix}\)

mindquantum.core.gates.YGate

Pauli Y gate.

\({\rm Y}=\begin{pmatrix}0&-i\\i&0\end{pmatrix}\)

mindquantum.core.gates.ZGate

Pauli-Z gate.

\({\rm Z}=\begin{pmatrix}1&0\\0&-1\end{pmatrix}\)

mindquantum.core.gates.GroupedPauli

Multi qubit pauli string gate.

\(U =\otimes_i\sigma_i, \text{where } \sigma \in \{I, X, Y, Z\}\)

mindquantum.core.gates.Givens

Givens rotation gate.

\({\rm G}(\theta)=\exp{\left(-i\frac{\theta}{2} (Y\otimes X - X\otimes Y)\right)} =\begin{pmatrix}1 & 0 & 0 & 0\\0 & \cos{\theta} & -\sin{\theta} & 0\\0 & \sin{\theta} & \cos{\theta} & 0\\0 & 0 & 0 & 1\\\end{pmatrix}\)

Functional Gate

mindquantum.core.gates.UnivMathGate

Universal math gate.

mindquantum.core.gates.gene_univ_parameterized_gate

Generate a customer parameterized gate based on the single parameter defined unitary matrix.

mindquantum.core.gates.BarrierGate

Barrier gate will separate two gate in two different layer.

pre-instantiated gate

The gates blow are the pre-instantiated quantum gates, which can be used directly as an instance of quantum gate.

pre-instantiated gate

gate

mindquantum.core.gates.CNOT

mindquantum.core.gates.CNOTGate

mindquantum.core.gates.I

mindquantum.core.gates.IGate

mindquantum.core.gates.ISWAP

mindquantum.core.gates.ISWAPGate

mindquantum.core.gates.H

mindquantum.core.gates.HGate

mindquantum.core.gates.S

mindquantum.core.gates.PhaseShift (numpy.pi/2)

mindquantum.core.gates.SWAP

mindquantum.core.gates.SWAPGate

mindquantum.core.gates.SX

mindquantum.core.gates.SXGate

mindquantum.core.gates.T

mindquantum.core.gates.PhaseShift (numpy.pi/4)

mindquantum.core.gates.X

mindquantum.core.gates.XGate

mindquantum.core.gates.Y

mindquantum.core.gates.YGate

mindquantum.core.gates.Z

mindquantum.core.gates.ZGate

Quantum Channel

API Name

Description

Math

mindquantum.core.gates.AmplitudeDampingChannel

Amplitude damping channel express error that qubit is affected by the energy dissipation.

\(\begin{gather*}\epsilon(\rho) = E_0 \rho E_0^\dagger + E_1 \rho E_1^\dagger\\\text{where}\ {E_0}=\begin{bmatrix}1&0\\0&\sqrt{1-\gamma}\end{bmatrix},\ {E_1}=\begin{bmatrix}0&\sqrt{\gamma}\\0&0\end{bmatrix}\end{gather*}\)

mindquantum.core.gates.BitFlipChannel

A bit flip channel.

\(\epsilon(\rho) = (1 - P)\rho + P X \rho X\)

mindquantum.core.gates.BitPhaseFlipChannel

A bit&phase flip channel.

\(\epsilon(\rho) = (1 - P)\rho + P Y \rho Y\)

mindquantum.core.gates.DepolarizingChannel

A depolarizing channel.

\(\epsilon(\rho) = (1 - P)\rho + P/4( I \rho I + X \rho X + Y \rho Y + Z \rho Z)\)

mindquantum.core.gates.KrausChannel

A kraus channel.

\(\epsilon(\rho) = \sum_{k=0}^{m-1} E_k \rho E_k^\dagger\)

mindquantum.core.gates.PauliChannel

A pauli channel.

\(\epsilon(\rho) = (1 - P_x - P_y - P_z)\rho + P_x X \rho X + P_y Y \rho Y + P_z Z \rho Z\)

mindquantum.core.gates.GroupedPauliChannel

A group of pauli channels.

\(\epsilon(\rho) = \otimes_i \epsilon_\text{pauli}^i(\rho)\)

mindquantum.core.gates.PhaseDampingChannel

A phase damping channel.

\(\begin{gather*}\epsilon(\rho) = E_0 \rho E_0^\dagger + E_1 \rho E_1^\dagger\\\text{where}\ {E_0}=\begin{bmatrix}1&0\\0&\sqrt{1-\gamma}\end{bmatrix},\ {E_1}=\begin{bmatrix}0&0\\0&\sqrt{\gamma}\end{bmatrix}\end{gather*}\)

mindquantum.core.gates.PhaseFlipChannel

A phase flip channel.

\(\epsilon(\rho) = (1 - P)\rho + P Z \rho Z\)

mindquantum.core.gates.ThermalRelaxationChannel

Thermal relaxation channel.

\(\begin{gather*}\epsilon(\rho) = \text{tr}_1 \left[ \Lambda \left( \rho^T \otimes I \right) \right],\Lambda=\begin{pmatrix}\epsilon_{T_1} & 0 & 0 & \epsilon_{T_2} \\0 & 1-\epsilon_{T_1} & 0 & 0 \\0 & 0 & 0 & 0 \\\epsilon_{T_2} & 0 & 0 & 1\end{pmatrix}\\\text{where}\ \epsilon_{T_1}=e^{-T_g/T_1}, \epsilon_{T_2}=e^{-T_g/T_2}\end{gather*}\)

Functional Class

mindquantum.core.gates.MeasureResult

Measurement result container.

mindquantum.core.gates.Power

Power operator on a non parameterized gate.