Standard Gates
MimiqCircuitsBase.GateU — TypeGateU(θ, ϕ, λ[, γ = 0])Single qubit generic unitary gate $U(\theta, \phi, \lambda, \gamma = 0)$, where $\theta$, $\phi$, and $\lambda$ are the Euler angles specified in radians, and $\gamma$ is a global phase.
See also GateU3, GateP, GateU2, GateU1
Matrix representation
\[\operatorname{U}(\theta, \phi, \lambda, \gamma = 0) = \mathrm{e}^{i\gamma} \begin{pmatrix} \cos\left(\frac{\theta}{2}\right) & -\mathrm{e}^{i\lambda}\sin\left(\frac{\theta}{2}\right) \\ \mathrm{e}^{i\phi}\sin\left(\frac{\theta}{2}\right) & \mathrm{e}^{i(\phi+\lambda)}\cos\left(\frac{\theta}{2}\right) \end{pmatrix}\]
Examples
julia> @variables θ ϕ λ
3-element Vector{Symbolics.Num}:
θ
ϕ
λ
julia> GateU(θ, ϕ, λ)
U(θ, ϕ, λ)
julia> matrix(GateU(2.023, 0.5, 0.1))
2×2 Matrix{ComplexF64}:
0.53059+0.0im -0.843394-0.0846217im
0.743864+0.406375im 0.437915+0.299594im
julia> c = push!(Circuit(), GateU(θ, ϕ, λ), 1)
1-qubit circuit with 1 instructions:
└── U(θ, ϕ, λ) @ q[1]
julia> push!(c, GateU(π/8, π/2, π/4), 2)
2-qubit circuit with 2 instructions:
├── U(θ, ϕ, λ) @ q[1]
└── U(π/8, π/2, π/4) @ q[2]
julia> power(GateU(θ, ϕ, λ), 2), inverse(GateU(θ, ϕ, λ))
(U(θ, ϕ, λ)^2, U(-θ, -λ, -ϕ))
Decomposition
Since $U$ gate, is the most general single qubit unitary matrix, all other matrices are defined from it.
julia> decompose(GateU(θ, λ, ϕ))
1-qubit circuit with 1 instructions:
└── U(θ, λ, ϕ) @ q[1]
MimiqCircuitsBase.GateP — TypeGateP(λ)Single qubit Phase gate.
λ is the phase angle in radians.
Matrix representation
\[\operatorname{P}(\lambda) = \operatorname{U}(0, 0, \lambda) = \begin{pmatrix} 1 & 0 \\ 0 & \mathrm{e}^{i\lambda} \end{pmatrix}\]
Examples
julia> @variables λ
1-element Vector{Symbolics.Num}:
λ
julia> GateP(λ)
P(λ)
julia> matrix(GateP(1.989))
2×2 Matrix{ComplexF64}:
1.0+0.0im 0.0+0.0im
0.0+0.0im -0.40612+0.91382im
julia> c = push!(Circuit(), GateP(λ), 1)
1-qubit circuit with 1 instructions:
└── P(λ) @ q[1]
julia> push!(c, GateP(π/2), 2)
2-qubit circuit with 2 instructions:
├── P(λ) @ q[1]
└── P(π/2) @ q[2]
Decomposition
julia> decompose(GateP(λ))
1-qubit circuit with 1 instructions:
└── U(0, 0, λ) @ q[1]
MimiqCircuitsBase.GateU1 — TypeGateU1(λ)Single qubit rotation \operatorname{U1}(\lambda) about the Z axis.
Equivalent to GateP.
Matrix representation
\[\operatorname{U1}(\lambda) = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\lambda} \end{pmatrix}\]
Examples
julia> @variables λ
1-element Vector{Symbolics.Num}:
λ
julia> GateU1(λ)
U1(λ)
julia> matrix(GateU1(0.519))
2×2 Matrix{ComplexF64}:
1.0+0.0im 0.0+0.0im
0.0+0.0im 0.868316+0.496012im
julia> c = push!(Circuit(), GateU1(λ), 1)
1-qubit circuit with 1 instructions:
└── U1(λ) @ q[1]
julia> push!(c, GateU1(π/2), 2)
2-qubit circuit with 2 instructions:
├── U1(λ) @ q[1]
└── U1(π/2) @ q[2]
julia> power(GateU1(λ), 2), inverse(GateU1(λ))
(U1(λ)^2, U1(-λ))
Decomposition
julia> decompose(GateU1(λ))
1-qubit circuit with 1 instructions:
└── U(0, 0, λ) @ q[1]
MimiqCircuitsBase.GateU2 — TypeGateU2(ϕ, λ)Single qubit rotation \operatorname{U2}(\phi, \lambda) about the X+Z axis.
Matrix representation
\[\operatorname{U2}(\phi,\lambda) = \frac{1}{\sqrt{2}}e^{-(\phi+\lambda)/2}\begin{pmatrix} 1 & -e^{i\lambda} \\ e^{i\phi} & e^{i(\phi+\lambda)} \end{pmatrix}\]
Examples
julia> @variables ϕ λ
2-element Vector{Symbolics.Num}:
ϕ
λ
julia> GateU2(ϕ, λ)
U2(ϕ, λ)
julia> matrix(GateU2(2.023, 0.5))
2×2 Matrix{ComplexF64}:
0.707107+0.0im -0.620545-0.339005im
-0.308969+0.636033im -0.576077+0.410044im
julia> c = push!(Circuit(), GateU2(ϕ, λ), 1)
1-qubit circuit with 1 instructions:
└── U2(ϕ, λ) @ q[1]
julia> push!(c, GateU2(π/2, π/4), 2)
2-qubit circuit with 2 instructions:
├── U2(ϕ, λ) @ q[1]
└── U2(π/2, π/4) @ q[2]
julia> power(GateU2(ϕ, λ), 2), inverse(GateU2(ϕ, λ))
(U2(ϕ, λ)^2, U2(-3.141592653589793 - λ, π - ϕ))
Decomposition
julia> decompose(GateU2(ϕ, λ))
1-qubit circuit with 1 instructions:
└── U3(π/2, ϕ, λ) @ q[1]
MimiqCircuitsBase.GateU3 — TypeGateU3(θ, ϕ, λ)Single qubit generic unitary gate U3(\theta, \phi, \lambda).
This gate is equivalent to the generic unitary gate GateU, differing from it only by a global phase of $\frac{\phi + \lambda + \theta}{2}$.
Matrix representation
\[\operatorname{U3}(\theta,\phi,\lambda) = \begin{pmatrix} \cos\left(\frac{\theta}{2}\right) & -e^{i\lambda}\sin\left(\frac{\theta}{2}\right) \\ \mathrm{e}^{i\phi}\sin\left(\frac{\theta}{2}\right) & \mathrm{e}^{i(\phi+\lambda)}\cos\left(\frac{\theta}{2}\right) \end{pmatrix}\]
Examples
julia> @variables θ ϕ λ
3-element Vector{Symbolics.Num}:
θ
ϕ
λ
julia> GateU3(θ, ϕ, λ)
U3(θ, ϕ, λ)
julia> matrix(GateU3(2.023, 0.5, 0.1))
2×2 Matrix{ComplexF64}:
0.53059+0.0im -0.843394-0.0846217im
0.743864+0.406375im 0.437915+0.299594im
julia> c = push!(Circuit(), GateU3(θ, ϕ, λ), 1)
1-qubit circuit with 1 instructions:
└── U3(θ, ϕ, λ) @ q[1]
julia> push!(c, GateU3(π/8, π/2, π/4), 2)
2-qubit circuit with 2 instructions:
├── U3(θ, ϕ, λ) @ q[1]
└── U3(π/8, π/2, π/4) @ q[2]
julia> power(GateU3(θ, ϕ, λ), 2), inverse(GateU3(θ, ϕ, λ))
(U3(θ, ϕ, λ)^2, U3(-θ, -λ, -ϕ))
Decomposition
julia> decompose(GateU3(θ, ϕ, λ))
1-qubit circuit with 1 instructions:
└── U(θ, ϕ, λ) @ q[1]
MimiqCircuitsBase.GateX — TypeGateX()Single qubit Pauli-X gate.
Matrix representation
\[\operatorname{X} = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}\]
Examples
julia> GateX()
X
julia> matrix(GateX())
2×2 Matrix{Int64}:
0 1
1 0
julia> c = push!(Circuit(), GateX(), 1)
1-qubit circuit with 1 instructions:
└── X @ q[1]
julia> push!(c, GateX, 2)
2-qubit circuit with 2 instructions:
├── X @ q[1]
└── X @ q[2]
Decomposition
julia> decompose(GateX())
1-qubit circuit with 1 instructions:
└── U(π, 0, π) @ q[1]
MimiqCircuitsBase.GateY — TypeGateY()Single qubit Pauli-Y gate.
Matrix representation
\[\operatorname{Y} = \begin{pmatrix} 0 & -i \\ i & 0 \end{pmatrix}\]
Examples
julia> GateY()
Y
julia> matrix(GateY())
2×2 Matrix{ComplexF64}:
0.0+0.0im 0.0-1.0im
0.0+1.0im 0.0+0.0im
julia> c = push!(Circuit(), GateY(), 1)
1-qubit circuit with 1 instructions:
└── Y @ q[1]
julia> push!(c, GateY, 2)
2-qubit circuit with 2 instructions:
├── Y @ q[1]
└── Y @ q[2]
Decomposition
julia> decompose(GateY())
1-qubit circuit with 1 instructions:
└── U(π, π/2, π/2) @ q[1]
MimiqCircuitsBase.GateZ — TypeGateZ()Single qubit Pauli-Z gate.
Matrix representation
\[\operatorname{Z} = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}\]
Examples
julia> GateZ()
Z
julia> matrix(GateZ())
2×2 Matrix{Float64}:
1.0 0.0
0.0 -1.0
julia> c = push!(Circuit(), GateZ(), 1)
1-qubit circuit with 1 instructions:
└── Z @ q[1]
julia> push!(c, GateZ, 2)
2-qubit circuit with 2 instructions:
├── Z @ q[1]
└── Z @ q[2]
Decomposition
julia> decompose(GateZ())
1-qubit circuit with 1 instructions:
└── P(π) @ q[1]
MimiqCircuitsBase.GateH — TypeGateH()Single qubit Hadamard gate.
Matrix representation
\[\operatorname H = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}\]
Examples
julia> GateH()
H
julia> matrix(GateH())
2×2 Matrix{Float64}:
0.707107 0.707107
0.707107 -0.707107
julia> c = push!(Circuit(), GateH(), 1)
1-qubit circuit with 1 instructions:
└── H @ q[1]
julia> push!(c, GateH, 1)
1-qubit circuit with 2 instructions:
├── H @ q[1]
└── H @ q[1]
julia> power(GateH(), 2), inverse(GateH())
(H^2, H)
Decomposition
julia> decompose(GateH())
1-qubit circuit with 1 instructions:
└── U(π/2, 0, π) @ q[1]
MimiqCircuitsBase.GateID — TypeGateID()Single qubit identity gate
Matrix representation
\[\operatorname{I} = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}\]
Examples
julia> GateID()
ID
julia> matrix(GateID())
2×2 Matrix{Float64}:
1.0 -0.0
0.0 1.0
julia> c = push!(Circuit(), GateID(), 1)
1-qubit circuit with 1 instructions:
└── ID @ q[1]
julia> power(GateID(), 2), inverse(GateID())
(ID, ID)
Decomposition
julia> decompose(GateID())
1-qubit circuit with 1 instructions:
└── U(0, 0, 0) @ q[1]
MimiqCircuitsBase.GateS — TypeGateS()Single qubit $S$ gate (or phase gate). It is defined as the square root of the $Z$ gate.
See also GateSDG, GateZ, Power
Matrix representation
\[\operatorname{S} = \sqrt{\operatorname{Z}} = \begin{pmatrix} 1 & 0 \\ 0 & i \end{pmatrix}\]
Examples
julia> GateS()
S
julia> matrix(GateS())
2×2 Matrix{ComplexF64}:
1.0+0.0im 0.0+0.0im
0.0+0.0im 0.0+1.0im
julia> c = push!(Circuit(), GateS(), 1)
1-qubit circuit with 1 instructions:
└── S @ q[1]
julia> push!(c, GateS, 2)
2-qubit circuit with 2 instructions:
├── S @ q[1]
└── S @ q[2]
julia> power(GateS(), 2), inverse(GateS())
(Z, S†)
Decomposition
julia> decompose(GateS())
1-qubit circuit with 1 instructions:
└── U(0, 0, π/2) @ q[1]
MimiqCircuitsBase.GateSDG — TypeGateSDG()Single qubit S-dagger gate (conjugate transpose of the S gate).
See also GateS, GateZ, Power, Inverse
Matrix representation
\[\operatorname S^\dagger = \begin{pmatrix} 1 & 0 \\ 0 & -i \end{pmatrix}\]
Examples
julia> GateSDG()
S†
julia> matrix(GateSDG())
2×2 adjoint(::Matrix{ComplexF64}) with eltype ComplexF64:
1.0-0.0im 0.0-0.0im
0.0-0.0im 0.0-1.0im
julia> c = push!(Circuit(), GateSDG(), 1)
1-qubit circuit with 1 instructions:
└── S† @ q[1]
julia> push!(c, GateSDG, 2)
2-qubit circuit with 2 instructions:
├── S† @ q[1]
└── S† @ q[2]
julia> power(GateSDG(), 2), inverse(GateSDG())
((S†)^2, S)
Decomposition
julia> decompose(GateSDG())
1-qubit circuit with 1 instructions:
└── U(0, 0, -1π/2) @ q[1]
MimiqCircuitsBase.GateT — TypeGateT()Single qubit T gate. It is defined as the square root of the $S$ gate, $Z^{\frac{1}{4}}$.
See also GateTDG, GateS, GateZ, Power
Matrix representation
\[\operatorname{Z} = \operatorname{Z}^{\frac{1}{4}} = \begin{pmatrix} 1 & 0 \\ 0 & \exp(\frac{i\pi}{4}) \end{pmatrix}\]
Examples
julia> GateT()
T
julia> matrix(GateT())
2×2 Matrix{ComplexF64}:
1.0+0.0im 0.0+0.0im
0.0+0.0im 0.707107+0.707107im
julia> c = push!(Circuit(), GateT(), 1)
1-qubit circuit with 1 instructions:
└── T @ q[1]
julia> push!(c, GateT, 2)
2-qubit circuit with 2 instructions:
├── T @ q[1]
└── T @ q[2]
julia> power(GateT(), 2), power(GateT(), 4), inverse(GateT())
(S, Z, T†)
Decomposition
julia> decompose(GateT())
1-qubit circuit with 1 instructions:
└── U(0, 0, π/4) @ q[1]
MimiqCircuitsBase.GateTDG — TypeGateTDG()Single qubit T-dagger gate (conjugate transpose of the T gate).
See also GateT
Matrix Representation
\[\operatorname T^\dagger = \begin{pmatrix} 1 & 0 \\ 0 & \exp(\frac{-i\pi}{4}) \end{pmatrix}\]
Examples
julia> GateTDG()
T†
julia> matrix(GateTDG())
2×2 adjoint(::Matrix{ComplexF64}) with eltype ComplexF64:
1.0-0.0im 0.0-0.0im
0.0-0.0im 0.707107-0.707107im
julia> c = push!(Circuit(), GateTDG(), 1)
1-qubit circuit with 1 instructions:
└── T† @ q[1]
julia> push!(c, GateTDG, 2)
2-qubit circuit with 2 instructions:
├── T† @ q[1]
└── T† @ q[2]
julia> power(GateTDG(), 2), power(GateTDG(), 4), inverse(GateTDG())
((T†)^2, (T†)^4, T)
Decomposition
julia> decompose(GateTDG())
1-qubit circuit with 1 instructions:
└── U(0, 0, -1π/4) @ q[1]
MimiqCircuitsBase.GateSX — TypeGateSX()Single qubit $\sqrt{X}$ gate.
See also GateSXDG, GateX, Power
Matrix representation
\[\operatorname{SX} = \sqrt{\operatorname{X}} = \frac{1}{2} \begin{pmatrix} 1+i & 1-i \\ 1-i & 1+i \end{pmatrix}\]
Examples
julia> GateSX()
SX
julia> matrix(GateSX())
2×2 Matrix{ComplexF64}:
0.5+0.5im 0.5-0.5im
0.5-0.5im 0.5+0.5im
julia> c = push!(Circuit(), GateSX(), 1)
1-qubit circuit with 1 instructions:
└── SX @ q[1]
julia> push!(c, GateSX, 2)
2-qubit circuit with 2 instructions:
├── SX @ q[1]
└── SX @ q[2]
julia> power(GateSX(), 2), inverse(GateSX())
(X, SX†)
Decomposition
julia> decompose(GateSX())
1-qubit circuit with 4 instructions:
├── S† @ q[1]
├── H @ q[1]
├── S† @ q[1]
└── U(0, 0, 0, π/4) @ q[1]MimiqCircuitsBase.GateSXDG — TypeGateSXDG()Single qubit $\sqrt{X}^\dagger$ gate (conjugate transpose of the $\sqrt{X}$ gate)
See also GateSX, GateX, Power, Inverse
Matrix representation
\[\operatorname{SXDG} = \sqrt{\operatorname{X}}^\dagger = \frac{1}{2} \begin{pmatrix} 1-i & 1+i \\ 1+i & 1-i \end{pmatrix}\]
Examples
julia> GateSXDG()
SX†
julia> matrix(GateSXDG())
2×2 adjoint(::Matrix{ComplexF64}) with eltype ComplexF64:
0.5-0.5im 0.5+0.5im
0.5+0.5im 0.5-0.5im
julia> c = push!(Circuit(), GateSXDG(), 1)
1-qubit circuit with 1 instructions:
└── SX† @ q[1]
julia> push!(c, GateSXDG, 2)
2-qubit circuit with 2 instructions:
├── SX† @ q[1]
└── SX† @ q[2]
julia> power(GateSXDG(), 2), inverse(GateSXDG())
((SX†)^2, SX)
MimiqCircuitsBase.GateR — TypeGateR(θ, ϕ)Single qubit parametric rotation $\operatorname{R}(\theta, \lambda)$ gate.
It performs a rotation of $\theta$ radians for the target qubit around an XY-plane axis of the Bloch sphere determined by $\cos(\phi)\mathbf{x} + \sin(\phi)\mathbf{y}$.
Matrix representation
\[\operatorname{R}(\theta,\phi) = \begin{pmatrix} \cos\frac{\theta}{2} & -ie^{-i\phi}\sin\frac{\theta}{2} \\ -ie^{i\phi}\sin\frac{\theta}{2} & \cos\frac{\theta}{2} \end{pmatrix}\]
Examples
julia> @variables θ ϕ
2-element Vector{Symbolics.Num}:
θ
ϕ
julia> GateR(θ, ϕ)
R(θ, ϕ)
julia> matrix(GateR(2.023, 1.989))
2×2 Matrix{ComplexF64}:
0.53059+0.0im -0.77458+0.344239im
0.77458+0.344239im 0.53059+0.0im
julia> c = push!(Circuit(), GateR(θ, ϕ), 1)
1-qubit circuit with 1 instructions:
└── R(θ, ϕ) @ q[1]
julia> push!(c, GateR(π/2, π/4), 2)
2-qubit circuit with 2 instructions:
├── R(θ, ϕ) @ q[1]
└── R(π/2, π/4) @ q[2]
Decomposition
julia> decompose(GateR(θ, ϕ))
1-qubit circuit with 1 instructions:
└── U3(θ, -1.5707963267948966 + ϕ, 1.5707963267948966 - ϕ) @ q[1]
MimiqCircuitsBase.GateRX — TypeGateRX(θ)Single qubit parametric rotation $\operatorname{R}_X(\theta)$ gate.
It performs a rotation of $\theta$ radians around the X-axis of the Bloch sphere of the target qubit.
Matrix representation
\[\operatorname{R}_X(\theta) = \begin{pmatrix} \cos\frac{\theta}{2} & -i\sin\frac{\theta}{2} \\ -i\sin\frac{\theta}{2} & \cos\frac{\theta}{2} \end{pmatrix}\]
Examples
julia> @variables θ
1-element Vector{Symbolics.Num}:
θ
julia> GateRX(θ)
RX(θ)
julia> matrix(GateRX(1.989))
2×2 Matrix{ComplexF64}:
0.544922+0.0im 0.0-0.838487im
0.0-0.838487im 0.544922+0.0im
julia> c = push!(Circuit(), GateRX(θ), 1)
1-qubit circuit with 1 instructions:
└── RX(θ) @ q[1]
julia> push!(c, GateRX(π/2), 2)
2-qubit circuit with 2 instructions:
├── RX(θ) @ q[1]
└── RX(π/2) @ q[2]
Decomposition
julia> decompose(GateRX(θ))
1-qubit circuit with 1 instructions:
└── U(θ, -1π/2, π/2) @ q[1]
MimiqCircuitsBase.GateRY — TypeGateRY(θ)Single qubit parametric rotation $\operatorname{R}_Y(\theta)$ gate.
It performss a rotation of $\theta$ radians around the Y-axis of the Bloch sphere of the target qubit.
Matrix representation
\[\operatorname{R}_Y(\theta) = \begin{pmatrix} \cos\frac{\theta}{2} & -\sin\frac{\theta}{2} \\ \sin\frac{\theta}{2} & \cos\frac{\theta}{2} \end{pmatrix}\]
Examples
julia> @variables θ
1-element Vector{Symbolics.Num}:
θ
julia> GateRY(θ)
RY(θ)
julia> matrix(GateRY(1.989))
2×2 Matrix{Float64}:
0.544922 -0.838487
0.838487 0.544922
julia> c = push!(Circuit(), GateRY(θ), 1)
1-qubit circuit with 1 instructions:
└── RY(θ) @ q[1]
julia> push!(c, GateRY(π/2), 2)
2-qubit circuit with 2 instructions:
├── RY(θ) @ q[1]
└── RY(π/2) @ q[2]
Decomposition
julia> decompose(GateRY(θ))
1-qubit circuit with 1 instructions:
└── U(θ, 0, 0) @ q[1]
MimiqCircuitsBase.GateRZ — TypeGateRZ(λ)Single qubit parametric rotation $\operatorname{R}_Z(\lambda)$ gate.
It performs a rotation of $\lambda$ radians around the Z-axis of the Bloch sphere for the target qubit.
Matrix representation
\[\operatorname{RZ}(\lambda) = \begin{pmatrix} e^{-i\frac{\lambda}{2}} & 0 \\ 0 & e^{i\frac{\lambda}{2}} \end{pmatrix}\]
Examples
julia> @variables θ
1-element Vector{Symbolics.Num}:
θ
julia> GateRZ(θ)
RZ(θ)
julia> matrix(GateRZ(1.989))
2×2 Matrix{ComplexF64}:
0.544922-0.838487im 0.0+0.0im
0.0+0.0im 0.544922+0.838487im
julia> c = push!(Circuit(), GateRZ(θ), 1)
1-qubit circuit with 1 instructions:
└── RZ(θ) @ q[1]
julia> push!(c, GateRZ(π/2), 2)
2-qubit circuit with 2 instructions:
├── RZ(θ) @ q[1]
└── RZ(π/2) @ q[2]
Decomposition
julia> decompose(GateRZ(θ))
1-qubit circuit with 1 instructions:
└── U(0, 0, θ, (-1//2)*θ) @ q[1]
MimiqCircuitsBase.GateSWAP — TypeGateSWAP()Two qubit SWAP gate.
Matrix representation
\[\operatorname{SWAP} = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}\]
Examples
julia> GateSWAP()
SWAP
julia> matrix(GateSWAP())
4×4 Matrix{Float64}:
1.0 0.0 0.0 0.0
0.0 0.0 1.0 0.0
0.0 1.0 0.0 0.0
0.0 0.0 0.0 1.0
julia> c = push!(Circuit(), GateSWAP(), 1, 2)
2-qubit circuit with 1 instructions:
└── SWAP @ q[1:2]
julia> push!(c, GateSWAP, 3, 4)
4-qubit circuit with 2 instructions:
├── SWAP @ q[1:2]
└── SWAP @ q[3:4]
julia> power(GateSWAP(), 2), inverse(GateSWAP())
(Parallel(2, ID), SWAP)
Decomposition
julia> decompose(GateSWAP())
2-qubit circuit with 3 instructions:
├── CX @ q[1], q[2]
├── CX @ q[2], q[1]
└── CX @ q[1], q[2]
MimiqCircuitsBase.GateISWAP — TypeGateISWAP()Two qubit ISWAP gate.
See also GateSWAP.
Matrix representation
\[\operatorname{ISWAP} = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & i & 0 \\ 0 & i & 0 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}\]
Examples
julia> GateISWAP()
ISWAP
julia> matrix(GateISWAP())
4×4 Matrix{ComplexF64}:
1.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 0.0+0.0im 0.0+1.0im 0.0+0.0im
0.0+0.0im 0.0+1.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 0.0+0.0im 0.0+0.0im 1.0+0.0im
julia> c = push!(Circuit(), GateISWAP(), 1, 2)
2-qubit circuit with 1 instructions:
└── ISWAP @ q[1:2]
julia> push!(c, GateISWAP, 3, 4)
4-qubit circuit with 2 instructions:
├── ISWAP @ q[1:2]
└── ISWAP @ q[3:4]
julia> power(GateISWAP(), 2), inverse(GateISWAP())
(ISWAP^2, ISWAP†)
Decomposition
julia> decompose(GateISWAP())
2-qubit circuit with 6 instructions:
├── S @ q[1]
├── S @ q[2]
├── H @ q[1]
├── CX @ q[1], q[2]
├── CX @ q[2], q[1]
└── H @ q[2]
MimiqCircuitsBase.GateCX — TypeGateCX()Two qubit Controlled-$X$ gate (or CNOT).
Details
Implemented as an alias to Control(1, GateX()).
By convention we refer to the first qubit as the control qubit and the second qubit as the target.
Matrix representation
\[\operatorname{CX} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{pmatrix}\]
Examples
julia> GateCX(), numcontrols(GateCX()), numtargets(GateCX())
(CX, 1, 1)
julia> matrix(GateCX())
4×4 Matrix{Float64}:
1.0 0.0 0.0 0.0
0.0 1.0 0.0 0.0
0.0 0.0 0.0 1.0
0.0 0.0 1.0 0.0
julia> c = push!(Circuit(), GateCX(), 1, 2)
2-qubit circuit with 1 instructions:
└── CX @ q[1], q[2]
julia> power(GateCX(), 2), inverse(GateCX())
(CID, CX)
Decomposition
julia> decompose(GateCX())
2-qubit circuit with 1 instructions:
└── CX @ q[1], q[2]
MimiqCircuitsBase.GateCY — TypeGateCY()Two qubit Controlled-$Y$ gate.
Details
Implemented as an alias to Control(1, GateY()).
By convention we refer to the first qubit as the control qubit and the second qubit as the target.
Matrix representation
\[\operatorname{CY} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & -i \\ 0 & 0 & i & 0 \end{pmatrix}\]
Examples
julia> GateCY(), numcontrols(GateCY()), numtargets(GateCY())
(CY, 1, 1)
julia> matrix(GateCY())
4×4 Matrix{ComplexF64}:
1.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 1.0+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 0.0+0.0im 0.0+0.0im 0.0-1.0im
0.0+0.0im 0.0+0.0im 0.0+1.0im 0.0+0.0im
julia> c = push!(Circuit(), GateCY(), 1, 2)
2-qubit circuit with 1 instructions:
└── CY @ q[1], q[2]
julia> power(GateCY(), 2), inverse(GateCY())
(CID, CY)
Decomposition
julia> decompose(GateCY())
2-qubit circuit with 3 instructions:
├── S† @ q[2]
├── CX @ q[1], q[2]
└── S @ q[2]
MimiqCircuitsBase.GateCZ — TypeGateCZ()Two qubit Controlled-$Z$ gate.
Details
Implemented as an alias to Control(1, GateZ()).
By convention we refer to the first qubit as the control qubit and the second qubit as the target.
Matrix representation
\[\operatorname{CZ} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & -1 \end{pmatrix}\]
Examples
julia> GateCZ(), numcontrols(GateCZ()), numtargets(GateCZ())
(CZ, 1, 1)
julia> matrix(GateCZ())
4×4 Matrix{Float64}:
1.0 0.0 0.0 0.0
0.0 1.0 0.0 0.0
0.0 0.0 1.0 0.0
0.0 0.0 0.0 -1.0
julia> c = push!(Circuit(), GateCZ(), 1, 2)
2-qubit circuit with 1 instructions:
└── CZ @ q[1], q[2]
julia> power(GateCZ(), 2), inverse(GateCZ())
(CID, CZ)
Decomposition
julia> decompose(GateCZ())
2-qubit circuit with 3 instructions:
├── H @ q[2]
├── CX @ q[1], q[2]
└── H @ q[2]MimiqCircuitsBase.GateCH — TypeGateCH()Two qubit controlled-Hadamard gate.
Details
Implemented as an alias to Control(1, GateH()).
By convention, the first qubit is the control and the second is the target.
Matrix representation
\[\operatorname{CH} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\ 0 & 0 & \frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}} \end{pmatrix}\]
Examples
julia> GateCH(), numcontrols(GateCH), numtargets(GateCH)
(CH, 1, 1)
julia> matrix(GateCH())
4×4 Matrix{Float64}:
1.0 0.0 0.0 0.0
0.0 1.0 0.0 0.0
0.0 0.0 0.707107 0.707107
0.0 0.0 0.707107 -0.707107
julia> c = push!(Circuit(), GateCH(), 1, 2)
2-qubit circuit with 1 instructions:
└── CH @ q[1], q[2]
julia> power(GateCH(), 2), inverse(GateCH())
(C(H^2), CH)
Decomposition
julia> decompose(GateCH())
2-qubit circuit with 7 instructions:
├── S @ q[2]
├── H @ q[2]
├── T @ q[2]
├── CX @ q[1], q[2]
├── T† @ q[2]
├── H @ q[2]
└── S† @ q[2]
MimiqCircuitsBase.GateCS — TypeGateCS()Two qubit Controlled-S gate.
Details
Implemented as an alias to Control(1, GateS()).
Matrix representation
\[\operatorname{CS} =\begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & i \end{pmatrix}\]
Examples
julia> GateCS(), numcontrols(GateCS()), numtargets(GateCS())
(CS, 1, 1)
julia> matrix(GateCS())
4×4 Matrix{ComplexF64}:
1.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 1.0+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 0.0+0.0im 1.0+0.0im 0.0+0.0im
0.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+1.0im
julia> c = push!(Circuit(), GateCS(), 1, 2)
2-qubit circuit with 1 instructions:
└── CS @ q[1], q[2]
julia> power(GateCS(), 2), inverse(GateCS())
(CZ, C(S†))
Decomposition
julia> decompose(GateCS())
2-qubit circuit with 1 instructions:
└── CP(π/2) @ q[1], q[2]
MimiqCircuitsBase.GateCSDG — TypeGateCSDG()
Adjoint of two qubit Controlled-S gate.Details
Implemented as an alias to inverse(Control(1, GateS())).
Matrix representation
\[\operatorname{CS}^{\dagger} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & -i \end{pmatrix}\]
Examples
julia> GateCSDG(), numcontrols(GateCSDG()), numtargets(GateCSDG())
(C(S†), 1, 1)
julia> matrix(GateCSDG())
4×4 Matrix{ComplexF64}:
1.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 1.0+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 0.0+0.0im 1.0-0.0im 0.0-0.0im
0.0+0.0im 0.0+0.0im 0.0-0.0im 0.0-1.0im
julia> c = push!(Circuit(), GateCSDG(), 1, 2)
2-qubit circuit with 1 instructions:
└── C(S†) @ q[1], q[2]
julia> power(GateCSDG(), 2), inverse(GateCSDG())
(C((S†)^2), CS)
Decomposition
julia> decompose(GateCSDG())
2-qubit circuit with 1 instructions:
└── CP(-1π/2) @ q[1], q[2]
MimiqCircuitsBase.GateCSX — TypeGateCSX()
Two qubit Controled-SX gate.Details
Implemented as an alias to Control(1, GateSX()).
See also GateSX, GateCSXDG, Control.
Matrix representation
\[\operatorname{CSX} =\begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \frac{1+i}{2} & \frac{1-i}{2} \\ 0 & 0 & \frac{1-i}{2} & \frac{1+i}{2} \end{pmatrix}\]
Examples
julia> GateCSX(), numcontrols(GateCSX()), numtargets(GateCSX())
(CSX, 1, 1)
julia> matrix(GateCSX())
4×4 Matrix{ComplexF64}:
1.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 1.0+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 0.0+0.0im 0.5+0.5im 0.5-0.5im
0.0+0.0im 0.0+0.0im 0.5-0.5im 0.5+0.5im
julia> c = push!(Circuit(), GateCSX(), 1, 2)
2-qubit circuit with 1 instructions:
└── CSX @ q[1], q[2]
julia> power(GateCSX(), 2), inverse(GateCSX())
(CX, C(SX†))
Decomposition
julia> decompose(GateCSX())
2-qubit circuit with 3 instructions:
├── H @ q[2]
├── CU1(π/2) @ q[1], q[2]
└── H @ q[2]
MimiqCircuitsBase.GateCSXDG — TypeGateCSXDG()Two qubit CSX-dagger gate. (Control on second qubit)
Details
Implemented as an alias to Control(1, GateSXDG()).
See also GateSX, GateCSXDG, Control.
Matrix representation
\[\operatorname{CSX}^{\dagger} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 0 & 0 & \frac{1-i}{2} & \frac{1+i}{2} \\ 0 & 0 & \frac{1+i}{2} & \frac{1-i}{2} \end{pmatrix}\]
Examples
julia> GateCSXDG(), numcontrols(GateCSXDG()), numtargets(GateCSXDG())
(C(SX†), 1, 1)
julia> matrix(GateCSXDG())
4×4 Matrix{ComplexF64}:
1.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 1.0+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 0.0+0.0im 0.5-0.5im 0.5+0.5im
0.0+0.0im 0.0+0.0im 0.5+0.5im 0.5-0.5im
julia> c = push!(Circuit(), GateCSXDG(), 1, 2)
2-qubit circuit with 1 instructions:
└── C(SX†) @ q[1], q[2]
julia> power(GateCSXDG(), 2), inverse(GateCSXDG())
(C((SX†)^2), CSX)
Decomposition
julia> decompose(GateCSXDG())
2-qubit circuit with 3 instructions:
├── H @ q[2]
├── CU1(-1π/2) @ q[1], q[2]
└── H @ q[2]
MimiqCircuitsBase.GateCU — TypeGateCU(θ, ϕ, λ)Controlled-$\operatorname{U}(\theta, \phi, \lambda)$ gate.
Details
Implemented as an alias to Control(1, GateU(θ, ϕ, λ, γ)).
\[\operatorname{CU}(\theta, \phi, \lambda, \gamma) = \frac{1}{2} \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & e^{i\gamma} \cos\left(\frac{\theta}{2}\right) & -e^{i\gamma} e^{i\lambda}\sin\left(\frac{\theta}{2}\right) \\ 0 & 0 & e^{i\gamma} \mathrm{e}^{i\phi}\sin\left(\frac{\theta}{2}\right) & e^{i\gamma} \mathrm{e}^{i(\phi+\lambda)}\cos\left(\frac{\theta}{2}\right) \end{pmatrix}\]
Examples
julia> @variables θ ϕ λ γ
4-element Vector{Symbolics.Num}:
θ
ϕ
λ
γ
julia> GateCU(θ, ϕ, λ, γ), numcontrols(GateCU(θ, ϕ, λ, γ)), numtargets(GateCU(θ, ϕ, λ, γ))
(CU(θ, ϕ, λ, γ), 1, 1)
julia> matrix(GateCU(2.023, 0.5, 0.1, 0.2))
4×4 Matrix{ComplexF64}:
1.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 1.0+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 0.0+0.0im 0.520013+0.105412im -0.809771-0.250491im
0.0+0.0im 0.0+0.0im 0.648302+0.546057im 0.369666+0.380622im
julia> c = push!(Circuit(), GateCU(θ, ϕ, λ, γ), 1, 2)
2-qubit circuit with 1 instructions:
└── CU(θ, ϕ, λ, γ) @ q[1], q[2]
julia> push!(c, GateCU(π/8, π/2, π/4, π/7), 1, 2)
2-qubit circuit with 2 instructions:
├── CU(θ, ϕ, λ, γ) @ q[1], q[2]
└── CU(π/8, π/2, π/4, π/7) @ q[1], q[2]
julia> power(GateCU(θ, ϕ, λ, γ), 2), inverse(GateCU(θ, ϕ, λ, γ))
(C(U(θ, ϕ, λ, γ)^2), CU(-θ, -λ, -ϕ, -γ))
Decomposition
julia> decompose(GateCU(θ, λ, ϕ, γ))
2-qubit circuit with 7 instructions:
├── P(γ) @ q[1]
├── P((1//2)*(λ + ϕ)) @ q[1]
├── P((1//2)*(-λ + ϕ)) @ q[2]
├── CX @ q[1], q[2]
├── U((-1//2)*θ, 0, (1//2)*(-λ - ϕ)) @ q[2]
├── CX @ q[1], q[2]
└── U((1//2)*θ, λ, 0) @ q[2]
MimiqCircuitsBase.GateCP — TypeGateCP(θ)Controlled-$\operatorname{P}(\lambda)$ gate.
Details
Implemented as an alias to Control(GateP(θ)).
Examples
julia> @variables λ
1-element Vector{Symbolics.Num}:
λ
julia> GateCP(λ), numcontrols(GateCP(λ)), numtargets(GateCP(λ))
(CP(λ), 1, 1)
julia> matrix(GateCP(1.989))
4×4 Matrix{ComplexF64}:
1.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 1.0+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 0.0+0.0im 1.0+0.0im 0.0+0.0im
0.0+0.0im 0.0+0.0im 0.0+0.0im -0.40612+0.91382im
julia> c = push!(Circuit(), GateCP(λ), 1, 2)
2-qubit circuit with 1 instructions:
└── CP(λ) @ q[1], q[2]
julia> push!(c, GateCP(π/8), 1, 2)
2-qubit circuit with 2 instructions:
├── CP(λ) @ q[1], q[2]
└── CP(π/8) @ q[1], q[2]
julia> power(GateCP(λ), 2), inverse(GateCP(λ))
(CP(2λ), CP(-λ))
Decomposition
julia> @variables θ
1-element Vector{Symbolics.Num}:
θ
julia> decompose(GateCP(θ))
2-qubit circuit with 5 instructions:
├── P((1//2)*θ) @ q[1]
├── CX @ q[1], q[2]
├── P((-1//2)*θ) @ q[2]
├── CX @ q[1], q[2]
└── P((1//2)*θ) @ q[2]MimiqCircuitsBase.GateCRX — TypeGateCRX(θ)Controlled-$\operatorname{R}_X(\theta)$ gate.
Details
Implemented as an alias to Control(GateRX(θ)).
Matrix representation
\[\operatorname{CRX}(\theta) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 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}\]
Examples
julia> @variables θ
1-element Vector{Symbolics.Num}:
θ
julia> GateCRX(θ), numcontrols(GateCRX(θ)), numtargets(GateCRX(θ))
(CRX(θ), 1, 1)
julia> matrix(GateCRX(1.989))
4×4 Matrix{ComplexF64}:
1.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 1.0+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 0.0+0.0im 0.544922+0.0im 0.0-0.838487im
0.0+0.0im 0.0+0.0im 0.0-0.838487im 0.544922+0.0im
julia> c = push!(Circuit(), GateCRX(θ), 1, 2)
2-qubit circuit with 1 instructions:
└── CRX(θ) @ q[1], q[2]
julia> push!(c, GateCRX(π/8), 1, 2)
2-qubit circuit with 2 instructions:
├── CRX(θ) @ q[1], q[2]
└── CRX(π/8) @ q[1], q[2]
julia> power(GateCRX(θ), 2), inverse(GateCRX(θ))
(CRX(2θ), CRX(-θ))
Decomposition
julia> decompose(GateCRX(θ))
2-qubit circuit with 5 instructions:
├── P(π/2) @ q[2]
├── CX @ q[1], q[2]
├── U((-1//2)*θ, 0, 0) @ q[2]
├── CX @ q[1], q[2]
└── U((1//2)*θ, -1π/2, 0) @ q[2]
MimiqCircuitsBase.GateCRY — TypeGateCRY(θ)Controlled-$\operatorname{R}_Y(\theta)$ gate.
Details
Implemented as an alias to Control(GateRY(θ)).
Matrix representation
\[\operatorname{CRY}(\theta) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \cos\frac{\theta}{2} & -\sin\frac{\theta}{2} \\ 0 & 0 & \sin\frac{\theta}{2} & \cos\frac{\theta}{2} \end{pmatrix}\]
Examples
julia> @variables θ
1-element Vector{Symbolics.Num}:
θ
julia> GateCRY(θ), numcontrols(GateCRY(θ)), numtargets(GateCRY(θ))
(CRY(θ), 1, 1)
julia> matrix(GateCRY(1.989))
4×4 Matrix{Float64}:
1.0 0.0 0.0 0.0
0.0 1.0 0.0 0.0
0.0 0.0 0.544922 -0.838487
0.0 0.0 0.838487 0.544922
julia> c = push!(Circuit(), GateCRY(θ), 1, 2)
2-qubit circuit with 1 instructions:
└── CRY(θ) @ q[1], q[2]
julia> push!(c, GateCRY(π/8), 1, 2)
2-qubit circuit with 2 instructions:
├── CRY(θ) @ q[1], q[2]
└── CRY(π/8) @ q[1], q[2]
julia> power(GateCRY(θ), 2), inverse(GateCRY(θ))
(CRY(2θ), CRY(-θ))
Decomposition
julia> decompose(GateCRY(θ))
2-qubit circuit with 4 instructions:
├── RY((1//2)*θ) @ q[2]
├── CX @ q[1], q[2]
├── RY((-1//2)*θ) @ q[2]
└── CX @ q[1], q[2]
MimiqCircuitsBase.GateCRZ — TypeGateCRZ(θ)Controlled-$\operatorname{R}_Z(\theta)$ gate.
Details
Implemented as an alias to Control(GateRZ(θ)).
Matrix representation
\[ \operatorname{CRZ}(\theta) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & e^{-i\frac{\lambda}{2}} & 0 \\ 0 & 0 & 0 & e^{i\frac{\lambda}{2}} \end{pmatrix}\]
Examples
julia> @variables θ
1-element Vector{Symbolics.Num}:
θ
julia> GateCRZ(θ), numcontrols(GateCRZ(θ)), numtargets(GateCRZ(θ))
(CRZ(θ), 1, 1)
julia> matrix(GateCRZ(1.989))
4×4 Matrix{ComplexF64}:
1.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 1.0+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 0.0+0.0im 0.544922-0.838487im 0.0+0.0im
0.0+0.0im 0.0+0.0im 0.0+0.0im 0.544922+0.838487im
julia> c = push!(Circuit(), GateCRZ(θ), 1, 2)
2-qubit circuit with 1 instructions:
└── CRZ(θ) @ q[1], q[2]
julia> push!(c, GateCRZ(π/8), 1, 2)
2-qubit circuit with 2 instructions:
├── CRZ(θ) @ q[1], q[2]
└── CRZ(π/8) @ q[1], q[2]
julia> power(GateCRZ(θ), 2), inverse(GateCRZ(θ))
(CRZ(2θ), CRZ(-θ))
Decomposition
julia> decompose(GateCRZ(θ))
2-qubit circuit with 4 instructions:
├── RZ((1//2)*θ) @ q[2]
├── CX @ q[1], q[2]
├── RZ((-1//2)*θ) @ q[2]
└── CX @ q[1], q[2]
MimiqCircuitsBase.GateECR — TypeGateECR()Two qubit ECR echo gate.
Matrix representation
\[\operatorname{ECR} = \frac{1}{\sqrt{2}} \begin{pmatrix} 0 & 1 & 0 & i \\ 1 & 0 & -i & 0 \\ 0 & i & 0 & 1 \\ -i & 0 & 1 & 0 \end{pmatrix}\]
Examples
julia> GateECR()
ECR
julia> matrix(GateECR())
4×4 Matrix{ComplexF64}:
0.0+0.0im 0.0+0.0im … 0.0+0.707107im
0.0+0.0im 0.0+0.0im 0.707107+0.0im
0.707107+0.0im 0.0-0.707107im 0.0+0.0im
0.0-0.707107im 0.707107+0.0im 0.0+0.0im
julia> c = push!(Circuit(), GateECR(), 1, 2)
2-qubit circuit with 1 instructions:
└── ECR @ q[1:2]
julia> power(GateECR(), 2), inverse(GateECR())
(Parallel(2, ID), ECR)
Decomposition
julia> decompose(GateECR())
2-qubit circuit with 3 instructions:
├── RZX(π/4) @ q[1:2]
├── X @ q[1]
└── RZX(-1π/4) @ q[1:2]
MimiqCircuitsBase.GateDCX — TypeGateDCX()Two qubit double-CNOT (control on first qubit and then second) OR DCX gate.
Matrix representation
\[\operatorname{DCX}= \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 1 & 0 & 0 \end{pmatrix}\]
Examples
julia> GateDCX()
DCX
julia> matrix(GateDCX())
4×4 Matrix{Float64}:
1.0 0.0 0.0 0.0
0.0 0.0 1.0 0.0
0.0 0.0 0.0 1.0
0.0 1.0 0.0 0.0
julia> c = push!(Circuit(), GateDCX(), 1, 2)
2-qubit circuit with 1 instructions:
└── DCX @ q[1:2]
julia> power(GateDCX(), 2), inverse(GateDCX())
(DCX†, DCX†)
Decomposition
julia> decompose(GateDCX())
2-qubit circuit with 2 instructions:
├── CX @ q[1], q[2]
└── CX @ q[2], q[1]
MimiqCircuitsBase.GateRXX — TypeGateRXX(θ)Parametric two qubit $X \otimes X$ interaction \operatorname{R}_{XX}(\theta) gate.
It corresponds to a rotation of $\theta$ radians along the XX axis of the two-qubit Bloch sphere.
See also GateRYY, GateRZZ, GateRZX, GateXXplusYY, GateXXminusYY.
Matrix representation
\[\operatorname{R}_{XX}(\theta) = \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}\]
Examples
julia> @variables θ
1-element Vector{Symbolics.Num}:
θ
julia> GateRXX(θ)
RXX(θ)
julia> matrix(GateRXX(θ))
4×4 Matrix{Complex{Symbolics.Num}}:
cos((1//2)*θ) 0 0 -im*sin((1//2)*θ)
0 cos((1//2)*θ) -im*sin((1//2)*θ) 0
0 -im*sin((1//2)*θ) cos((1//2)*θ) 0
-im*sin((1//2)*θ) 0 0 cos((1//2)*θ)
julia> c = push!(Circuit(), GateRXX(θ), 1, 2)
2-qubit circuit with 1 instructions:
└── RXX(θ) @ q[1:2]
julia> push!(c, GateRXX(π/2), 1, 2)
2-qubit circuit with 2 instructions:
├── RXX(θ) @ q[1:2]
└── RXX(π/2) @ q[1:2]
Decomposition
julia> decompose(GateRXX(θ))
2-qubit circuit with 7 instructions:
├── H @ q[1]
├── H @ q[2]
├── CX @ q[1], q[2]
├── RZ(θ) @ q[2]
├── CX @ q[1], q[2]
├── H @ q[2]
└── H @ q[1]
MimiqCircuitsBase.GateRYY — TypeGateRYY(θ)Parametric two qubit $Y \otimes Y$ interaction \operatorname{R}_{YY}(\theta) gate.
It corresponds to a rotation of $\theta$ radians along the YY axis of the two-qubit Bloch sphere.
See also GateRXX, GateRZZ, GateRZX, GateXXplusYY, GateXXminusYY.
Matrix representation
\[\operatorname{R}_{YY}(\theta) = \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}\]
Examples
julia> @variables θ
1-element Vector{Symbolics.Num}:
θ
julia> GateRYY(θ)
RYY(θ)
julia> matrix(GateRYY(θ))
4×4 Matrix{Complex{Symbolics.Num}}:
cos((1//2)*θ) 0 0 im*sin((1//2)*θ)
0 cos((1//2)*θ) -im*sin((1//2)*θ) 0
0 -im*sin((1//2)*θ) cos((1//2)*θ) 0
im*sin((1//2)*θ) 0 0 cos((1//2)*θ)
julia> c = push!(Circuit(), GateRYY(θ), 1, 2)
2-qubit circuit with 1 instructions:
└── RYY(θ) @ q[1:2]
julia> push!(c, GateRYY(π/2), 1, 2)
2-qubit circuit with 2 instructions:
├── RYY(θ) @ q[1:2]
└── RYY(π/2) @ q[1:2]
Decomposition
julia> decompose(GateRYY(θ))
2-qubit circuit with 7 instructions:
├── RX(π/2) @ q[1]
├── RX(π/2) @ q[2]
├── CX @ q[1], q[2]
├── RZ(θ) @ q[2]
├── CX @ q[1], q[2]
├── RX(-1π/2) @ q[1]
└── RX(-1π/2) @ q[2]
MimiqCircuitsBase.GateRZX — TypeGateRZX(θ)Parametric two qubit $Z \otimes X$ interaction \operatorname{R}_{ZX}(\theta) gate.
It corresponds to a rotation of $\theta$ radians about ZX.
See also GateRXX, GateRYY, GateRZZ, GateXXplusYY, GateXXminusYY.
Matrix representation
\[\operatorname{RZX}(\theta) =\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}\]
Examples
julia> @variables θ
1-element Vector{Symbolics.Num}:
θ
julia> GateRZX(θ)
RZX(θ)
julia> matrix(GateRZX(θ))
4×4 Matrix{Complex{Symbolics.Num}}:
cos((1//2)*θ) -im*sin((1//2)*θ) 0 0
-im*sin((1//2)*θ) cos((1//2)*θ) 0 0
0 0 cos((1//2)*θ) im*sin((1//2)*θ)
0 0 im*sin((1//2)*θ) cos((1//2)*θ)
julia> c = push!(Circuit(), GateRZX(θ), 1, 2)
2-qubit circuit with 1 instructions:
└── RZX(θ) @ q[1:2]
julia> push!(c, GateRZX(π/2), 1, 2)
2-qubit circuit with 2 instructions:
├── RZX(θ) @ q[1:2]
└── RZX(π/2) @ q[1:2]
Decomposition
julia> decompose(GateRZX(θ))
2-qubit circuit with 5 instructions:
├── H @ q[2]
├── CX @ q[1], q[2]
├── RZ(θ) @ q[2]
├── CX @ q[1], q[2]
└── H @ q[2]
MimiqCircuitsBase.GateRZZ — TypeGateRZZ(θ)Parametric two qubit $Z \otimes Z$ interaction \operatorname{R}_{ZZ}(\theta) gate.
It corresponds to a rotation of $\theta$ radians along the ZZ axis of the two-qubit Bloch sphere.
See also GateRXX, GateRYY, GateRZX, GateXXplusYY, GateXXminusYY.
Matrix representation
\[\operatorname{R}_{ZZ}(\theta) = \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}\]
Examples
julia> @variables θ
1-element Vector{Symbolics.Num}:
θ
julia> GateRZZ(θ)
RZZ(θ)
julia> matrix(GateRZZ(θ))
4×4 Matrix{Complex{Symbolics.Num}}:
cos((-1//2)*θ) + im*sin((-1//2)*θ) … 0
0 0
0 0
0 cos((-1//2)*θ) + im*sin((-1//2)*θ)
julia> c = push!(Circuit(), GateRZZ(θ), 1, 2)
2-qubit circuit with 1 instructions:
└── RZZ(θ) @ q[1:2]
julia> push!(c, GateRZZ(π/2), 1, 2)
2-qubit circuit with 2 instructions:
├── RZZ(θ) @ q[1:2]
└── RZZ(π/2) @ q[1:2]
Decomposition
julia> decompose(GateRZZ(θ))
2-qubit circuit with 3 instructions:
├── CX @ q[1], q[2]
├── RZ(θ) @ q[2]
└── CX @ q[1], q[2]
MimiqCircuitsBase.GateXXminusYY — TypeGateXXminusYY(θ, β)Parametric two qubit $X \otimes X - Y \otimes Y$ interaction $\operatorname{(XX-YY)}(\theta, \beta)$ gate, where $\theta$ and $\beta$ are the rotation and phase angles.
See also GateRXX, GateRYY, GateRZZ, GateRZX, GateXXplusYY.
Matrix Representation
\[\operatorname{(XX-YY)}(\theta, \beta) = \begin{pmatrix} \cos(\frac{\theta}{2}) & 0 & 0 & -i\sin(\frac{\theta}{2})e^{-i\beta} \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ -i\sin(\frac{\theta}{2})e^{i\beta} & 0 & 0 & \cos(\frac{\theta}{2}) \end{pmatrix}\]
Examples
julia> @variables θ β
2-element Vector{Symbolics.Num}:
θ
β
julia> GateXXminusYY(θ, β)
XXminusYY(θ, β)
julia> matrix(GateXXminusYY(θ, β))
4×4 Matrix{Complex{Symbolics.Num}}:
cos((1//2)*θ) … sin(-β)*sin((1//2)*θ) - im*cos(-β)*sin((1//2)*θ)
0 0
0 0
sin(β)*sin((1//2)*θ) - im*cos(β)*sin((1//2)*θ) cos((1//2)*θ)
julia> c = push!(Circuit(), GateXXminusYY(θ, β), 1, 2)
2-qubit circuit with 1 instructions:
└── XXminusYY(θ, β) @ q[1:2]
julia> push!(c, GateXXminusYY(π/2, 0.0), 1, 2)
2-qubit circuit with 2 instructions:
├── XXminusYY(θ, β) @ q[1:2]
└── XXminusYY(π/2, 0π) @ q[1:2]
Decomposition
julia> decompose(GateXXminusYY(θ, β))
2-qubit circuit with 14 instructions:
├── RZ(-β) @ q[2]
├── RZ(-1π/2) @ q[1]
├── SX @ q[1]
├── RZ(π/2) @ q[1]
├── S @ q[2]
├── CX @ q[1], q[2]
├── RY((1//2)*θ) @ q[1]
├── RY((-1//2)*θ) @ q[2]
├── CX @ q[1], q[2]
├── S† @ q[2]
├── RZ(-1π/2) @ q[1]
├── SX† @ q[1]
├── RZ(π/2) @ q[1]
└── RZ(β) @ q[2]
MimiqCircuitsBase.GateXXplusYY — TypeGateXXplusYY(θ, β)Parametric two qubit $X \otimes X + Y \otimes Y$ interaction $\operatorname{(XX+YY)}(\theta, \beta)$ gate, where $\theta$ and $\beta$ are the rotation and phase angles.
See also GateRXX, GateRYY, GateRZZ, GateRZX, GateXXminusYY.
Matrix representation
\[\operatorname{(XX+YY)}(\theta, \beta) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & \cos(\frac{\theta}{2}) & -i\sin(\frac{\theta}{2})e^{i\beta} & 0 \\ 0 & -i\sin(\frac{\theta}{2})e^{-i\beta} & \cos(\frac{\theta}{2}) & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}\]
Examples
julia> @variables θ β
2-element Vector{Symbolics.Num}:
θ
β
julia> GateXXplusYY(θ, β)
XXplusYY(θ, β)
julia> matrix(GateXXplusYY(θ, β))
4×4 Matrix{Complex{Symbolics.Num}}:
1 0 … 0
0 cos((1//2)*θ) 0
0 sin(-β)*sin((1//2)*θ) - im*cos(-β)*sin((1//2)*θ) 0
0 0 1
julia> c = push!(Circuit(), GateXXplusYY(θ, β), 1, 2)
2-qubit circuit with 1 instructions:
└── XXplusYY(θ, β) @ q[1:2]
julia> push!(c, GateXXplusYY(π/2, 0), 1, 2)
2-qubit circuit with 2 instructions:
├── XXplusYY(θ, β) @ q[1:2]
└── XXplusYY(π/2, 0) @ q[1:2]
Decomposition
julia> decompose(GateXXplusYY(θ, β))
2-qubit circuit with 14 instructions:
├── RZ(β) @ q[1]
├── RZ(-1π/2) @ q[2]
├── SX @ q[2]
├── RZ(π/2) @ q[2]
├── S @ q[1]
├── CX @ q[2], q[1]
├── RY((-1//2)*θ) @ q[2]
├── RY((-1//2)*θ) @ q[1]
├── CX @ q[2], q[1]
├── S† @ q[1]
├── RZ(-1π/2) @ q[2]
├── SX† @ q[2]
├── RZ(π/2) @ q[2]
└── RZ(-β) @ q[1]
MimiqCircuitsBase.GateCSWAP — TypeGateCSWAP()Three-qubit, controlled-$\operatorname{SWAP}$ gate.
Details
Implemented as an alias to Control{1,2,3,GateSWAP}.
By convention, the first qubit is the control and the last two are targets.
Examples
julia> GateCSWAP(), numcontrols(GateCSWAP()), numtargets(GateCSWAP())
(CSWAP, 1, 2)
julia> matrix(GateCSWAP())
8×8 Matrix{Float64}:
1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0
0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0
julia> c = push!(Circuit(), GateCSWAP(), 1, 2, 3)
3-qubit circuit with 1 instructions:
└── CSWAP @ q[1], q[2:3]
julia> power(GateCSWAP(), 2), inverse(GateCSWAP())
(C(Parallel(2, ID)), CSWAP)
Decomposition
julia> decompose(GateCSWAP())
3-qubit circuit with 3 instructions:
├── CX @ q[3], q[2]
├── C₂X @ q[1:2], q[3]
└── CX @ q[3], q[2]
MimiqCircuitsBase.GateC3X — TypeGateC3X()Four qubit, triply-controlled $X$ gate.
Details
Implemented as an alias to $Control(3, GateX())$.
By convention, the first three qubits are the controls and the fourth is the target.
Examples
julia> GateC3X(), numcontrols(GateC3X()), numtargets(GateC3X())
(C₃X, 3, 1)
julia> matrix(GateC3X())
16×16 Matrix{Float64}:
1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 … 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 … 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 … 0.0 1.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 … 0.0 0.0 0.0 0.0 0.0 1.0 0.0
julia> c = push!(Circuit(), GateC3X(), 1, 2, 3, 4)
4-qubit circuit with 1 instructions:
└── C₃X @ q[1:3], q[4]
julia> power(GateC3X(), 2), inverse(GateC3X())
(C₃ID, C₃X)
Decomposition
julia> decompose(GateC3X())
4-qubit circuit with 31 instructions:
├── H @ q[4]
├── P(π/8) @ q[1]
├── P(π/8) @ q[2]
├── P(π/8) @ q[3]
├── P(π/8) @ q[4]
├── CX @ q[1], q[2]
├── P(-1π/8) @ q[2]
├── CX @ q[1], q[2]
├── CX @ q[2], q[3]
⋮ ⋮
├── CX @ q[1], q[4]
├── P(π/8) @ q[4]
├── CX @ q[3], q[4]
├── P(-1π/8) @ q[4]
├── CX @ q[2], q[4]
├── P(π/8) @ q[4]
├── CX @ q[3], q[4]
├── P(-1π/8) @ q[4]
├── CX @ q[1], q[4]
└── H @ q[4]
MimiqCircuitsBase.GateCCX — TypeGateCCX()Three-qubit, doubly-controlled $X$ gate.
Details
Implemented as an alias to $Control(2, GateX())$.
By convention, the first two qubits are the controls and the third is the target.
Examples
julia> GateCCX(), numcontrols(GateCCX()), numtargets(GateCCX())
(C₂X, 2, 1)
julia> matrix(GateCCX())
8×8 Matrix{Float64}:
1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0
0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0
julia> c = push!(Circuit(), GateCCX(), 1, 2, 3)
3-qubit circuit with 1 instructions:
└── C₂X @ q[1:2], q[3]
julia> power(GateCCX(), 2), inverse(GateCCX())
(C₂ID, C₂X)
Decomposition
julia> decompose(GateCCX())
3-qubit circuit with 15 instructions:
├── H @ q[3]
├── CX @ q[2], q[3]
├── T† @ q[3]
├── CX @ q[1], q[3]
├── T @ q[3]
├── CX @ q[2], q[3]
├── T† @ q[3]
├── CX @ q[1], q[3]
├── T @ q[2]
├── T @ q[3]
├── H @ q[3]
├── CX @ q[1], q[2]
├── T @ q[1]
├── T† @ q[2]
└── CX @ q[1], q[2]
MimiqCircuitsBase.GateCCP — TypeGateCCP(λ)Three-qubit, doubly-controlled phase gate.
Details
Implemented as an alias to $Control(2, GateP(λ))$.
By convention, the first two qubits are the controls and the third is the target.
Examples
julia> @variables λ
1-element Vector{Symbolics.Num}:
λ
julia> GateCCP(λ), numcontrols(GateCCP(λ)), numtargets(GateCCP(λ))
(C₂P(λ), 2, 1)
julia> matrix(GateCCP(1.989))
8×8 Matrix{ComplexF64}:
1.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im … 0.0+0.0im 0.0+0.0im
0.0+0.0im 1.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 0.0+0.0im 1.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 0.0+0.0im 0.0+0.0im 1.0+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im
0.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im … 0.0+0.0im 0.0+0.0im
0.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im 1.0+0.0im 0.0+0.0im
0.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im 0.0+0.0im -0.40612+0.91382im
julia> c = push!(Circuit(), GateCCP(λ), 1, 2, 3)
3-qubit circuit with 1 instructions:
└── C₂P(λ) @ q[1:2], q[3]
julia> push!(c, GateCCP(π/8), 1, 2, 3)
3-qubit circuit with 2 instructions:
├── C₂P(λ) @ q[1:2], q[3]
└── C₂P(π/8) @ q[1:2], q[3]
julia> power(GateCCP(λ), 2), inverse(GateCCP(λ))
(C₂P(2λ), C₂P(-λ))
Decomposition
julia> @variables λ
1-element Vector{Symbolics.Num}:
λ
julia> decompose(GateCCP(λ))
3-qubit circuit with 5 instructions:
├── CP((1//2)*λ) @ q[2], q[3]
├── CX @ q[1], q[2]
├── CP((-1//2)*λ) @ q[2], q[3]
├── CX @ q[1], q[2]
└── CP((1//2)*λ) @ q[1], q[3]