Standard Gates

MimiqCircuitsBase.GateUType
GateU(θ, ϕ, λ[, γ = 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(θ, ϕ, λ))
(GateU(θ, ϕ, λ, 0π)^2, GateU(-θ, -λ, -ϕ, 0π))

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]
source
MimiqCircuitsBase.GatePType
GateP(λ)

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]
source
MimiqCircuitsBase.GateU1Type
GateU1(λ)

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(λ))
(GateU1(λ)^2, GateU1(-λ))

Decomposition

julia> decompose(GateU1(λ))
1-qubit circuit with 1 instructions:
└── U(0,0,λ) @ q[1]
source
MimiqCircuitsBase.GateU2Type
GateU2(ϕ, λ)

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(ϕ, λ))
(GateU2(ϕ, λ)^2, GateU2(-3.141592653589793 - λ, π - ϕ))

Decomposition

julia> decompose(GateU2(ϕ, λ))
1-qubit circuit with 1 instructions:
└── U3(π/2,ϕ,λ) @ q[1]
source
MimiqCircuitsBase.GateU3Type
GateU3(θ, ϕ, λ)

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(θ, ϕ, λ))
(GateU3(θ, ϕ, λ)^2, GateU3(-θ, -λ, -ϕ))

Decomposition

julia> decompose(GateU3(θ, ϕ, λ))
1-qubit circuit with 1 instructions:
└── U(θ,ϕ,λ) @ q[1]
source
MimiqCircuitsBase.GateXType
GateX()

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]
source
MimiqCircuitsBase.GateYType
GateY()

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]
source
MimiqCircuitsBase.GateZType
GateZ()

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]
source
MimiqCircuitsBase.GateHType
GateH()

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())
(GateH()^2, GateH())

Decomposition

julia> decompose(GateH())
1-qubit circuit with 1 instructions:
└── U(π/2,0,π) @ q[1]
source
MimiqCircuitsBase.GateHXYType
GateHXY()

Single qubit HXY gate.

Matrix representation

\[\operatorname{HXY} = \frac{1}{\sqrt{2}} \begin{pmatrix} 0 & 1 - i \\ 1 + i & 0 \end{pmatrix}\]

Examples

julia> GateHXY()
HXY

julia> matrix(GateHXY())
2×2 Matrix{ComplexF64}:
      0.0+0.0im       0.707107-0.707107im
 0.707107+0.707107im       0.0+0.0im

julia> c = push!(Circuit(), GateHXY(), 1)
1-qubit circuit with 1 instructions:
└── HXY @ q[1]

julia> power(GateHXY(), 2), inverse(GateHXY())
(GateHXY()^2, GateHXY())

Decomposition

julia> decompose(GateHXY())
1-qubit circuit with 5 instructions:
├── H @ q[1]
├── Z @ q[1]
├── H @ q[1]
├── S @ q[1]
└── U(0,0,0,-1π/4) @ q[1]
source
MimiqCircuitsBase.GateHXZType
GateHXZ()

The HXZ gate is an alias for the Hadamard gate. It applies a transformation that puts the qubit in an equal superposition of |0⟩ and |1⟩.

Matrix representation

\[\operatorname{HXZ} = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}\]

Examples

julia> GateHXZ()
H

julia> matrix(GateHXZ())
2×2 Matrix{Float64}:
 0.707107   0.707107
 0.707107  -0.707107

julia> c = push!(Circuit(), GateHXZ(), 1)
1-qubit circuit with 1 instructions:
└── H @ q[1]

julia> power(GateHXZ(), 2), inverse(GateHXZ())
(GateH()^2, GateH())

Decomposition

julia> decompose(GateHXZ())
1-qubit circuit with 1 instructions:
└── U(π/2,0,π) @ q[1]
source
MimiqCircuitsBase.GateHYZType
GateHYZ()

Single qubit HYZ gate.

Matrix representation

\[\operatorname{HYZ} = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & -i \\ i & -1 \end{pmatrix}\]

Examples

julia> GateHYZ()
HYZ

julia> matrix(GateHYZ())
2×2 Matrix{ComplexF64}:
 0.707107+0.0im             0.0-0.707107im
      0.0+0.707107im  -0.707107+0.0im

julia> c = push!(Circuit(), GateHYZ(), 1)
1-qubit circuit with 1 instructions:
└── HYZ @ q[1]

julia> power(GateHYZ(), 2), inverse(GateHYZ())
(GateHYZ()^2, GateHYZ())

Decomposition

julia> decompose(GateHYZ())
1-qubit circuit with 5 instructions:
├── H @ q[1]
├── S @ q[1]
├── H @ q[1]
├── Z @ q[1]
└── U(0,0,0,-1π/4) @ q[1]
source
MimiqCircuitsBase.GateIDType
GateID()

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())
(GateID(), GateID())

Decomposition

julia> decompose(GateID())
1-qubit circuit with 1 instructions:
└── U(0,0,0) @ q[1]
source
MimiqCircuitsBase.GateSType
GateS()

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{Complex{Int64}}:
 1+0im  0+0im
 0+0im  0+1im

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())
(GateZ(), Inverse(GateS()))

Decomposition

julia> decompose(GateS())
1-qubit circuit with 1 instructions:
└── U(0,0,π/2) @ q[1]
source
MimiqCircuitsBase.GateSDGType
GateSDG()

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 Matrix{Complex{Int64}}:
 1+0im  0+0im
 0+0im  0-1im

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())
((Inverse(GateS()))^2, GateS())

Decomposition

julia> decompose(GateSDG())
1-qubit circuit with 1 instructions:
└── U(0,0,-1π/2) @ q[1]
source
MimiqCircuitsBase.GateTType
GateT()

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())
(GateS(), GateZ(), Inverse(GateT()))

Decomposition

julia> decompose(GateT())
1-qubit circuit with 1 instructions:
└── U(0,0,π/4) @ q[1]
source
MimiqCircuitsBase.GateTDGType
GateTDG()

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 Matrix{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())
((Inverse(GateT()))^2, (Inverse(GateT()))^4, GateT())

Decomposition

julia> decompose(GateTDG())
1-qubit circuit with 1 instructions:
└── U(0,0,-1π/4) @ q[1]
source
MimiqCircuitsBase.GateSXType
GateSX()

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())
(GateX(), Inverse(GateSX()))

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]
source
MimiqCircuitsBase.GateSXDGType
GateSXDG()

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 Matrix{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())
((Inverse(GateSX()))^2, GateSX())
source
MimiqCircuitsBase.GateRType
GateR(θ, ϕ)

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]
source
MimiqCircuitsBase.GateRXType
GateRX(θ)

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]
source
MimiqCircuitsBase.GateRYType
GateRY(θ)

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]
source
MimiqCircuitsBase.GateRZType
GateRZ(λ)

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]
source
MimiqCircuitsBase.GateSWAPType
GateSWAP()

Two qubit SWAP gate.

See also GateISWAP, GateCSWAP

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, GateID()), GateSWAP())

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]
source
MimiqCircuitsBase.GateISWAPType
GateISWAP()

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())
(GateISWAP()^2, Inverse(GateISWAP()))

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]
source
MimiqCircuitsBase.GateCXType
GateCX()

Two qubit Controlled-$X$ gate (or CNOT).

Details

Implemented as an alias to Control(1, GateX()).

Note

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())
(GateCX(), 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())
(Control(GateID()), GateCX())

Decomposition

julia> decompose(GateCX())
2-qubit circuit with 1 instructions:
└── CX @ q[1], q[2]
source
MimiqCircuitsBase.GateCYType
GateCY()

Two qubit Controlled-$Y$ gate.

Details

Implemented as an alias to Control(1, GateY()).

Note

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())
(GateCY(), 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())
(Control(GateID()), GateCY())

Decomposition

julia> decompose(GateCY())
2-qubit circuit with 3 instructions:
├── S† @ q[2]
├── CX @ q[1], q[2]
└── S @ q[2]
source
MimiqCircuitsBase.GateCZType
GateCZ()

Two qubit Controlled-$Z$ gate.

Details

Implemented as an alias to Control(1, GateZ()).

Note

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())
(GateCZ(), 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())
(Control(GateID()), GateCZ())

Decomposition

julia> decompose(GateCZ())
2-qubit circuit with 3 instructions:
├── H @ q[2]
├── CX @ q[1], q[2]
└── H @ q[2]
source
MimiqCircuitsBase.GateCHType
GateCH()

Two qubit controlled-Hadamard gate.

Details

Implemented as an alias to Control(1, GateH()).

Note

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)
(GateCH(), 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())
(Control(GateH()^2), GateCH())

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]
source
MimiqCircuitsBase.GateCSType
GateCS()

Two qubit Controlled-S gate.

Details

Implemented as an alias to Control(1, GateS()).

See also GateS, Control.

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())
(GateCS(), 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())
(GateCZ(), Control(Inverse(GateS())))

Decomposition

julia> decompose(GateCS())
2-qubit circuit with 1 instructions:
└── CP(π/2) @ q[1], q[2]
source
MimiqCircuitsBase.GateCSDGType
GateCSDG()

Adjoint of two qubit Controlled-S gate.
Details

Implemented as an alias to inverse(Control(1, GateS())).

See also GateS, Control.

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())
(Control(Inverse(GateS())), 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())
(Control((Inverse(GateS()))^2), GateCS())

Decomposition

julia> decompose(GateCSDG())
2-qubit circuit with 1 instructions:
└── CP(-1π/2) @ q[1], q[2]
source
MimiqCircuitsBase.GateCSXType
GateCSX()

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())
(GateCSX(), 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())
(GateCX(), Control(Inverse(GateSX())))

Decomposition

julia> decompose(GateCSX())
2-qubit circuit with 3 instructions:
├── H @ q[2]
├── CU1(π/2) @ q[1], q[2]
└── H @ q[2]
source
MimiqCircuitsBase.GateCSXDGType
GateCSXDG()

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())
(Control(Inverse(GateSX())), 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())
(Control((Inverse(GateSX()))^2), GateCSX())

Decomposition

julia> decompose(GateCSXDG())
2-qubit circuit with 3 instructions:
├── H @ q[2]
├── CU1(-1π/2) @ q[1], q[2]
└── H @ q[2]
source
MimiqCircuitsBase.GateCUType
GateCU(θ, ϕ, λ)

Controlled-$\operatorname{U}(\theta, \phi, \lambda)$ gate.

Details

Implemented as an alias to Control(1, GateU(θ, ϕ, λ, γ)).

See also Control, 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(θ, ϕ, λ, γ))
(GateCU(θ, ϕ, λ, γ), 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(θ, ϕ, λ, γ))
(Control(GateU(θ, ϕ, λ, γ)^2), GateCU(-θ, -λ, -ϕ, -γ))

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]
source
MimiqCircuitsBase.GateCPType
GateCP(θ)

Controlled-$\operatorname{P}(\lambda)$ gate.

Details

Implemented as an alias to Control(GateP(θ)).

See also Control, GateRZ.

Examples

julia> @variables λ
1-element Vector{Symbolics.Num}:
 λ

julia> GateCP(λ), numcontrols(GateCP(λ)), numtargets(GateCP(λ))
(GateCP(λ), 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(λ))
(GateCP(2λ), GateCP(-λ))

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]
source
MimiqCircuitsBase.GateCRXType
GateCRX(θ)

Controlled-$\operatorname{R}_X(\theta)$ gate.

Details

Implemented as an alias to Control(GateRX(θ)).

See also 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(θ))
(GateCRX(θ), 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(θ))
(GateCRX(2θ), GateCRX(-θ))

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]
source
MimiqCircuitsBase.GateCRYType
GateCRY(θ)

Controlled-$\operatorname{R}_Y(\theta)$ gate.

Details

Implemented as an alias to Control(GateRY(θ)).

See also 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(θ))
(Control(GateRY(θ)), 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(θ))
(Control(GateRY(2θ)), Control(GateRY(-θ)))

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]
source
MimiqCircuitsBase.GateCRZType
GateCRZ(θ)

Controlled-$\operatorname{R}_Z(\theta)$ gate.

Details

Implemented as an alias to Control(GateRZ(θ)).

See also 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(θ))
(Control(GateRZ(θ)), 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(θ))
(Control(GateRZ(2θ)), Control(GateRZ(-θ)))

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]
source
MimiqCircuitsBase.GateECRType
GateECR()

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, GateID()), GateECR())

Decomposition

julia> decompose(GateECR())
2-qubit circuit with 3 instructions:
├── RZX(π/4) @ q[1:2]
├── X @ q[1]
└── RZX(-1π/4) @ q[1:2]
source
MimiqCircuitsBase.GateDCXType
GateDCX()

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())
(Inverse(GateDCX()), Inverse(GateDCX()))

Decomposition

julia> decompose(GateDCX())
2-qubit circuit with 2 instructions:
├── CX @ q[1], q[2]
└── CX @ q[2], q[1]
source
MimiqCircuitsBase.GateRXXType
GateRXX(θ)

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\left(\frac{\theta}{2}\right) & 0 & 0 & -i\sin\left(\frac{\theta}{2}\right) \\ 0 & \cos\left(\frac{\theta}{2}\right) & -i\sin\left(\frac{\theta}{2}\right) & 0 \\ 0 & -i\sin\left(\frac{\theta}{2}\right) & \cos\left(\frac{\theta}{2}\right) & 0 \\ -i\sin\left(\frac{\theta}{2}\right) & 0 & 0 & \cos\left(\frac{\theta}{2}\right) \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]
source
MimiqCircuitsBase.GateRYYType
GateRYY(θ)

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\left(\frac{\theta}{2}\right) & 0 & 0 & i\sin\left(\frac{\theta}{2}\right) \\ 0 & \cos\left(\frac{\theta}{2}\right) & -i\sin\left(\frac{\theta}{2}\right) & 0 \\ 0 & -i\sin\left(\frac{\theta}{2}\right) & \cos\left(\frac{\theta}{2}\right) & 0 \\ i\sin\left(\frac{\theta}{2}\right) & 0 & 0 & \cos\left(\frac{\theta}{2}\right) \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]
source
MimiqCircuitsBase.GateRZXType
GateRZX(θ)

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]
source
MimiqCircuitsBase.GateRZZType
GateRZZ(θ)

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]
source
MimiqCircuitsBase.GateXXminusYYType
GateXXminusYY(θ, β)

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]
source
MimiqCircuitsBase.GateXXplusYYType
GateXXplusYY(θ, β)

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]
source
MimiqCircuitsBase.GateCSWAPType
GateCSWAP()

Three-qubit, controlled-$\operatorname{SWAP}$ gate.

Details

Implemented as an alias to Control{1,2,3,GateSWAP}.

See also Control, GateU.

Note

By convention, the first qubit is the control and the last two are targets.

Examples

julia> GateCSWAP(), numcontrols(GateCSWAP()), numtargets(GateCSWAP())
(GateCSWAP(), 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())
(Control(Parallel(2, GateID())), GateCSWAP())

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]
source
MimiqCircuitsBase.GateC3XType
GateC3X()

Four qubit, triply-controlled $X$ gate.

Details

Implemented as an alias to $Control(3, GateX())$.

Note

By convention, the first three qubits are the controls and the fourth is the target.

Examples

julia> GateC3X(), numcontrols(GateC3X()), numtargets(GateC3X())
(Control(3, GateX()), 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())
(Control(3, GateID()), Control(3, GateX()))

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]
source
MimiqCircuitsBase.GateCCXType
GateCCX()

Three-qubit, doubly-controlled $X$ gate.

Details

Implemented as an alias to $Control(2, GateX())$.

Note

By convention, the first two qubits are the controls and the third is the target.

Examples

julia> GateCCX(), numcontrols(GateCCX()), numtargets(GateCCX())
(Control(2, GateX()), 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())
(Control(2, GateID()), Control(2, GateX()))

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]
source
MimiqCircuitsBase.GateCCPType
GateCCP(λ)

Three-qubit, doubly-controlled phase gate.

Details

Implemented as an alias to $Control(2, GateP(λ))$.

Note

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(λ))
(GateCCP(λ), 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:
└── CCP(λ) @ q[1:2], q[3]

julia> push!(c, GateCCP(π/8), 1, 2, 3)
3-qubit circuit with 2 instructions:
├── CCP(λ) @ q[1:2], q[3]
└── CCP(π/8) @ q[1:2], q[3]

julia> power(GateCCP(λ), 2), inverse(GateCCP(λ))
(GateCCP(2λ), GateCCP(-λ))

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]
source