Quantum Circuits Library

Contents

Quantum Circuits

MimiqCircuitsBase.Circuit — Type
struct Circuit

Representation of a quantum circuit as a vector of gates applied to the qubits.

Parameters

  • gates::Vector{Instruction} vector of quantum instructions (see Instruction)

Example iteration

circuit = Circuit()
# add gates to circuit

for (; operation, targets) in circuit
    # do something with the gate and its targets
    # e.g.
end

(here the iteration parameters should be called operation and targets to proper destructure a Instruction)

Gate types

MimiqCircuitsBase.Instruction — Type
struct Instruction{N,M,T<:Operation}

Element of a quantum circuit, representing a N-qubit gate applied to N targets

Parameters

  • gate::T actual gate represented
  • qtargets::NTuple{N, Int64} indices specifying the quantum bits on which the instruction is applied
  • ctargets::NTuple{N, Int64} indices specifying the classical bits on which the instruction is applied
MimiqCircuitsBase.depth — Function
depth(circuit)

Compute the depth of a quantum circuit.

The depth of a quantum circuit is a metric computing the maximum time (in units of quantum gates application) between the input and output of the circuit.

Bit States

MimiqCircuitsBase.BitState — Type
struct BitState

Representation of the quantum state of a quantum register with definite values for each qubit.

Examples

julia> BitState(16)
16-qubit BitState with 0 non-zero qubits:
└── |0000000000000000⟩

julia> bs = BitState(16, [1,2,3,4])
16-qubit BitState with 4 non-zero qubits:
├── |1111000000000000⟩
└── non-zero qubits: [1, 2, 3, 4]

julia> bs[10] = 1
1

julia> bs
16-qubit BitState with 5 non-zero qubits:
├── |1111000001000000⟩
└── non-zero qubits: [1, 2, 3, 4, 10]

julia> c = Circuit()
empty circuit

julia> push!(c, GateX(), 8)
8-qubit circuit with 1 gates:
└── X @ q8

julia> BitState(c, [1,3,5,8])
8-qubit BitState with 4 non-zero qubits:
├── |10101001⟩
└── non-zero qubits: [1, 3, 5, 8]

julia> bitstate_to_integer(bs)
527

julia> typeof(ans)
BigInt

julia> bitstate_to_integer(bs, Int64)
527

julia> typeof(ans)
Int64

There are many different ways to get bit states:

julia> bs = BitState(30, 2344574)
30-qubit BitState with 13 non-zero qubits:
├── |011111100110001111000100000000⟩
└── non-zero qubits: [2, 3, 4, 5, 6, 7, 10, 11, 15, 16, 17, 18, 22]

julia> ones(BitState, 10) # or also trues(BitState, 10)
10-qubit BitState with 10 non-zero qubits:
├── |1111111111⟩
└── non-zero qubits: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

julia> zeros(BitState, 10) # or also falses(BitState, 10)
10-qubit BitState with 0 non-zero qubits:
└── |0000000000⟩

julia> BitState(16) do i
           iseven(i)
       end
16-qubit BitState with 8 non-zero qubits:
├── |0101010101010101⟩
└── non-zero qubits: [2, 4, 6, 8, 10, 12, 14, 16]
MimiqCircuitsBase.bitstate_to_index — Function
bitstate_to_index(bitstate)

Convert a bit state into the corresponding index.

This is useful for indexing, for example, a vector of states.

MimiqCircuitsBase.@bs_str — Macro
macro bs_str(s)

Convert a string into a bit state.

Example usage

julia> bs"101011"
6-qubit BitState with 4 non-zero qubits:
├── |101011⟩
└── non-zero qubits: [1, 3, 5, 6]
MimiqCircuitsBase.to01 — Function
to01(bitstate[, endianess=:big])

Converts a BitState into a string of 0 and 1 characters. Optionally endianess can be specified, which can be either :big or :little.

Examples

julia> to01(bs"10011")
"10011"

julia> to01(bs"10011"; endianess=:big)
"10011"

julia> to01(bs"10011"; endianess=:little)
"11001"

Quantum Operations

MimiqCircuitsBase.opname — Function
opname(instruction)
opname(operation)

Returns the name of the given operation in a human readable format.

MimiqCircuitsBase.inverse — Function
inverse(circuit)
inverse(instruction)
inverse(operation)

Return the inverse of the given operation.

Gates

MimiqCircuitsBase.numbits — Function
numbits(instruction)
numbits(circuit)

Number of classical bits on which the given operation or instruction is defined.

MimiqCircuitsBase.numqubits — Function
numqubits(gate)
numqubits(barrier)
numqubits(instruction)
numqubits(circuit)

Number of qubits on which the given operation or instruction is defined.

Parametric gates

MimiqCircuitsBase.numparams — Function
numparams(gate)

Number of parameters for the given parametric gate. Zero for non parametric gates.

Single-Qubit Gates

Pauli gates

MimiqCircuitsBase.GateID — Type
struct GateID <: Gate{1}

Single qubit Identity gate

Matrix Representation

\[\operatorname{I} = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}\]

Examples

julia> matrix(GateID())
2×2 Matrix{Float64}:
 1.0  -0.0
 0.0   1.0

julia> push!(Circuit(), GateID(), 1)
1-qubit circuit with 1 gates:
└── ID @ q1
MimiqCircuitsBase.GateX — Type
struct GateX <: Gate{1}

Single qubit Pauli-X gate.

Matrix Representation

\[\operatorname X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}\]

Examples

julia> matrix(GateX())
2×2 Matrix{Float64}:
 0.0   1.0
 1.0  -0.0

julia> push!(Circuit(), GateX(), 1)
1-qubit circuit with 1 gates:
└── X @ q1
MimiqCircuitsBase.GateY — Type
struct GateY <: Gate{1}

Single qubit Pauli-Y gate.

Matrix Representation

\[\operatorname Y = \begin{pmatrix} 0 & -i \\ i & 0 \end{pmatrix}\]

Examples

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

julia> push!(Circuit(), GateY(), 1)
1-qubit circuit with 1 gates:
└── Y @ q1
MimiqCircuitsBase.GateZ — Type
struct GateZ <: Gate{1}

Single qubit Pauli-Z gate.

Matrix Representation

\[\operatorname Z = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}\]

Examples

julia> matrix(GateZ())
2×2 Matrix{Float64}:
 1.0   0.0
 0.0  -1.0

julia> push!(Circuit(), GateZ(), 1)
1-qubit circuit with 1 gates:
└── Z @ q1
MimiqCircuitsBase.GateH — Type
struct GateH <: Gate{1}

Single qubit Hadamard gate.

Matrix Representation

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

Examples

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

julia> push!(Circuit(), GateH(), 1)
1-qubit circuit with 1 gates:
└── H @ q1
MimiqCircuitsBase.GateS — Type
struct GateS <: Gate{1}

Single qubit S gate (or Phase gate).

See also GateSDG

Matrix Representation

\[\operatorname S = \begin{pmatrix} 1 & 0 \\ 0 & i \end{pmatrix}\]

Examples

julia> matrix(GateS())
2×2 Matrix{ComplexF64}:
 1.0+0.0im  0.0+0.0im
 0.0+0.0im  0.0+1.0im

julia> push!(Circuit(), GateS(), 1)
1-qubit circuit with 1 gates:
└── S @ q1
MimiqCircuitsBase.GateSDG — Type
struct GateSDG <: Gate{1}

Single qubit S-dagger gate (conjugate transpose of the S gate).

See also GateS

Matrix Representation

\[\operatorname S^\dagger = \begin{pmatrix} 1 & 0 \\ 0 & -i \end{pmatrix}\]

Examples

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

julia> push!(Circuit(), GateSDG(), 1)
1-qubit circuit with 1 gates:
└── SDG @ q1
MimiqCircuitsBase.GateT — Type
struct GateT <: Gate{1}

Single qubit T gate.

See also GateTDG

Matrix Representation

\[\operatorname T = \begin{pmatrix} 1 & 0 \\ 0 & \exp(\frac{i\pi}{4}) \end{pmatrix}\]

Examples

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

julia> push!(Circuit(), GateT(), 1)
1-qubit circuit with 1 gates:
└── T @ q1
MimiqCircuitsBase.GateTDG — Type
struct GateTDG <: Gate{1}

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> matrix(GateTDG())
2×2 Matrix{ComplexF64}:
 1.0+0.0im       0.0+0.0im
 0.0+0.0im  0.707107-0.707107im

julia> push!(Circuit(), GateTDG(), 1)
1-qubit circuit with 1 gates:
└── TDG @ q1
MimiqCircuitsBase.GateSX — Type
struct GateSX <: Gate{1}

Single qubit √X gate.

See also GateSXDG, GateX

Matrix Representation

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

Examples

julia> matrix(GateSX())
2×2 Matrix{ComplexF64}:
 0.5+0.5im  0.5-0.5im
 0.5-0.5im  0.5+0.5im

julia> push!(Circuit(), GateSX(), 1)
1-qubit circuit with 1 gates:
└── SX @ q1
MimiqCircuitsBase.GateSXDG — Type
struct GateSXDG <: Gate{1}

Single qubit √X-dagger gate (conjugate transpose of the √X gate)

See also GateSX, GateX

Matrix Representation

\[\sqrt{\operatorname{X}}^\dagger = \frac{1}{2} \begin{pmatrix} 1-i & 1+i \\ 1+i & 1-i \end{pmatrix}\]

Examples

julia> matrix(GateSXDG())
2×2 Matrix{ComplexF64}:
 0.5-0.5im  0.5+0.5im
 0.5+0.5im  0.5-0.5im

julia> push!(Circuit(), GateSXDG(), 1)
1-qubit circuit with 1 gates:
└── SXDG @ q1

Parametric Single-Qubit Gates

MimiqCircuitsBase.GateP — Type
struct GateP <: ParametricGate{1}

Single qubit Phase gate.

Arguments

  • λ::Float64: Phase angle in radians

Matrix Representation

\[\operatorname P(\lambda) = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\lambda} \end{pmatrix}\]

Examples

julia> matrix(GateP(pi/4))
2×2 Matrix{ComplexF64}:
 1.0+0.0im       0.0+0.0im
 0.0+0.0im  0.707107+0.707107im

julia> push!(Circuit(), GateP(pi/4), 1)
1-qubit circuit with 1 gates:
└── P(λ=π⋅0.25) @ q1
MimiqCircuitsBase.GateRX — Type
struct GateRX <: ParametricGate{1}

Single qubit Rotation-X gate (RX gate)

Arguments

  • θ::Float64: Rotation angle in radians

Matrix Representation

\[\operatorname{RX}(\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> matrix(GateRX(pi/2))
2×2 Matrix{ComplexF64}:
 0.707107+0.0im           -0.0-0.707107im
      0.0-0.707107im  0.707107+0.0im

julia> push!(Circuit(), GateRX(pi/2), 1)
1-qubit circuit with 1 gates:
└── RX(θ=π⋅0.5) @ q1
MimiqCircuitsBase.GateRY — Type
struct GateRY <: ParametricGate{1}

Single qubit Rotation-Y gate (RY gate)

Arguments

  • θ::Float64: Rotation angle in radians

Matrix Representation

\[\operatorname{RY}(\theta) = \begin{pmatrix} \cos\frac{\theta}{2} & -\sin\frac{\theta}{2} \\ \sin\frac{\theta}{2} & \cos\frac{\theta}{2} \end{pmatrix}\]

Examples

julia> matrix(GateRY(pi/2))
2×2 Matrix{Float64}:
 0.707107  -0.707107
 0.707107   0.707107

julia> push!(Circuit(), GateRY(pi/2), 1)
1-qubit circuit with 1 gates:
└── RY(θ=π⋅0.5) @ q1
MimiqCircuitsBase.GateRZ — Type
struct GateRZ <: ParametricGate{1}

Single qubit Rotation-Z gate (RZ gate)

Arguments

  • λ::Float64: Rotation angle in radians

Matrix Representation

\[\operatorname{RZ}(\lambda) = \begin{pmatrix} e^{-i\frac{\lambda}{2}} & 0 \\ 0 & e^{i\frac{\lambda}{2}} \end{pmatrix}\]

Examples

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

julia> push!(Circuit(), GateRZ(pi/2), 1)
1-qubit circuit with 1 gates:
└── RZ(λ=π⋅0.5) @ q1
MimiqCircuitsBase.GateR — Type
struct GateR <: ParametricGate{1}

Single qubit Rotation gate around the axis cos(ϕ)x + sin(ϕ)y.

Arguments

  • θ::Float64: Rotation angle in radians
  • ϕ::Float64: Axis of rotation in radians

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> matrix(GateR(pi/2,pi/4))
2×2 Matrix{ComplexF64}:
 0.707107+0.0im      -0.5-0.5im
      0.5-0.5im  0.707107+0.0im

julia> push!(Circuit(), GateR(pi/2,pi/4), 1)
1-qubit circuit with 1 gates:
└── R(θ=π⋅0.5, ϕ=π⋅0.25) @ q1
MimiqCircuitsBase.GateU1 — Type
struct GateU1 <: ParametricGate{1}

One qubit generic unitary gate u1, as defined in OpenQASM 3.0

Equivalent to GateP

Arguments

  • λ::Float64: Rotation angle in radians

Matrix Representation

\[\operatorname{U1}(\lambda) = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\lambda} \end{pmatrix}\]

Examples

julia> matrix(GateU1(pi/4))
2×2 Matrix{ComplexF64}:
 1.0+0.0im       0.0+0.0im
 0.0+0.0im  0.707107+0.707107im

julia> push!(Circuit(), GateU1(pi/4), 1)
1-qubit circuit with 1 gates:
└── U1(λ=π⋅0.25) @ q1
MimiqCircuitsBase.GateU2 — Type
struct GateU2 <: ParametricGate{1}

One qubit generic unitary gate u2, as defined in OpenQASM 3.0

See also GateU2DG.

Arguments

  • ϕ:Float64: Rotation angle in radians
  • λ::Float64: Rotation angle in radians

Examples

julia> matrix(GateU2(pi/2,pi/4))
2×2 Matrix{ComplexF64}:
 0.270598-0.653281im  -0.653281+0.270598im
 0.653281+0.270598im   0.270598+0.653281im

julia> push!(Circuit(), GateU2(pi/4,pi/4), 1)
1-qubit circuit with 1 gates:
└── U2(ϕ=π⋅0.25, λ=π⋅0.25) @ q1
MimiqCircuitsBase.GateU2DG — Type
struct GateU2DG <: ParametricGate{1}

One qubit generic unitary gate u2-dagger, as defined in OpenQASM 3.0 for backwards compatibility

See also GateU2

Arguments

  • ϕ:Float64: Rotation angle in radians
  • λ::Float64: Rotation angle in radians

Examples

julia> matrix(GateU2DG(pi/2,pi/4))
2×2 Matrix{ComplexF64}:
  0.270598+0.653281im  0.653281-0.270598im
 -0.653281-0.270598im  0.270598-0.653281im

julia> push!(Circuit(), GateU2DG(pi/2,pi/4), 1)
1-qubit circuit with 1 gates:
└── U2DG(ϕ=π⋅0.5, λ=π⋅0.25) @ q1
MimiqCircuitsBase.GateU3 — Type
struct GateU3 <: ParametricGate{1}

One qubit generic unitary gate u3, as defined in OpenQASM 3.0 for backwards compatibility.

Arguments

  • θ:Float64: Rotation angle 1 in radians
  • ϕ:Float64: Rotation angle 2 in radians
  • λ::Float64: Rotation angle 3 in radians

Examples

julia> matrix(GateU3(pi/2,pi/4,pi/2))
2×2 Matrix{ComplexF64}:
 0.270598-0.653281im  -0.653281-0.270598im
 0.653281-0.270598im   0.270598+0.653281im

julia> push!(Circuit(), GateU3(pi/2, pi/4, pi/2), 1)
1-qubit circuit with 1 gates:
└── U3(θ=π⋅0.5, ϕ=π⋅0.25, λ=π⋅0.5) @ q1
MimiqCircuitsBase.GateU — Type
struct GateU <: ParametricGate{1}

One qubit generic unitary gate, as defined in OpenQASM 3.0.

Arguments

  • θ::Float64: Euler angle 1 in radians
  • ϕ::Float64: Euler angle 2 in radians
  • λ::Float64: Euler angle 3 in radians

Matrix Representation

\[\operatorname{U}(\theta,\phi,\lambda) = \begin{pmatrix} \cos\frac{\theta}{2} & -e^{i\lambda}\sin\frac{\theta}{2} \\ e^{i\phi}\sin\frac{\theta}{2} & e^{i(\phi+\lambda)}\cos\frac{\theta}{2} \end{pmatrix}\]

Examples

julia> matrix(GateU(pi/3, pi/3, pi/3))
2×2 Matrix{ComplexF64}:
 0.866025+0.0im           -0.25-0.433013im
     0.25+0.433013im  -0.433013+0.75im

julia> push!(Circuit(), GateU(pi/3, pi/3, pi/3), 1)
1-qubit circuit with 1 gates:
└── U(θ=π⋅0.3333..., ϕ=π⋅0.3333..., λ=π⋅0.3333...) @ q1

Two-Qubit Gates

Controlled Pauli gates:

MimiqCircuitsBase.GateCX — Type
struct GateCX <: Gate{2}

Two qubit Controlled-X gate (or CNOT).

Matrix Representation

\[\operatorname{CX} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{pmatrix}\]

By convention we refer to the first qubit as the control qubit and the second qubit as the target.

Examples

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> push!(Circuit(), GateCX(), 1, 2)
2-qubit circuit with 1 gates:
└── CX @ q1, q2
MimiqCircuitsBase.GateCY — Type
struct GateCY <: Gate{2}

Two qubit Controlled-Y gate.

Matrix Representation

\[\operatorname{CY} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & -i \\ 0 & 0 & i & 0 \end{pmatrix}\]

By convention we refer to the first qubit as the control qubit and the second qubit as the target.

Examples

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> push!(Circuit(), GateCY(), 1, 2)
2-qubit circuit with 1 gates:
└── CY @ q1, q2
MimiqCircuitsBase.GateCZ — Type
struct GateCZ <: Gate{2}

Two qubit Controlled-Z gate.

Matrix Representation

\[\operatorname{CZ} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & -1 \end{pmatrix}\]

By convention we refer to the first qubit as the control qubit and the second qubit as the target.

Examples

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> push!(Circuit(), GateCZ(), 1, 2)
2-qubit circuit with 1 gates:
└── CZ @ q1, q2
MimiqCircuitsBase.GateCH — Type
struct GateCH <: Gate{2}

Two qubit Controlled-Hadamard gate.

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}\]

By convention we refer to the first qubit as the control qubit and the second qubit as the target.

Examples

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> push!(Circuit(), GateCH(), 1, 2)
2-qubit circuit with 1 gates:
└── CH @ q1, q2
MimiqCircuitsBase.GateSWAP — Type
struct GateSWAP <: Gate{2}

Two qubit SWAP gate.

See also GateISWAP

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> 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> push!(Circuit(), GateSWAP(), 1, 2)
2-qubit circuit with 1 gates:
└── SWAP @ q1, q2
MimiqCircuitsBase.GateISWAP — Type
struct GateISWAP <: Gate{2}

Two qubit ISWAP gate.

See also GateISWAPDG, 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> 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> push!(Circuit(), GateISWAP(), 1, 2)
2-qubit circuit with 1 gates:
└── ISWAP @ q1, q2
MimiqCircuitsBase.GateISWAPDG — Type
struct GateISWAPDG <: Gate{2}

Two qubit ISWAP-dagger gate (conjugate transpose of ISWAP)

See also GateISWAP, GateSWAP

Matrix Representation

\[\operatorname{ISWAP}^\dagger = \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> matrix(GateISWAPDG())
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> push!(Circuit(), GateISWAPDG(), 1, 2)
2-qubit circuit with 1 gates:
└── ISWAPDG @ q1, q2
MimiqCircuitsBase.GateCS — Type
struct GateCS <: Gate{2}

Two qubit Controlled-S gate.

Matrix Representation

\[\begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & i \end{pmatrix}\]

Examples

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> push!(Circuit(), GateCS(), 1, 2)
2-qubit circuit with 1 gates:
└── CS @ q1, q2
MimiqCircuitsBase.GateCSDG — Type
struct GateCSDG <: Gate{2}

Two qubit CS-dagger gate.

Matrix Representation

\[\begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & i \end{pmatrix}\]

Examples

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> push!(Circuit(), GateCSDG(), 1, 2)
2-qubit circuit with 1 gates:
└── CSDG @ q1, q2
MimiqCircuitsBase.GateCSX — Type
struct GateCSX <: Gate{2}

Two qubit Controlled-SX gate. (Control on second qubit)

Matrix Representation

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

Examples

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  0.5+0.5im  0.0+0.0im  0.5-0.5im
 0.0+0.0im  0.0+0.0im  1.0+0.0im  0.0+0.0im
 0.0+0.0im  0.5-0.5im  0.0+0.0im  0.5+0.5im

julia> push!(Circuit(), GateCSX(), 1, 2)
2-qubit circuit with 1 gates:
└── CSX @ q1, q2
MimiqCircuitsBase.GateCSXDG — Type
struct GateCSXDG <: Gate{2}

Two qubit CSX-dagger gate. (Control on second qubit)

Matrix Representation

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

Examples

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  0.5-0.5im  0.0+0.0im  0.5+0.5im
 0.0+0.0im  0.0+0.0im  1.0+0.0im  0.0+0.0im
 0.0+0.0im  0.5+0.5im  0.0+0.0im  0.5-0.5im

julia> push!(Circuit(), GateCSXDG(), 1, 2)
2-qubit circuit with 1 gates:
└── CSXDG @ q1, q2
MimiqCircuitsBase.GateECR — Type
struct GateECR <: Gate{2}

Two qubit ECR echo gate.

Matrix Representation

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

Examples

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  0.5+0.5im  0.0+0.0im  0.5-0.5im
 0.0+0.0im  0.0+0.0im  1.0+0.0im  0.0+0.0im
 0.0+0.0im  0.5-0.5im  0.0+0.0im  0.5+0.5im

julia> push!(Circuit(), GateCSX(), 1, 2)
2-qubit circuit with 1 gates:
└── CSX @ q1, q2
MimiqCircuitsBase.GateDCX — Type
struct GateDCX <: Gate{2}

Two qubit double-CNOT (Control on first qubit and then second) OR DCX gate.

Matrix Representation

\[\begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \end{pmatrix}\]

Examples

julia> matrix(GateDCX())
4×4 Matrix{Float64}:
 1.0  0.0  0.0  0.0
 0.0  0.0  0.0  1.0
 0.0  1.0  0.0  0.0
 0.0  0.0  1.0  0.0

julia> push!(Circuit(), GateDCX(), 1, 2)
2-qubit circuit with 1 gates:
└── DCX @ q1, q2
MimiqCircuitsBase.GateDCXDG — Type
struct GateDCXDG <: Gate{2}

Two qubit DCX-dagger gate.

Matrix Representation

\[\begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 1 & 0 & 0 \end{pmatrix}\]

Examples

julia> matrix(GateDCXDG())
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> push!(Circuit(), GateDCXDG(), 1, 2)
2-qubit circuit with 1 gates:
└── DCXDG @ q1, q2

Parametric Two-Cubit Gates

MimiqCircuitsBase.GateCP — Type
struct GateCP <: ParametricGate{2}

Two qubit Controlled-Phase gate

Arguments

  • λ::Float64: Phase angle in radians

Matrix Representation

\[\operatorname{CP}(\lambda) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & e^{i\lambda} \end{pmatrix}\]

By convention we refer to the first qubit as the control qubit and the second qubit as the target.

Examples

julia> matrix(GateCP(pi/4))
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.707107+0.707107im

julia> push!(Circuit(), GateCP(pi/4), 1, 2)
2-qubit circuit with 1 gates:
└── CP(λ=π⋅0.25) @ q1, q2
MimiqCircuitsBase.GateCRX — Type
struct GateCRX <: ParametricGate{2}

Two qubit Controlled-RX gate

Arguments

  • θ::Float64: Rotation angle in radians

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}\]

By convention we refer to the first qubit as the control qubit and the second qubit as the target.

Examples

julia> matrix(GateCRX(pi/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.707107+0.0im           -0.0-0.707107im
 0.0+0.0im  0.0+0.0im       0.0-0.707107im  0.707107+0.0im

julia> push!(Circuit(), GateCRX(pi/2), 1, 2)
2-qubit circuit with 1 gates:
└── CRX(θ=π⋅0.5) @ q1, q2
MimiqCircuitsBase.GateCRY — Type
struct GateCRY <: ParametricGate{2}

Two qubit Controlled-RY gate

Arguments

  • θ::Float64: Rotation angle in radians

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}\]

By convention we refer to the first qubit as the control qubit and the second qubit as the target.

Examples

julia> matrix(GateCRY(pi/2))
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> push!(Circuit(), GateCRY(pi/2), 1, 2)
2-qubit circuit with 1 gates:
└── CRY(θ=π⋅0.5) @ q1, q2
MimiqCircuitsBase.GateCRZ — Type
struct GateCRZ <: ParametricGate{2}

Two qubit Controlled-RZ gate

Arguments

  • λ::Float64: Rotation angle in radians

Matrix Representation

\[\operatorname{CRZ}(\lambda) = \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}\]

By convention we refer to the first qubit as the control qubit and the second qubit as the target.

Examples

julia> matrix(GateCRZ(pi/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.707107-0.707107im      -0.0+0.0im
 0.0+0.0im  0.0+0.0im       0.0+0.0im       0.707107+0.707107im

julia> push!(Circuit(), GateCRZ(pi/2), 1, 2)
2-qubit circuit with 1 gates:
└── CRZ(λ=π⋅0.5) @ q1, q2
MimiqCircuitsBase.GateCU — Type
struct GateCU <: ParametricGate{2}

Two qubit generic unitary gate, equivalent to the qiskit CUGate https://qiskit.org/documentation/stubs/qiskit.circuit.library.CUGate.html

Arguments

  • θ::Float64: Euler angle 1 in radians
  • ϕ::Float64: Euler angle 2 in radians
  • λ::Float64: Euler angle 3 in radians
  • γ::Float64: Global phase of the U gate

Matrix Representation

\[\operatorname{CU}(\theta,\phi,\lambda,\gamma) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & e^{i\gamma}\cos\frac{\theta}{2} & -e^{i(\gamma+\lambda)}\sin\frac{\theta}{2} \\ 0 & 0 & e^{i(\gamma+\phi)}\sin\frac{\theta}{2} & e^{i(\gamma+\phi+\lambda)}\cos\frac{\theta}{2} \end{pmatrix}\]

By convention we refer to the first qubit as the control qubit and the second qubit as the target.

Examples

julia> matrix(GateCU(pi/3, pi/3, pi/3, 0))
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.866025+0.0im           -0.25-0.433013im
 0.0+0.0im  0.0+0.0im      0.25+0.433013im  -0.433013+0.75im

julia> push!(Circuit(), GateCU(pi/3, pi/3, pi/3, 0), 1, 2)
2-qubit circuit with 1 gates:
└── CU(θ=π⋅0.3333..., ϕ=π⋅0.3333..., λ=π⋅0.3333..., γ=π⋅0.0) @ q1, q2
MimiqCircuitsBase.GateCR — Type
struct GateCR <: ParametricGate{2}

Two qubit Controlled-R gate.

Arguments

  • θ::Float64: Rotation angle in radians
  • ϕ::Float64: The phase angle in radians.

Matrix Representation

\[\operatorname{CR}(\theta, \phi) = \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}e^{i\phi} \end{pmatrix}\]

Examples

julia> matrix(GateCR(pi,-pi))
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   6.12323e-17+0.0im  1.22465e-16+1.0im
 0.0+0.0im  0.0+0.0im  -1.22465e-16+1.0im  6.12323e-17+0.0im

julia> push!(Circuit(), GateCR(pi,-pi), 1, 2)
2-qubit circuit with 1 gates:
└── CR(θ=π⋅1.0, ϕ=-π⋅1.0) @ q1, q2
MimiqCircuitsBase.GateRXX — Type
struct GateRXX <: ParametricGate{2}

Two qubit RXX gate.

Arguments

  • θ::Float64: The angle in radians

Matrix Representation

\[\operatorname{RXX}(\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> matrix(GateRXX(π/4))
4×4 Matrix{ComplexF64}:
 0.92388+0.0im           0.0+0.0im       …      0.0-0.382683im
     0.0+0.0im       0.92388+0.0im              0.0+0.0im
     0.0+0.0im           0.0-0.382683im         0.0+0.0im
     0.0-0.382683im      0.0+0.0im          0.92388+0.0im

julia> push!(Circuit(), GateRXX(π), 1, 2)
2-qubit circuit with 1 gates:
└── RXX(θ=π⋅1.0) @ q1, q2
MimiqCircuitsBase.GateRYY — Type
struct GateRYY <: ParametricGate{2}

Two qubit RYY gate.

Arguments

  • θ::Float64: The angle in radians

Matrix Representation

\[\operatorname{RYY}(\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> matrix(GateRYY(π/4))
4×4 Matrix{ComplexF64}:
 0.92388+0.0im           0.0+0.0im       …      0.0+0.382683im
     0.0+0.0im       0.92388+0.0im              0.0+0.0im
     0.0+0.0im           0.0-0.382683im         0.0+0.0im
     0.0+0.382683im      0.0+0.0im          0.92388+0.0im

julia> push!(Circuit(), GateRYY(π), 1, 2)
2-qubit circuit with 1 gates:
└── RYY(θ=π⋅1.0) @ q1, q2
MimiqCircuitsBase.GateRZZ — Type
struct GateRZZ <: ParametricGate{2}

Two qubit RZZ gate.

Arguments

  • θ::Float64: The angle in radians

Matrix Representation

\[\operatorname{RZZ}(\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> matrix(GateRZZ(π/4))
4×4 Matrix{ComplexF64}:
 0.92388-0.382683im      0.0+0.0im       …      0.0+0.0im
     0.0+0.0im       0.92388+0.382683im         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.92388-0.382683im

julia> push!(Circuit(), GateRZZ(π), 1, 2)
2-qubit circuit with 1 gates:
└── RZZ(θ=π⋅1.0) @ q1, q2
MimiqCircuitsBase.GateXXplusYY — Type
struct GateXXplusYY <: ParametricGate{2}

Two qubit XXplusYY gate.

Arguments

  • θ::Float64: The angle in radians.
  • β::Float64: The phase angle in radians.

Matrix Representation

\[\operatorname{XXplusYY}(\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> matrix(GateXXplusYY(π/2,π/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  0.707107+0.0im          -0.707107-4.32978e-17im  0.0+0.0im
 0.0+0.0im  0.707107-4.32978e-17im   0.707107+0.0im          0.0+0.0im
 0.0+0.0im       0.0+0.0im                0.0+0.0im          1.0+0.0im

julia> push!(Circuit(), GateXXplusYY(π,π), 1, 2)
2-qubit circuit with 1 gates:
└── XXplusYY(θ=π⋅1.0, β=π⋅1.0) @ q1, q2
MimiqCircuitsBase.GateXXminusYY — Type
struct GateXXminusYY <: ParametricGate{2}

Two qubit XXminusYY gate.

Arguments

  • θ::Float64: The angle in radians.
  • β::Float64: The phase angle in radians.

Matrix Representation

\[\operatorname{XXminusYY}(\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> matrix(GateXXminusYY(π/2,π/2))
4×4 Matrix{ComplexF64}:
 0.707107+0.0im          0.0+0.0im  0.0+0.0im  -0.707107-4.32978e-17im
      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.707107-4.32978e-17im  0.0+0.0im  0.0+0.0im   0.707107+0.0im

julia> push!(Circuit(), GateXXminusYY(π,π), 1, 2)
2-qubit circuit with 1 gates:
└── XXminusYY(θ=π⋅1.0, β=π⋅1.0) @ q1, q2

Custom gates

MimiqCircuitsBase.GateCustom — Type
struct GateCustom{N,T} <: Gate{N}

N qubit gate specified by a $2^N \times 2^N$ matrix with elements of type T.

Use this to construct your own gates based on unitary matrices. Currently only N=1,2 (M=2,4) are recognised.

MIMIQ uses textbook convention for specifying gates.

One qubit gate matrices are defined in the basis $|0\rangle$, $|1\rangle$ e.g.,

\[\operatorname{Z} = \begin{pmatrix} 1&0\\ 0&-1 \end{pmatrix}\]

Two qubit gate matrices are defined in the basis $|00\rangle$, $|01\rangle$>, $|10\rangle$, $|11\rangle$ where the left-most qubit is the first to appear in the target list e.g.,

\[\operatorname{CNOT} = \begin{pmatrix} 1&0&0&0\\ 0&1&0&0\\ 0&0&0&1\\ 0&0&1&0 \end{pmatrix}\]

julia> CNOT = [1 0 0 0; 0 1 0 0; 0 0 0 1; 0 0 1 0]
4×4 Matrix{Int64}:
 1  0  0  0
 0  1  0  0
 0  0  0  1
 0  0  1  0

julia> # CNOT gate with control on q1 and target on q2

julia> Instruction(GateCustom(CNOT), 1, 2)
GateCustom([1 0 0 0; 0 1 0 0; 0 0 0 1; 0 0 1 0]) @ q1, q2

# Examples

jldoctest julia> g = GateCustom([1 0; 0 1]) Custom([1.0 0.0; 0.0 1.0])

julia> push!(Circuit(), g, 1) 1-qubit circuit with 1 gates: └── Custom([1.0 0.0; 0.0 1.0]) @ q1 ```

Other quantum operations

MimiqCircuitsBase.Barrier — Type
struct Barrier <: Operation

A barrier is a special operation that does not affect the quantum state or the execution of a circuit, but it prevents compression or optimization operation from being applied across it.

Examples

julia> push!(Circuit(), Barrier(), 1, 2)
2-qubit circuit with 1 gates:
└── Barrier @ q1, q2

Utilities to load or save quantum circuits

MimiqCircuitsBase.fromjson — Function
fromjson(str)
fromjson(parsed_json_dict)

Returns a circuit from a JSON string or parsed JSON.

Index