Generalized gates
MimiqCircuitsBase.QFT — Type
QFT(n)Quantum Fourier transform.
Performs the quantum Fourier transform on a register of n qubits.
The inverse quantum Fourier transform is simply given inverse(qft).
It implements the unitary transformation.
\[\frac{1}{2^{n/2}} \sum_{x=0}^{2^n-1} \sum_{y=0}^{2^n-1} e^{2\pi i \frac{xy}{2^n}} \ket{y}\bra{x}\]
Examples
julia> c = push!(Circuit(), QFT(10), 1:10...)
10-qubit circuit with 1 instruction:
└── QFT @ q[1:10]
julia> push!(c, inverse(QFT(10)), 1:10...)
10-qubit circuit with 2 instructions:
├── QFT @ q[1:10]
└── QFT† @ q[1:10]MimiqCircuitsBase.PhaseGradient — Type
PhaseGradient(n)A phase gradient gate applies a phase shift to a quantum register of n qubits, where each computational basis state $\ket{k}$ experiences a phase proportional to its integer value $k$:
\[\operatorname{PhaseGradient} = \sum{k=0}^{n-1} \mathrm{e}^{i \frac{2 \pi}{N} k} \ket{k}\bra{k}\]
MimiqCircuitsBase.PolynomialOracle — Type
PolynomialOracle(xregsize, yregsize, a, b, c, d)
PolynomialOracle(a, b, c, d) # lazyQuantum oracle for a polynomial function of two registers.
Applies a $\pi$ phase shift to any basis state which satifies $a xy + bx + cy + d == 0$, where $\ket{x}$ and $\ket{y}$ are the states of the two registers.
Examples
julia> c = push!(Circuit(), PolynomialOracle(5,5,1,2,3,4), 1:10...)
10-qubit circuit with 1 instruction:
└── PolynomialOracle(1,2,3,4) @ q[1:5], q[6:10]
julia> push!(c, inverse(PolynomialOracle(5,5,1,2,3,4)), 1:10...)
10-qubit circuit with 2 instructions:
├── PolynomialOracle(1,2,3,4) @ q[1:5], q[6:10]
└── PolynomialOracle(1,2,3,4) @ q[1:5], q[6:10]MimiqCircuitsBase.Diffusion — Type
Diffusion(n)
Diffusion() # lazyGrover's diffusion operator.
It implements the unitary transformation.
\[H^{\otimes n} (1-2\ket{0^n}\bra{0^n}) H^{\otimes n}\]
Examples
julia> c = push!(Circuit(), Diffusion(10), 1:10...)
10-qubit circuit with 1 instruction:
└── Diffusion @ q[1:10]
julia> push!(c, inverse(Diffusion(10)), 1:10...)
10-qubit circuit with 2 instructions:
├── Diffusion @ q[1:10]
└── Diffusion† @ q[1:10]julia> decompose(Diffusion(4))
4-qubit circuit with 71 instructions:
├── U(π/2,0,0) @ q[1]
├── U(π/2,0,0) @ q[2]
├── U(π/2,0,0) @ q[3]
├── U(π/2,0,0) @ q[4]
├── U(0,0,π/4) @ q[3]
├── CX @ q[3], q[4]
├── U(0,0,-1π/4) @ q[4]
├── CX @ q[3], q[4]
├── U(0,0,π/4) @ q[4]
⋮ ⋮
├── U(0,0,π/8) @ q[1]
├── U(0,0,π/8) @ q[4]
├── CX @ q[1], q[4]
├── U(0,0,-1π/8) @ q[4]
├── CX @ q[1], q[4]
├── U(0,0,0) @ q[4]
├── U(-1π/2,0,0) @ q[1]
├── U(-1π/2,0,0) @ q[2]
├── U(-1π/2,0,0) @ q[3]
└── U(-1π/2,0,0) @ q[4]
MimiqCircuitsBase.PauliString — Type
PauliString(paulistr)$N$-qubit tensor product of Pauli operators.
The PauliString gate can represent any $N$-qubit tensor product of Pauli operators of the form
\[P_1 \otimes P_2 \otimes P_3 \otimes \ldots \otimes P_N,\]
where each $P_i \in \{ I, X, Y, Z \}$ is a Pauli operator, including the identity.
See also GateID, GateX, GateY, GateZ.
Arguments
paulistr: string of length $N$ where each character is either"I","X","Y", or"Z". The number of qubits is equal to $N$.
Examples
PauliStrings of any length are supported.
julia> c = push!(Circuit(), PauliString("XX"), 1, 2)
2-qubit circuit with 1 instruction:
└── XX @ q[1:2]
julia> push!(c, PauliString("IXYZZYXI"), 1, 2, 3, 4, 5, 6, 7, 8)
8-qubit circuit with 2 instructions:
├── XX @ q[1:2]
└── IXYZZYXI @ q[1:8]Decomposition
Decomposes into one-qubit Pauli gates.
julia> decompose(PauliString("XIYZZ"))
5-qubit circuit with 5 instructions:
├── U(π,0,π) @ q[1]
├── U(0,0,0) @ q[2]
├── U(π,π/2,π/2) @ q[3]
├── U(0,0,π) @ q[4]
└── U(0,0,π) @ q[5]MimiqCircuitsBase.@pauli_str — Macro
macro pauli_str(s)pauli"" literal for creating a PauliString gate.
Examples
julia> pauli"XYYXZ"
XYYXZ
MimiqCircuitsBase.RPauli — Type
RPauli(pauli::String, param)Apply an exponential of a Pauli string rotation gate of the form:
\mathrm{e}^{-\imath \frac{\theta}{2} \left(P_1 \otimes P_2 \otimes \dots\right)}Each $P_i$ is a Pauli operator $I$ $X$, $Y$, or $Z$.
Examples
```jldoctests julia> RPauli("X", π/2) exp(-i * 1.5707963267948966 * X)
julia> RPauli("ZIZ", 2.0) exp(-i * 2.0 * ZIZ)
julia> RPauli("ZIZ", 2.0)|>decompose 3-qubit circuit with 3 instructions: ├── CX @ q[1], q[3] ├── RZ(2.0) @ q[3] └── CX @ q[1], q[3]
julia> c = push!(Circuit(), RPauli("YXI", 2.0), 1, 2, 3) 3-qubit circuit with 1 instructions: └── exp(-i * 2.0/2 * YXI) @ q[1:3]
julia> push!(c, RPauli("III", π), 1, 2, 3) 3-qubit circuit with 2 instructions: ├── exp(-i * 2.0/2 * YXI) @ q[1:3] └── identity rotation (noop) @ q[1:3]
julia> push!(c, RPauli("IXY", π), 1, 2, 3) 3-qubit circuit with 3 instructions: ├── exp(-i * 2.0/2 * YXI) @ q[1:3] ├── identity rotation (noop) @ q[1:3] └── exp(-i * π * IXY) @ q[1:3]
MimiqCircuitsBase.GateRNZ — Type
GateRNZ(n, θ)
GateRNZ() # lazyMulti-qubit parity-phase rotation gate along the Z-axis.
Examples
```jldoctests julia> using Symbolics; @variables θ 1-element Vector{Num}: θ
julia> GateRNZ(4, θ) RNZ(θ)
julia> matrix(GateRNZ(2, θ)) 4×4 Matrix{Complex{Symbolics.Num}}: cos((1//2)θ) + imsin((1//2)θ) 0 0 0 0 cos((-1//2)θ) + imsin((-1//2)θ) 0 0 0 0 cos((-1//2)θ) + imsin((-1//2)θ) 0 0 0 0 cos((1//2)θ) + imsin((1//2)θ)
julia> c = push!(Circuit(), GateRNZ(3, θ), 1, 2, 3) 3-qubit circuit with 1 instructions: └── RNZ(θ) @ q[1:3]
julia> push!(c, inverse(GateRNZ(3, θ)), 1, 2, 3) 3-qubit circuit with 2 instructions: ├── RNZ(θ) @ q[1:3] └── RNZ(-θ) @ q[1:3]