Multi-Qubit Gates

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 instruction:
└── 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 instruction:
└── 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:
├── U(0,0,π/2) @ q[1]
├── U(0,0,π/2) @ q[2]
├── U(π/2,0,π) @ q[1]
├── CX @ q[1], q[2]
├── CX @ q[2], q[1]
└── U(π/2,0,π) @ 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 instruction:
└── CX @ q[1], q[2]

julia> power(GateCX(), 2), inverse(GateCX())
(Control(GateID()), GateCX())

Decomposition

julia> decompose(GateCX())
2-qubit circuit with 1 instruction:
└── 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 instruction:
└── CY @ q[1], q[2]

julia> power(GateCY(), 2), inverse(GateCY())
(Control(GateID()), GateCY())

Decomposition

julia> decompose(GateCY())
2-qubit circuit with 3 instructions:
├── U(0,0,-1π/2) @ q[2]
├── CX @ q[1], q[2]
└── U(0,0,π/2) @ 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 instruction:
└── CZ @ q[1], q[2]

julia> power(GateCZ(), 2), inverse(GateCZ())
(Control(GateID()), GateCZ())

Decomposition

julia> decompose(GateCZ())
2-qubit circuit with 3 instructions:
├── U(π/2,0,π) @ q[2]
├── CX @ q[1], q[2]
└── U(π/2,0,π) @ 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 instruction:
└── 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:
├── U(0,0,π/2) @ q[2]
├── U(π/2,0,π) @ q[2]
├── U(0,0,π/4) @ q[2]
├── CX @ q[1], q[2]
├── U(0,0,-1π/4) @ q[2]
├── U(π/2,0,π) @ q[2]
└── U(0,0,-1π/2) @ 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 instruction:
└── CS @ q[1], q[2]

julia> power(GateCS(), 2), inverse(GateCS())
(GateCZ(), Control(Inverse(GateS())))

Decomposition

julia> decompose(GateCS())
2-qubit circuit with 5 instructions:
├── U(0,0,π/4) @ q[1]
├── CX @ q[1], q[2]
├── U(0,0,-1π/4) @ q[2]
├── CX @ q[1], q[2]
└── U(0,0,π/4) @ 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 instruction:
└── 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 5 instructions:
├── U(0,0,-1π/4) @ q[1]
├── CX @ q[1], q[2]
├── U(0,0,π/4) @ q[2]
├── CX @ q[1], q[2]
└── U(0,0,-1π/4) @ 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 instruction:
└── CSX @ q[1], q[2]

julia> power(GateCSX(), 2), inverse(GateCSX())
(GateCX(), Control(Inverse(GateSX())))

Decomposition

julia> decompose(GateCSX())
2-qubit circuit with 7 instructions:
├── U(π/2,0,π) @ q[2]
├── U(0,0,π/4) @ q[1]
├── CX @ q[1], q[2]
├── U(0,0,-1π/4) @ q[2]
├── CX @ q[1], q[2]
├── U(0,0,π/4) @ q[2]
└── U(π/2,0,π) @ 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 instruction:
└── 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 7 instructions:
├── U(π/2,0,π) @ q[2]
├── U(0,0,-1π/4) @ q[1]
├── CX @ q[1], q[2]
├── U(0,0,π/4) @ q[2]
├── CX @ q[1], q[2]
├── U(0,0,-1π/4) @ q[2]
└── U(π/2,0,π) @ 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 instruction:
└── 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:
├── U(0,0,γ) @ q[1]
├── U(0,0,(λ + ϕ) / 2) @ q[1]
├── U(0,0,(-λ + ϕ) / 2) @ q[2]
├── CX @ q[1], q[2]
├── U((-1//2)*θ,0,(-λ - ϕ) / 2) @ q[2]
├── CX @ q[1], q[2]
└── U(θ / 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 instruction:
└── 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:
├── U(0,0,θ / 2) @ q[1]
├── CX @ q[1], q[2]
├── U(0,0,(-1//2)*θ) @ q[2]
├── CX @ q[1], q[2]
└── U(0,0,θ / 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 instruction:
└── 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:
├── U(0,0,π/2) @ q[2]
├── CX @ q[1], q[2]
├── U((-1//2)*θ,0,0) @ q[2]
├── CX @ q[1], q[2]
└── U(θ / 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 instruction:
└── 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:
├── U(θ / 2,0,0) @ q[2]
├── CX @ q[1], q[2]
├── U((-1//2)*θ,0,0) @ 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 instruction:
└── 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:
├── U(0,0,θ / 2,(-1//4)*θ) @ q[2]
├── CX @ q[1], q[2]
├── U(0,0,(-1//2)*θ,(1//4)*θ) @ 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 instruction:
└── ECR @ q[1:2]

julia> power(GateECR(), 2), inverse(GateECR())
(Parallel(2, GateID()), GateECR())

Decomposition

julia> decompose(GateECR())
2-qubit circuit with 11 instructions:
├── U(π/2,0,π) @ q[2]
├── CX @ q[1], q[2]
├── U(0,0,π/4,-1π/8) @ q[2]
├── CX @ q[1], q[2]
├── U(π/2,0,π) @ q[2]
├── U(π,0,π) @ q[1]
├── U(π/2,0,π) @ q[2]
├── CX @ q[1], q[2]
├── U(0,0,-1π/4,π/8) @ q[2]
├── CX @ q[1], q[2]
└── U(π/2,0,π) @ q[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 instruction:
└── 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(θ / 2)               0               0  -im*sin(θ / 2)
              0      cos(θ / 2)  -im*sin(θ / 2)               0
              0  -im*sin(θ / 2)      cos(θ / 2)               0
 -im*sin(θ / 2)               0               0      cos(θ / 2)

julia> c = push!(Circuit(), GateRXX(θ), 1, 2)
2-qubit circuit with 1 instruction:
└── 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:
├── U(π/2,0,π) @ q[1]
├── U(π/2,0,π) @ q[2]
├── CX @ q[1], q[2]
├── U(0,0,θ,(-1//2)*θ) @ q[2]
├── CX @ q[1], q[2]
├── U(π/2,0,π) @ q[2]
└── U(π/2,0,π) @ 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(θ / 2)               0               0  im*sin(θ / 2)
             0      cos(θ / 2)  -im*sin(θ / 2)              0
             0  -im*sin(θ / 2)      cos(θ / 2)              0
 im*sin(θ / 2)               0               0     cos(θ / 2)

julia> c = push!(Circuit(), GateRYY(θ), 1, 2)
2-qubit circuit with 1 instruction:
└── 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:
├── U(π/2,-1π/2,π/2) @ q[1]
├── U(π/2,-1π/2,π/2) @ q[2]
├── CX @ q[1], q[2]
├── U(0,0,θ,(-1//2)*θ) @ q[2]
├── CX @ q[1], q[2]
├── U(-1π/2,-1π/2,π/2) @ q[1]
└── U(-1π/2,-1π/2,π/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(θ / 2)  -im*sin(θ / 2)              0              0
 -im*sin(θ / 2)      cos(θ / 2)              0              0
              0               0     cos(θ / 2)  im*sin(θ / 2)
              0               0  im*sin(θ / 2)     cos(θ / 2)

julia> c = push!(Circuit(), GateRZX(θ), 1, 2)
2-qubit circuit with 1 instruction:
└── 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:
├── U(π/2,0,π) @ q[2]
├── CX @ q[1], q[2]
├── U(0,0,θ,(-1//2)*θ) @ q[2]
├── CX @ q[1], q[2]
└── U(π/2,0,π) @ 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 instruction:
└── 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]
├── U(0,0,θ,(-1//2)*θ) @ 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(θ / 2)                       …  sin(-β)*sin(θ / 2) - im*cos(-β)*sin(θ / 2)
                   0                                                      0
                   0                                                      0
 sin(β)*sin(θ / 2) - im*cos(β)*sin(θ / 2)                        cos(θ / 2)

julia> c = push!(Circuit(), GateXXminusYY(θ, β), 1, 2)
2-qubit circuit with 1 instruction:
└── 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 20 instructions:
├── U(0,0,-β,β / 2) @ q[2]
├── U(0,0,-1π/2,π/4) @ q[1]
├── U(0,0,-1π/2) @ q[1]
├── U(π/2,0,π) @ q[1]
├── U(0,0,-1π/2) @ q[1]
├── U(0,0,0,π/4) @ q[1]
├── U(0,0,π/2,-1π/4) @ q[1]
├── U(0,0,π/2) @ q[2]
├── CX @ q[1], q[2]
├── U(θ / 2,0,0) @ q[1]
├── U((-1//2)*θ,0,0) @ q[2]
├── CX @ q[1], q[2]
├── U(0,0,-1π/2) @ q[2]
├── U(0,0,-1π/2,π/4) @ q[1]
├── U(0,0,π/2) @ q[1]
├── U(π/2,0,π) @ q[1]
├── U(0,0,π/2) @ q[1]
├── U(0,0,0,-1π/4) @ q[1]
├── U(0,0,π/2,-1π/4) @ q[1]
└── U(0,0,β,(-1//2)*β) @ 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(θ / 2)                  0
 0  sin(-β)*sin(θ / 2) - im*cos(-β)*sin(θ / 2)     0
 0                              0                  1

julia> c = push!(Circuit(), GateXXplusYY(θ, β), 1, 2)
2-qubit circuit with 1 instruction:
└── 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 20 instructions:
├── U(0,0,β,(-1//2)*β) @ q[1]
├── U(0,0,-1π/2,π/4) @ q[2]
├── U(0,0,-1π/2) @ q[2]
├── U(π/2,0,π) @ q[2]
├── U(0,0,-1π/2) @ q[2]
├── U(0,0,0,π/4) @ q[2]
├── U(0,0,π/2,-1π/4) @ q[2]
├── U(0,0,π/2) @ q[1]
├── CX @ q[2], q[1]
├── U((-1//2)*θ,0,0) @ q[2]
├── U((-1//2)*θ,0,0) @ q[1]
├── CX @ q[2], q[1]
├── U(0,0,-1π/2) @ q[1]
├── U(0,0,-1π/2,π/4) @ q[2]
├── U(0,0,π/2) @ q[2]
├── U(π/2,0,π) @ q[2]
├── U(0,0,π/2) @ q[2]
├── U(0,0,0,-1π/4) @ q[2]
├── U(0,0,π/2,-1π/4) @ q[2]
└── U(0,0,-β,β / 2) @ 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 instruction:
└── 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 17 instructions:
├── CX @ q[3], q[2]
├── U(π/2,0,π) @ q[3]
├── CX @ q[2], q[3]
├── U(0,0,-1π/4) @ q[3]
├── CX @ q[1], q[3]
├── U(0,0,π/4) @ q[3]
├── CX @ q[2], q[3]
├── U(0,0,-1π/4) @ q[3]
├── CX @ q[1], q[3]
├── U(0,0,π/4) @ q[2]
├── U(0,0,π/4) @ q[3]
├── U(π/2,0,π) @ q[3]
├── CX @ q[1], q[2]
├── U(0,0,π/4) @ q[1]
├── U(0,0,-1π/4) @ q[2]
├── CX @ q[1], q[2]
└── 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 instruction:
└── 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:
├── U(π/2,0,π) @ q[4]
├── U(0,0,π/8) @ q[1]
├── U(0,0,π/8) @ q[2]
├── U(0,0,π/8) @ q[3]
├── U(0,0,π/8) @ q[4]
├── CX @ q[1], q[2]
├── U(0,0,-1π/8) @ q[2]
├── CX @ q[1], q[2]
├── CX @ q[2], q[3]
⋮   ⋮
├── CX @ q[1], q[4]
├── U(0,0,π/8) @ q[4]
├── CX @ q[3], q[4]
├── U(0,0,-1π/8) @ q[4]
├── CX @ q[2], q[4]
├── U(0,0,π/8) @ q[4]
├── CX @ q[3], q[4]
├── U(0,0,-1π/8) @ q[4]
├── CX @ q[1], q[4]
└── U(π/2,0,π) @ 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 instruction:
└── 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:
├── U(π/2,0,π) @ q[3]
├── CX @ q[2], q[3]
├── U(0,0,-1π/4) @ q[3]
├── CX @ q[1], q[3]
├── U(0,0,π/4) @ q[3]
├── CX @ q[2], q[3]
├── U(0,0,-1π/4) @ q[3]
├── CX @ q[1], q[3]
├── U(0,0,π/4) @ q[2]
├── U(0,0,π/4) @ q[3]
├── U(π/2,0,π) @ q[3]
├── CX @ q[1], q[2]
├── U(0,0,π/4) @ q[1]
├── U(0,0,-1π/4) @ 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 instruction:
└── 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 17 instructions:
├── U(0,0,λ / 4) @ q[1]
├── CX @ q[1], q[3]
├── U(0,0,(-1//4)*λ) @ q[3]
├── CX @ q[1], q[3]
├── U(0,0,λ / 4) @ q[3]
├── CX @ q[1], q[2]
├── U(0,0,(-1//4)*λ) @ q[2]
├── CX @ q[2], q[3]
├── U(0,0,(1//4)*λ) @ q[3]
├── CX @ q[2], q[3]
├── U(0,0,(-1//4)*λ) @ q[3]
├── CX @ q[1], q[2]
├── U(0,0,λ / 4) @ q[2]
├── CX @ q[2], q[3]
├── U(0,0,(-1//4)*λ) @ q[3]
├── CX @ q[2], q[3]
└── U(0,0,λ / 4) @ q[3]
source