QuantumCircuitOpt Function References
QuantumCircuitOpt.GateData
— TypeGateData
The composite mutable struct, GateData
, type of the gate, the complex matrix form of the gate, full sized real form of the gate, inverse of the gate and a boolean which states if the gate has all real entries.
QuantumCircuitOpt.QCModelOptions
— TypeQCModelOptions
The composite mutable struct, QCModelOptions
, holds various optimization model options for enhancements with defualt options set to the values provided by get_default_options
function.
QuantumCircuitOpt.QuantumCircuitModel
— TypeQuantumCircuitModel
The composite mutable struct, QuantumCircuitModel
, holds dictionaries for input data, abstract JuMP model for optimization, variable references and result from solving the JuMP model.
QuantumCircuitOpt.CCZGate
— MethodCCZGate()
Three-qubit controlled-controlled Z gate.
Circuit Representation
q_0: ─■─
│
q_1: ─■─
│
q_2: ─■─
Matrix Representation
\[CCZGate = \begin{pmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & -1 \\ \end{pmatrix}\]
QuantumCircuitOpt.CHGate
— MethodCHGate()
Two-qubit, symmetric, controlled Hadamard gate (HGate).
Circuit Representation
q_0: ──■──
┌─┴─┐
q_1: ┤ H ├
└───┘
Matrix Representation
\[CH = |0\rangle\langle 0| \otimes I + |1\rangle\langle 1| \otimes H = \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}\]
QuantumCircuitOpt.CHRevGate
— MethodCHRevGate()
Two-qubit reverse controlled-H gate, with target and control on first and second qubits, respectively.
Circuit Representation
┌───┐
q_0: ┤ H ├
└─┬─┘
q_1: ──■──
Matrix Representation
\[CHRev = I \otimes |0\rangle\langle 0| + H \otimes |1\rangle\langle 1| = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & \frac{1}{\sqrt{2}} & 0 & \frac{1}{\sqrt{2}} \\ 0 & 0 & 1 & 0 \\ 0 & \frac{1}{\sqrt{2}} & 0 & -\frac{1}{\sqrt{2}} \end{pmatrix}\]
QuantumCircuitOpt.CNotGate
— MethodCNotGate()
Two-qubit controlled NOT gate with control and target on first and second qubits, respectively. This is also called the controlled X gate (CXGate).
Circuit Representation
q_0: ──■──
┌─┴─┐
q_1: ┤ X ├
└───┘
Matrix Representation
\[CNot = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{pmatrix}\]
QuantumCircuitOpt.CNotRevGate
— MethodCNotRevGate()
Two-qubit reverse controlled NOT gate, with target and control on first and second qubits, respectively.
Circuit Representation
┌───┐
q_0: ┤ X ├
└─┬─┘
q_1: ──■──
Matrix Representation
\[CNotRev = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \end{pmatrix}\]
QuantumCircuitOpt.CRXGate
— MethodCRXGate(θ::Number)
Two-qubit controlled RXGate.
Circuit Representation
q_0: ────■────
┌───┴───┐
q_1: ┤ RX(ϴ) ├
└───────┘
Matrix Representation
\[\newcommand{\th}{\frac{\theta}{2}} CRX(\theta)\ q_1, q_0 = |0\rangle\langle0| \otimes I + |1\rangle\langle1| \otimes RX(\theta) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \cos{\th} & -i\sin{\th} \\ 0 & 0 & -i\sin{\th} & \cos{\th} \end{pmatrix}\]
QuantumCircuitOpt.CRXRevGate
— MethodCRXRevGate(θ::Number)
Two-qubit controlled reverse RXGate.
Circuit Representation
┌───────┐
q_1: ┤ RX(ϴ) ├
└───┬───┘
q_0: ────■────
Matrix Representation
\[\newcommand{\th}{\frac{\theta}{2}} CRXRev(\theta)\ q_1, q_0 = |0\rangle\langle0| \otimes I + |1\rangle\langle1| \otimes RX(\theta) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & \cos{\th} & 0 & -i\sin{\th} \\ 0 & 0 & 1 & 0\\ 0 & -i\sin{\th} & 0 & \cos{\th} \end{pmatrix}\]
QuantumCircuitOpt.CRYGate
— MethodCRYGate(θ::Number)
Two-qubit controlled RYGate.
Circuit Representation
q_0: ────■────
┌───┴───┐
q_1: ┤ RY(ϴ) ├
└───────┘
Matrix Representation
\[\newcommand{\th}{\frac{\theta}{2}} CRY(\theta)\ q_1, q_0 = |0\rangle\langle0| \otimes I + |1\rangle\langle1| \otimes RY(\theta) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \cos{\th} & -\sin{\th} \\ 0 & 0 & \sin{\th} & \cos{\th} \end{pmatrix}\]
QuantumCircuitOpt.CRYRevGate
— MethodCRYRevGate(θ::Number)
Two-qubit controlled reverse RYGate.
Circuit Representation
┌───────┐
q_1: ┤ RY(ϴ) ├
└───┬───┘
q_0: ────■────
Matrix Representation
\[\newcommand{\th}{\frac{\theta}{2}} CRYRev(\theta)\ q_1, q_0 = |0\rangle\langle0| \otimes I + |1\rangle\langle1| \otimes RY(\theta) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & \cos{\th} & 0 & -\sin{\th} \\ 0 & 0 & 1 & 0 \\ 0 & \sin{\th} & 0 & \cos{\th} \end{pmatrix}\]
QuantumCircuitOpt.CRZGate
— MethodCRZGate(θ::Number)
Two-qubit controlled RZGate.
Circuit Representation
q_0: ────■────
┌───┴───┐
q_1: ┤ RZ(ϴ) ├
└───────┘
Matrix Representation
\[\newcommand{\th}{\frac{\theta}{2}} CRZ(\theta)\ q_1, q_0 = |0\rangle\langle0| \otimes I + |1\rangle\langle1| \otimes RZ(\theta) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & e^{-i\th} & 0 \\ 0 & 0 & 0 & e^{i\th} \end{pmatrix}\]
QuantumCircuitOpt.CRZRevGate
— MethodCRZRevGate(θ::Number)
Two-qubit controlled reverse RZGate.
Circuit Representation
┌───────┐
q_1: ┤ RZ(ϴ) ├
└───┬───┘
q_0: ────■────
Matrix Representation
\[\newcommand{\th}{\frac{\theta}{2}} CRZRev(\theta)\ q_1, q_0 = |0\rangle\langle0| \otimes I + |1\rangle\langle1| \otimes RZ(\theta) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & e^{-i\th} & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & e^{i\th} \end{pmatrix}\]
QuantumCircuitOpt.CSGate
— MethodCSGate()
Two-qubit, controlled-S gate, which induces π/2 phase in the target qubit. This gate is invariant to the swap of control and target qubits.
Circuit Representation
q_0: ──■──
┌─┴─┐
q_1: ┤ S ├
└───┘
Matrix Representation
\[CS = |0 \rangle\langle 0| \otimes I + |1 \rangle\langle 1| \otimes S = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & i \end{pmatrix}\]
QuantumCircuitOpt.CSXGate
— MethodCSXGate()
Two-qubit controlled version of (SXGate).
Circuit Representation
q_0: ─────■─────
┌────┴────┐
q_1: ┤ sqrt(X) ├
└─────────┘
Matrix Representation
\[CSXGate = |0 \rangle\langle 0| \otimes I + |1 \rangle\langle 1| \otimes SX = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0.5+0.5i & 0.5-0.5i \\ 0 & 0 & 0.5-0.5i & 0.5+0.5i \end{pmatrix}\]
QuantumCircuitOpt.CSXRevGate
— MethodCSXRevGate()
Two-qubit controlled version of the reverse (SXGate).
Circuit Representation
┌─────────┐
q_1: ┤ sqrt(X) ├
└────┬────┘
q_0: ─────■────
Matrix Representation
\[CSXRevGate = I \otimes |0\rangle\langle 0| + SX \otimes |1\rangle\langle 1| = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0.5+0.5i & 0 & 0.5-0.5i \\ 0 & 0 & 1 & 0 \\ 0 & 0.5-0.5i & 0 & 0.5+0.5i \end{pmatrix}\]
QuantumCircuitOpt.CSdaggerGate
— MethodCSdaggerGate()
Two-qubit hermitian conjugate of controlled-S gate. This gate is invariant to the swap of control and target qubits.
Circuit Representation
q_0: ──■──
┌─┴─┐
q_1: ┤ S'├
└───┘
Matrix Representation
\[CSdagger = |0 \rangle\langle 0| \otimes I + |1 \rangle\langle 1| \otimes S^{\dagger} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & -i \end{pmatrix}\]
QuantumCircuitOpt.CSwapGate
— MethodCSwapGate()
Three-qubit, controlled SwapGate, also known as the Fredkin gate.
Circuit Representation
q_0: ─■─
│
q_1: ─X─
│
q_2: ─X─
Matrix Representation
\[CSwapGate = \begin{pmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 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 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ \end{pmatrix}\]
QuantumCircuitOpt.CTGate
— MethodCTGate()
Two-qubit, controlled-T gate, which induces a π/4 phase in the target qubit. This gate is invariant to the swap of control and target qubits.
Circuit Representation
q_0: ──■──
┌─┴─┐
q_1: ┤ T ├
└───┘
Matrix Representation
\[CT = |0 \rangle\langle 0| \otimes I + |1 \rangle\langle 1| \otimes T = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & e^{i\pi/4} \end{pmatrix}\]
QuantumCircuitOpt.CTdaggerGate
— MethodCTdaggerGate()
Two-qubit hermitian conjugate of controlled-T gate. This gate is invariant to the swap of control and target qubits.
Circuit Representation
q_0: ──■──
┌─┴─┐
q_1: ┤ T'├
└───┘
Matrix Representation
\[CTdagger = |0 \rangle\langle 0| \otimes I + |1 \rangle\langle 1| \otimes T^{\dagger} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & e^{-i\pi/4} \end{pmatrix}\]
QuantumCircuitOpt.CU3Gate
— MethodCU3Gate(θ::Number, ϕ::Number, λ::Number)
Two-qubit, controlled version of the universal rotation gate with three Euler angles (U3Gate).
Circuit Representation
q_0: ──────■──────
┌─────┴─────┐
q_1: ┤ U3(ϴ,φ,λ) ├
└───────────┘
Matrix Representation
\[\newcommand{\th}{\frac{\theta}{2}} CU3(\theta, \phi, \lambda)\ q_1, q_0 = |0\rangle\langle 0| \otimes I + |1\rangle\langle 1| \otimes U3(\theta,\phi,\lambda) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \cos(\th) & -e^{i\lambda}\sin(\th) \\ 0 & 0 & e^{i\phi}\sin(\th) & e^{i(\phi+\lambda)}\cos(\th) \end{pmatrix}\]
QuantumCircuitOpt.CU3RevGate
— MethodCU3RevGate(θ::Number, ϕ::Number, λ::Number)
Two-qubit, reverse controlled version of the universal rotation gate with three Euler angles (U3Gate).
Circuit Representation
┌────────────┐
q_1: ┤ U3(ϴ,φ,λ) ├
└──────┬─────┘
q_0: ───────■──────
Matrix Representation
\[\newcommand{\th}{\frac{\theta}{2}} CU3(\theta, \phi, \lambda)\ q_1, q_0 = |0\rangle\langle 0| \otimes I + |1\rangle\langle 1| \otimes U3(\theta,\phi,\lambda) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & \cos(\th) & 0 & -e^{i\lambda}\sin(\th) \\ 0 & 0 & 1 & 0 \\ 0 & e^{i\phi}\sin(\th) & 0 & e^{i(\phi+\lambda)}\cos(\th) \end{pmatrix}\]
QuantumCircuitOpt.CVGate
— MethodCVGate()
Two-qubit, controlled-V gate, which is also the same as Controlled square-root of X gate (CSXGate).
Circuit Representation
q_0: ──■──
┌─┴─┐
q_1: ┤ V ├
└───┘
Matrix Representation
\[CV = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0.5+0.5i & 0.5-0.5i \\ 0 & 0 & 0.5-0.5i & 0.5+0.5i \end{pmatrix}\]
QuantumCircuitOpt.CVRevGate
— MethodCVRevGate()
Two-qubit reverse controlled-V gate, with target and control on first and second qubits, respectively.
Circuit Representation
┌───┐
q_0: ┤ V ├
└─┬─┘
q_1: ──■──
Matrix Representation
\[CVRev = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0.5+0.5i & 0 & 0.5-0.5i \\ 0 & 0 & 1 & 0 \\ 0 & 0.5-0.5i & 0 & 0.5+0.5i \end{pmatrix}\]
QuantumCircuitOpt.CVdaggerGate
— MethodCVdaggerGate()
Two-qubit hermitian conjugate of controlled-V gate, which is also the same as hermitian conjugate Controlled square-root of X gate (CSXGate).
Circuit Representation
q_0: ──■──
┌─┴─┐
q_1: ┤ V'├
└───┘
Matrix Representation
\[CVdagger = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0.5-0.5i & 0.5+0.5i \\ 0 & 0 & 0.5+0.5i & 0.5-0.5i \end{pmatrix}\]
QuantumCircuitOpt.CVdaggerRevGate
— MethodCVdaggerRevGate()
Two-qubit hermitian conjugate of reverse controlled-V gate, with target and control on first and second qubits, respectively.
Circuit Representation
┌───┐
q_0: ┤ V'├
└─┬─┘
q_1: ──■──
Matrix Representation
\[CVdaggerRev = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0.5-0.5i & 0 & 0.5+0.5i \\ 0 & 0 & 1 & 0 \\ 0 & 0.5+0.5i & 0 & 0.5-0.5i \end{pmatrix}\]
QuantumCircuitOpt.CXGate
— MethodCXGate()
Two-qubit controlled XGate, which is also the same as CNotGate.
Circuit Representation
q_0: ──■──
┌─┴─┐
q_1: ┤ X ├
└───┘
Matrix Representation
\[CX = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{pmatrix}\]
QuantumCircuitOpt.CXRevGate
— MethodCXRevGate()
Two-qubit reverse controlled-X gate, with target and control on first and second qubits, respectively. This is also the same as CNotRevGate.
Circuit Representation
┌───┐
q_0: ┤ X ├
└─┬─┘
q_1: ──■──
Matrix Representation
\[CXRev = I \otimes |0 \rangle\langle 0| + X \otimes |1 \rangle\langle 1| = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \end{pmatrix}\]
QuantumCircuitOpt.CYGate
— MethodCYGate()
Two-qubit controlled YGate.
Circuit Representation
q_0: ──■──
┌─┴─┐
q_1: ┤ Y ├
└───┘
Matrix Representation
\[CY = |0 \rangle\langle 0| \otimes I + |1 \rangle\langle 1| \otimes Y = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & -i \\ 0 & 0 & i & 0 \end{pmatrix}\]
QuantumCircuitOpt.CYRevGate
— MethodCYRevGate()
Two-qubit reverse controlled-Y gate, with target and control on first and second qubits, respectively.
Circuit Representation
┌───┐
q_0: ┤ Y ├
└─┬─┘
q_1: ──■──
Matrix Representation
\[CYRev = I \otimes |0 \rangle\langle 0| + Y \otimes |1 \rangle\langle 1| = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & -i \\ 0 & 0 & 1 & 0 \\ 0 & i & 0 & 0 \end{pmatrix}\]
QuantumCircuitOpt.CZGate
— MethodCZGate()
Two-qubit, symmetric, controlled ZGate.
Circuit Representation
q_0: ──■── ─■─
┌─┴─┐ ≡ │
q_1: ┤ Z ├ ─■─
└───┘
Matrix Representation
\[CZ = |0 \rangle\langle 0| \otimes I + |1 \rangle\langle 1| \otimes Z = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & -1 \end{pmatrix}\]
QuantumCircuitOpt.CiSwapGate
— MethodCiSwapGate()
Three-qubit controlled version of the iSwapGate. Reference: https://doi.org/10.1103/PhysRevResearch.2.033097
Circuit Representation
q_0: ─────■─────
│
┌───────┐
q_1: ─┤ ├─
│ iSwap │
q_2: ─┤ ├─
└───────┘
Matrix Representation
\[CiSwapGate = \begin{pmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & i & 0 \\ 0 & 0 & 0 & 0 & 0 & i & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ \end{pmatrix}\]
QuantumCircuitOpt.DCXGate
— MethodDCXGate()
Two-qubit double controlled NOT gate consisting of two back-to-back CNotGates with alternate controls.
Circuit Representation
┌───┐
q_0: ──■──┤ X ├
┌─┴─┐└─┬─┘
q_1: ┤ X ├──■──
└───┘
Matrix Representation
\[DCX = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \end{pmatrix}\]
QuantumCircuitOpt.GRGate
— MethodGRGate(num_qubits::Int64, θ::Number, ϕ::Number)
A multi-qubit rotation gate with two Euler angles, $\theta$ and $\phi$, applied about the $\cos(\phi)x + \sin(\phi)y$ axis and parametrized by the number of qubits. This gate can be applied to multiple qubits simultaneously, for a given depth. The global R gate is native to atomic systems. In the one-qubit case, this gate is equivalent to the RGate.
Reference: Qiskit's circuit library
Circuit Representation (in 3 qubits)
┌──────────┐
q_0: ┤0 ├
│ │
q_1: ┤1 GR(ϴ,φ) ├
│ │
q_2: ┤2 ├
└──────────┘
Matrix Representation (in 3 qubits)
\[GR(\theta, \phi) = \exp \left(-i \sum_{i=1}^{3} (\cos(\phi)X_i + \sin(\phi)Y_i) \theta/2 \right) \\ = R(\theta, \phi) \otimes R(\theta, \phi) \otimes R(\theta, \phi) \]
QuantumCircuitOpt.GroverDiffusionGate
— MethodGroverDiffusionGate()
Two-qubit, Grover's diffusion operator, a key building block of the Glover's algorithm used to find a specific item (with probability > 0.5) within a randomly ordered database of N items in O(sqrt(N)) operations. Reference: https://arxiv.org/pdf/1804.03719.pdf
Matrix Representation
\[GroverDiffusionGate = \frac{1}{2}\begin{pmatrix} 1 & -1 & -1 & -1 \\ -1 & 1 & -1 & -1 \\ -1 & -1 & 1 & -1 \\ -1 & -1 & -1 & 1 \end{pmatrix}\]
QuantumCircuitOpt.HCoinGate
— MethodHCoinGate()
Two-qubit, Hadamard Coin gate when implemented in tune with the quantum cellular automata. Reference: https://doi.org/10.1007/s11128-018-1983-x, https://arxiv.org/pdf/2106.03115.pdf
Matrix Representation
\[HCoinGate = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} & 0 \\ 0 & \frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}} & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}\]
QuantumCircuitOpt.HGate
— MethodHGate()
Single-qubit Hadamard gate, which is a $\pi$ rotation about the X+Z axis, thus equivalent to U3Gate($\frac{\pi}{2},0,\pi$)
Matrix Representation
\[H = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}\]
QuantumCircuitOpt.IGate
— MethodIGate(num_qubits::Int64)
Identity matrix for an input number of qubits.
Matrix Representation (num_qubits = 1)
\[I = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}\]
QuantumCircuitOpt.MGate
— MethodMGate()
Two-qubit Magic gate, also known as the Ising coupling or the XX gate.
Reference: https://doi.org/10.1103/PhysRevA.69.032315
Circuit Representation
┌───┐ ┌───┐
q_0: ─┤ X ├────────┤ S ├
└─┬─┘ └─┬─┘
│ ┌───┐ ┌─┴─┐
q_1: ───■───┤ H ├──┤ S ├
└───┘ └───┘
Matrix Representation
\[M = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & i & 0 & 0 \\ 0 & 0 & i & 1 \\ 0 & 0 & i & -1 \\ 1 & -i & 0 & 0 \end{pmatrix}\]
QuantumCircuitOpt.MargolusGate
— MethodMargolusGate()
Three-qubit Margolus gate, which is a simplified ToffoliGate and coincides with the Toffoli gate up to a single change of sign. The advantage of this gate is that its implementation requires only three CNot (or CX) gates. Reference: https://arxiv.org/pdf/quant-ph/0312225.pdf
Matrix Representation
\[MargolusGate = \begin{pmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 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 & 1 & 0 \\ \end{pmatrix}\]
QuantumCircuitOpt.PeresGate
— MethodPeresGate()
Three-qubit Peres gate. This gate is equivalent to ToffoliGate followed by the CNotGate in 3 qubits. Reference: https://doi.org/10.1103/PhysRevA.32.3266
Circuit Representation
q_0: ──■─────■──
│ ┌─┴─┐
q_1: ──■───┤ X ├
┌─┴─┐ └───┘
q_2: ┤ X ├──────
└───┘
Matrix Representation
\[PeresGate = \begin{pmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ \end{pmatrix}\]
QuantumCircuitOpt.PhaseGate
— MethodPhaseGate(λ::Number)
Single-qubit rotation gate about the Z axis. This is also equivalent to U3Gate($0,0,\lambda$). This gate is also referred to as the U1Gate.
Matrix Representation
\[P(\lambda) = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\lambda} \end{pmatrix}\]
QuantumCircuitOpt.QFT2Gate
— MethodQFT2Gate()
Two-qubit Quantum Fourier Transform (QFT) gate, where the QFT operation on n-qubits is given by:
\[|j\rangle \mapsto \frac{1}{2^{n/2}} \sum_{k=0}^{2^n - 1} e^{2\pi ijk / 2^n} |k\rangle\]
Circuit Representation
┌──────┐
q_0: ┤ ├
│ QFT2 │
q_1: ┤ ├
└──────┘
Matrix Representation
\[M = \frac{1}{2} \begin{pmatrix} 1 & 1 & 1 & 1 \\ 1 & i & -1 & -i \\ 1 & -1 & 1 & -1 \\ 1 & -i & -1 & i \end{pmatrix}\]
QuantumCircuitOpt.QFT3Gate
— MethodQFT3Gate()
Three-qubit Quantum Fourier Transform (QFT) gate, where the QFT operation on n-qubits is given by:
\[|j\rangle \mapsto \frac{1}{2^{n/2}} \sum_{k=0}^{2^n - 1} e^{2\pi ijk / 2^n} |k\rangle\]
Circuit Representation
┌──────┐
q_0: ┤ ├
│ │
q_1: ┤ QFT3 ├
│ │
q_3: ┤ ├
└──────┘
Matrix Representation
\[M = \frac{1}{2\sqrt{2}} \begin{pmatrix} 1 1 1 1 1 1 1 1 \\ 1 \frac{1}{\sqrt{2}} + \frac{i}{\sqrt{2}} i -\frac{1}{\sqrt{2}} + \frac{i}{\sqrt{2}} -1 -\frac{1}{\sqrt{2}} - \frac{i}{\sqrt{2}} -i \frac{1}{\sqrt{2}} - \frac{i}{\sqrt{2}} \\ 1 i -1 -i 1 i -1 -i \\ 1 -\frac{1}{\sqrt{2}} + \frac{i}{\sqrt{2}} -i \frac{1}{\sqrt{2}} + \frac{i}{\sqrt{2}} -1 \frac{1}{\sqrt{2}} - \frac{i}{\sqrt{2}} i -\frac{1}{\sqrt{2}} - \frac{i}{\sqrt{2}} \\ 1 -1 1 -1 1 -1 1 -1 \\ 1 -\frac{1}{\sqrt{2}} - \frac{i}{\sqrt{2}} i \frac{1}{\sqrt{2}} - \frac{i}{\sqrt{2}} -1 \frac{1}{\sqrt{2}} + \frac{i}{\sqrt{2}} -i -\frac{1}{\sqrt{2}} + \frac{i}{\sqrt{2}} \\ 1 -i -1 i 1 -i -1 i \\ 1 \frac{1}{\sqrt{2}} - \frac{i}{\sqrt{2}} -i -\frac{1}{\sqrt{2}} - \frac{i}{\sqrt{2}} -1 -\frac{1}{\sqrt{2}} + \frac{i}{\sqrt{2}} i \frac{1}{\sqrt{2}} + \frac{i}{\sqrt{2}} \\ \end{pmatrix}\]
QuantumCircuitOpt.RCCXGate
— MethodRCCXGate()
Three-qubit relative (or simplified) Toffoli gate, or the CCX gate. This gate is equivalent to ToffoliGate upto relative phases. The advantage of this gate is that it's implementation requires only three CNot (or CX) gates. Reference: https://arxiv.org/pdf/1508.03273.pdf
Matrix Representation
\[RCCXGate = \begin{pmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & -1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & -i \\ 0 & 0 & 0 & 0 & 0 & 0 & i & 0 \\ \end{pmatrix}\]
QuantumCircuitOpt.RGate
— MethodRGate(θ::Number, ϕ::Number)
A single-qubit rotation gate with two Euler angles, $\theta$ and $\phi$, about the $\cos(\phi)x + \sin(\phi)y$ axis.
Matrix Representation
\[R(\theta, \phi) = e^{-i \theta \left(\cos{\phi} x + \sin{\phi} y\right)} = \begin{pmatrix} \cos{\theta} & -i e^{-i \phi} \sin{\theta} \\ -i e^{i \phi} \sin{\theta} & \cos{\theta} \end{pmatrix}\]
QuantumCircuitOpt.RXGate
— MethodRXGate(θ::Number)
A single-qubit Pauli gate which represents rotation about the X axis.
Matrix Representation
\[\newcommand{\th}{\frac{\theta}{2}} RX(\theta) = exp(-i \th X) = \begin{pmatrix} \cos{\th} & -i\sin{\th} \\ -i\sin{\th} & \cos{\th} \end{pmatrix}\]
QuantumCircuitOpt.RYGate
— MethodRYGate(θ::Number)
A single-qubit Pauli gate which represents rotation about the Y axis.
Matrix Representation
\[\newcommand{\th}{\frac{\theta}{2}} RY(\theta) = exp(-i \th Y) = \begin{pmatrix} \cos{\th} & -\sin{\th} \\ \sin{\th} & \cos{\th} \end{pmatrix}\]
QuantumCircuitOpt.RZGate
— MethodRZGate(θ::Number)
A single-qubit Pauli gate which represents rotation about the Z axis. This gate is also equivalent to U1Gate up to a phase factor, that is, $RZ(\theta) = e^{-i{\theta}/2}U1(\theta)$.
Matrix Representation
\[\newcommand{\th}{\frac{\theta}{2}} RZ(\theta) = exp(-i\th Z) = \begin{pmatrix} e^{-i\th} & 0 \\ 0 & e^{i\th} \end{pmatrix}\]
QuantumCircuitOpt.SGate
— MethodSGate()
Single-qubit S gate, equivalent to U3Gate($0,0,\frac{\pi}{2}$). This gate is also referred to as a Clifford gate, P gate or a square-root of Pauli-ZGate. Historically, this is also called as the phase gate (denoted by P), since it shifts the phase of the one state relative to the zero state.
Matrix Representation
\[S = \begin{pmatrix} 1 & 0 \\ 0 & i \end{pmatrix}\]
QuantumCircuitOpt.SSwapGate
— MethodSSwapGate()
Two-qubit, square root version of the SwapGate.
Circuit Representation
┌────────────┐
q_0: ┤ ├
│ sqrt(Swap) │
q_1: ┤ ├
└────────────┘
Matrix Representation
\[SWAP = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0.5+0.5i & 0.5-0.5i & 0 \\ 0 & 0.5-0.5i & 0.5+0.5i & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}\]
QuantumCircuitOpt.SXGate
— MethodSXGate()
Single-qubit square root of pauli-XGate.
Matrix Representation
\[\sqrt{X} = \frac{1}{2} \begin{pmatrix} 1 + i & 1 - i \\ 1 - i & 1 + i \end{pmatrix}\]
QuantumCircuitOpt.SXdaggerGate
— MethodSXdaggerGate()
Single-qubit hermitian conjugate of the square root of pauli-XGate, or the SXGate.
Matrix Representation
\[\sqrt{X}^{\dagger} = \frac{1}{2} \begin{pmatrix} 1 - i & 1 + i \\ 1 + i & 1 - i \end{pmatrix}\]
QuantumCircuitOpt.SdaggerGate
— MethodSdaggerGate()
Single-qubit, hermitian conjugate of the SGate. This is also an alternative square root of the ZGate.
Matrix Representation
\[S = \begin{pmatrix} 1 & 0 \\ 0 & -i \end{pmatrix}\]
QuantumCircuitOpt.SwapGate
— MethodSwapGate()
Two-qubit, symmetric, SWAP gate.
Circuit Representation
q_0: ─X─
│
q_1: ─X─
Matrix Representation
\[SWAP = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}\]
QuantumCircuitOpt.SycamoreGate
— MethodSycamoreGate()
Two-qubit Sycamore Gate, native to Google's universal quantum processor. Reference: quantumai.google/cirq/google/devices
Circuit Representation
┌──────┐
q_0: ┤ ├
│ SYC │
q_1: ┤ ├
└──────┘
Matrix Representation
\[ SycamoreGate() = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & -i & 0 \\ 0 & -i & 0 & 0 \\ 0 & 0 & 0 & e^{-i \frac{\pi}{6}} \end{pmatrix} \]
QuantumCircuitOpt.TGate
— MethodTGate()
Single-qubit T gate, equivalent to U3Gate($0,0,\frac{\pi}{4}$). This gate is also referred to as a $\frac{\pi}{8}$ gate or as a fourth-root of Pauli-ZGate.
Matrix Representation
\[T = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\pi/4} \end{pmatrix}\]
QuantumCircuitOpt.TdaggerGate
— MethodTdaggerGate()
Single-qubit, hermitian conjugate of the TGate. This gate is equivalent to U3Gate($0,0,-\frac{\pi}{4}$). This gate is also referred to as the fourth-root of Pauli-ZGate.
Matrix Representation
\[T^{\dagger} = \begin{pmatrix} 1 & 0 \\ 0 & e^{-i\pi/4} \end{pmatrix}\]
QuantumCircuitOpt.ToffoliGate
— MethodToffoliGate()
Three-qubit Toffoli gate, also known as the CCX (controlled-controlled-NOT) gate.
Circuit Representation
q_0: ──■──
│
q_1: ──■──
┌─┴─┐
q_2: ┤ X ├
└───┘
Matrix Representation
\[Toffoli = |0 \rangle \langle 0| \otimes I \otimes I + |1 \rangle \langle 1| \otimes CXGate = \begin{pmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 1 & 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 & 1 & 0 \end{pmatrix}\]
QuantumCircuitOpt.U1Gate
— MethodU1Gate(λ::Number)
Universal single-qubit rotation gate with one Euler angle, $\lambda$. U1Gate represents rotation about the Z axis and is the special case of U3Gate, which also known as the PhaseGate. Also note that $U1(\pi) =$ZGate, $U1(\pi/2) =$SGate and $U1(\pi/4) =$TGate.
Matrix Representation
\[U1(\lambda) = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\lambda} \end{pmatrix}\]
QuantumCircuitOpt.U2Gate
— MethodU2Gate(ϕ::Number, λ::Number)
Universal single-qubit rotation gate with two Euler angles, $\phi$ and $\lambda$. U2Gate is the special case of U3Gate.
Matrix Representation
\[U2(\phi, \lambda) = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & -e^{i\lambda} \\ e^{i\phi} & e^{i(\phi+\lambda)} \end{pmatrix}\]
QuantumCircuitOpt.U3Gate
— MethodU3Gate(θ::Number, ϕ::Number, λ::Number)
Universal single-qubit rotation gate with three Euler angles, $\theta$, $\phi$ and $\lambda$.
Matrix Representation
\[\newcommand{\th}{\frac{\theta}{2}} U3(\theta, \phi, \lambda) = \begin{pmatrix} \cos(\th) & -e^{i\lambda}\sin(\th) \\ e^{i\phi}\sin(\th) & e^{i(\phi+\lambda)}\cos(\th) \end{pmatrix}\]
QuantumCircuitOpt.WGate
— MethodWGate()
Two-qubit, W hermitian gate, typically useful to diagonlize the (SwapGate).
Matrix Representation
\[W = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} & 0 \\ 0 & \frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}} & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}\]
QuantumCircuitOpt.XGate
— MethodXGate()
Single-qubit Pauli-X gate ($\sigma_x$), equivalent to U3Gate($\pi,0,\pi$)
Matrix Representation
\[X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}\]
QuantumCircuitOpt.YGate
— MethodYGate()
Single-qubit Pauli-Y gate ($\sigma_y$), equivalent to U3Gate($\pi,\frac{\pi}{2},\frac{\pi}{2}$)
Matrix Representation
\[Y = \begin{pmatrix} 0 & -i \\ i & 0 \end{pmatrix}\]
QuantumCircuitOpt.ZGate
— MethodZGate()
Single-qubit Pauli-Z gate ($\sigma_z$), equivalent to U3Gate($0,0,\pi$)
Matrix Representation
\[Z = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}\]
QuantumCircuitOpt._catch_gate_name_error
— Method_catch_gate_name_error()
Helper function to ensure that the kron_symbol x
does not appear in any of the gate names.
QuantumCircuitOpt._catch_input_gate_errors
— Method_catch_input_gate_errors(gate_type::String, qubit_loc::Vector{Int64}, num_qubits::Int64, input_gate::String)
Given an input gate string, number of qubits of the circuit and the qubit locations for the input gate, this function catches and throws any errors, should the input gate type and qubits are invalid.
QuantumCircuitOpt._determinant_test_for_infeasibility
— Method_determinant_test_for_infeasibility(data::Dict{String,Any})
This function performs determinant-based checks on the target and elementary gates in the given data dictionary to detect potential MIP infeasibility.
QuantumCircuitOpt._get_constraint_slope_intercept
— Method_get_constraint_slope_intercept(vertex1::Vector{<:Number}, vertex2::Vector{<:Number})
Given co-ordinates of two points in a plane, this function returns the slope (m) and intercept (c) of the line joining these two points.
QuantumCircuitOpt._get_elementary_gates_fixed_indices
— Method_get_elementary_gates_fixed_indices(M::Array{T,3} where T <: Number)
Given the set of input elementary gates in real form, this function returns a dictionary of tuples of indices wholse values are fixed in sum_k (z_k*M[:,:,k])
.
QuantumCircuitOpt._get_matrix_product_fixed_indices
— Method_get_matrix_product_fixed_indices(left_matrix_fixed_idx::Dict{Tuple{Int64, Int64}, Any},
right_matrix_fixed_idx::Dict{Tuple{Int64, Int64}, Any},
N::Int64)
Given left and right square matrices of size NxN
, in a dictionary format with tuples of indices whose values are fixed, this function returns a dictionary of tuples of indices wholse values are fixed in left_matrix * right_matrix
.
QuantumCircuitOpt._get_nonzero_idx_of_complex_matrix
— Method_get_nonzero_idx_of_complex_matrix(M::Array{Complex{Float64},2})
A helper function for global phase constraints: Given a complex matrix, M
, this function returns the first non-zero index it locates within M
, either in real or the complex part.
QuantumCircuitOpt._get_nonzero_idx_of_complex_to_real_matrix
— Method_get_nonzero_idx_of_complex_to_real_matrix(M::Array{Float64,2})
A helper function for global phase constraints: Given a complex to real reformulated matrix, M
, using QCO.complex_to_real_gate
, this function returns the first non-zero index it locates within M
.
QuantumCircuitOpt._get_unitary_variables_fixed_indices
— Method_get_unitary_variables_fixed_indices(M::Array{T,3} where T <: Number,
maximum_depth::Int64)
Given a 3D array of real square matrices (representing gates), and a maximum alowable depth, this function returns a dictionary of tuples of indices wholse values are fixed in the unitary matrices for every depth of the circuit.
QuantumCircuitOpt._lt_filter
— Method_lt_filter(a::Tuple{<:Number, <:Number}, b::Tuple{<:Number, <:Number})
Utility function for sorting step in convex_hull
. Given two points, a
and b
, this function returns true if a
has larger polar angle (counterclock-wise direction) than b
w.r.t. first point chull_p1
.
QuantumCircuitOpt._orientation
— Method_orientation(x::Tuple{<:Number, <:Number}, y::Tuple{<:Number, <:Number}, z::Tuple{<:Number, <:Number})
Utility function for convex_hull
. Given an ordered triplet, this function returns if three points are collinear, oriented in clock-wise or anticlock-wise direction.
QuantumCircuitOpt._parse_gate_string
— Method_parse_gate_string(s::String)
Given a string representing a single gate with qubit numbers separated by symbol _
, this function parses and returns the vector of qubits on which the input gate is located. For example, if the input string is CRX_2_3
, the output will be Vector{Int64}([2,3])
.
QuantumCircuitOpt._parse_gates_with_kron_symbol
— Method_parse_gates_with_kron_symbol(s::String)
Given a string with gates separated by kronecker symbols x
, this function parses and returns the vector of gates. For example, if the input string is H_1xCNot_2_3xT_4
, the output will be Vector{String}(["H_1", "CNot_2_3", "T_4"])
.
QuantumCircuitOpt.auxiliary_variable_bounds
— Methodauxiliary_variable_bounds(v::Array{JuMP.VariableRef,1})
Given a vector of JuMP variables (maximum 4 variables), this function returns the worst-case bounds, the product of these input variables can admit.
QuantumCircuitOpt.build_QCModel_result
— MethodQuantumCircuitOpt.complex_to_real_gate
— Methodcomplex_to_real_gate(M::Array{Complex{Float64},2})
Given a complex-valued two-dimensional quantum gate of size NxN, this function returns a real-valued gate of dimensions 2Nx2N.
QuantumCircuitOpt.convex_hull
— Methodconvex_hull(points::Vector{T}) where T<:Tuple{Number, Number}
Graham's scan algorithm to compute the convex hull of a finite set of n
points in a plane with time complexity O(n*log(n))
. Given a vector of tuples of co-ordinates, this function returns a vector of tuples of co-ordinates which form the convex hull of the given set of points.
Sources: https://doi.org/10.1016/0020-0190(72)90045-2 https://en.wikipedia.org/wiki/Graham_scan
QuantumCircuitOpt.eliminate_nonunique_gates
— Methodeliminate_nonunique_gates(gates_dict::Dict{String, Any})
QuantumCircuitOpt.fSwapGate
— MethodfSwapGate()
Two-qubit, symmetric, Fermionic SWAP gate, that swaps adjacent fermionic modes in the Jordan-Wigner representation. Because the qubits represent identical fermions, swapping two particles applies a -1 phase to the state.
Reference: https://doi.org/10.22331/q-2018-12-21-114
Matrix Representation
\[fSWAP = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & -1 \end{pmatrix}\]
QuantumCircuitOpt.gate_element_bounds
— Methodgate_element_bounds(M::Array{Float64,3})
Given a set of elementary gates, {G1, G2, ... ,Gn}
, this function evaluates the range of every co-ordinate of the superimposed gates, over all possible gates.
QuantumCircuitOpt.get_commutative_gate_pairs
— Methodget_commutative_gate_pairs(M::Dict{String,Any}; decomposition_type::String; identity_in_pairs = true)
Given a dictionary of elementary quantum gates, this function returns all pairs of commuting gates. Optional argument, identity_pairs
can be set to false
if identity matrix need not be part of the commuting pairs.
QuantumCircuitOpt.get_data
— Methodget_data(params::Dict{String, Any}; eliminate_identical_gates = true)
Given the user input params
dictionary, this function returns a dictionary of processed data which contains all the necessary information to formulate the optimization model for the circuit design problem.
QuantumCircuitOpt.get_default_options
— Methodget_default_options()
This function returns the default options for building the struct QCModelOptions
.
QuantumCircuitOpt.get_depth_compressed_circuit
— Methodget_depth_compressed_circuit(num_qubits::Int64, gates_sol::Array{String,1})
Given the number of qubits and the sequence of gates from the solution, this function returns a decomposition of gates after compressing adjacent pair of gates represented on two separate qubits. For example, gates H1 and H2 appearing in a sequence will be compressed to H1xH2 (kron(H1,H2)). This functionality is currently supported only for two qubit circuits and gates without angle parameters.
QuantumCircuitOpt.get_full_sized_kron_gate
— Methodget_full_sized_kron_gate(input::String, num_qubits::Int64)
Given an input string with kronecker symbols representing the gate and number of qubits of the circuit, this function returns a full-sized gate with respect to the input number of qubits. For example, if num_qubits = 3
and the input gate in I_1xT_2xH_3
, then this function returns IGate⨂TGate⨂HGate
, where IGate, TGate and HGate are single-qubit Identity, T and Hadamard gates, respectively. Two qubit gates can also be used as one of the input gates, for ex. I_1xCV_2_3xH_4
. Note that this function currently does not support an input gate parametrized with Euler angles.
QuantumCircuitOpt.get_idempotent_gates
— Methodget_idempotent_gates(M::Dict{String,Any}, decomposition_type::String)
Given the dictionary of complex quantum gates, this function returns the indices of matrices which are self-idempotent or idempotent with other set of input gates, excluding the Identity gate.
QuantumCircuitOpt.get_input_circuit_dict
— Methodget_input_circuit_dict(input_circuit::Vector{Tuple{Int64,String}}, params::Dict{String,Any})
Given the user input circuit which serves as a warm-start to the optimization model, and user input params dictionary, this function outputs the post-processed dictionary of the input circuit which is used by the optimization model.
QuantumCircuitOpt.get_involutory_gates
— Methodget_involutory_gates(M::Dict{String,Any})
Given the dictionary of complex gates G_1, G_2, ..., G_n
, this function returns the indices of these gates which are involutory, i.e, G_i^2 = Identity
, excluding the Identity gate.
QuantumCircuitOpt.get_objective_bound
— MethodQuantumCircuitOpt.get_objective_value
— MethodQuantumCircuitOpt.get_redundant_gate_product_pairs
— Methodget_redundant_gate_product_pairs(M::Dict{String,Any}, decomposition_type::String)
Given a dictionary of elementary quantum gates, this function returns all pairs of gates whose product is one of the input elementary gates. For example, let G_basis = {G1, G2, G3}
be the elementary gates. If G1*G2 ∈ G_basis
, then (1,2)
is considered as a redundant pair.
QuantumCircuitOpt.get_target_gate
— Methodget_target_gate(params::Dict{String, Any}, are_elementary_gates_real::Bool)
Given the user input params
dictionary and a boolean if all the input elementary gates are real, this function returns the corresponding real version of the target gate.
QuantumCircuitOpt.get_unitary
— Methodget_unitary(input::String, num_qubits::Int64; angle = nothing)
Given an input string representing the gate and number of qubits of the circuit, this function returns a full-sized gate with respect to the input number of qubits. For example, if num_qubits = 3
and the input gate in H_3
(Hadamard on third qubit), then this function returns IGate ⨂ IGate ⨂ HGate
, where IGate and HGate are single qubit Identity and Hadamard gates, respectively. Note that angle
vector is an optional input which is necessary when the input gate is parametrized by Euler angles.
QuantumCircuitOpt.iSwapGate
— MethodiSwapGate()
Two-qubit, symmetric and clifford, iSWAP gate. This is an entangling swapping gate where the qubits obtain a phase of $i$ if the state of the qubits is swapped.
Circuit Representation
q_0: ─⨂─
│
q_1: ─⨂─
Minimum depth representation
┌───┐ ┌───┐ ┌───┐
q_0: ─┤ X ├──■──┤ S ├─┤ X ├─
└─┬─┘┌─┴─┐└───┘ └─┬─┘
q_1: ───■──┤ X ├────────■──
└───┘
Matrix Representation
\[iSWAP = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & i & 0 \\ 0 & i & 0 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}\]
QuantumCircuitOpt.is_gate_real
— Methodis_gate_real(M::Array{Complex{Float64},2})
Given a complex-valued quantum gate, M, this function returns if M has purely real parts or not as it's elements.
QuantumCircuitOpt.is_multi_qubit_gate
— Methodis_multi_qubit_gate(gate::String)
Given the input gate string, this function returns a boolean if the input gate is a multi qubit gate or not. For example, for a 2-qubit gate CRZ_1_2
, output is true
.
QuantumCircuitOpt.isapprox_global_phase
— Methodisapprox_global_phase(M1::Array{Complex{Float64},2}, M2::Array{Complex{Float64},2}; tol_0 = 1E-4)
Given two complex matrices, M1
and M2
, this function returns a boolean if these matrices are equivalent up to a global phase.
QuantumCircuitOpt.kron_single_qubit_gate
— Methodkron_single_qubit_gate(num_qubits::Int64, M::Array{Complex{Float64},2}, qubit_loc::String)
Given number of qubits of the circuit, the complex-valued one-qubit gate and the qubit location ("q1","q2',"q3",...), this function returns a full-sized gate after applying appropriate kronecker products. This function supports any number integer-valued qubits.
QuantumCircuitOpt.kron_two_qubit_gate
— Methodkron_two_qubit_gate(num_qubits::Int64, M::Array{Complex{Float64},2}, c_qubit_loc::String, t_qubit_loc::String)
Given number of qubits of the circuit, the complex-valued two-qubit gate and the control and target qubit locations ("q1","q2',"q3",...), this function returns a full-sized gate after applying appropriate kronecker products. This function supports any number of integer-valued qubits.
QuantumCircuitOpt.logger_config!
— Methodallows the user to set the logging level without the need to add Memento
QuantumCircuitOpt.multi_controlled_gate
— Methodmulti_controlled_gate(target_gate::Array{Complex{Float64},2},
control_qubits::Vector{Int64},
target_qubit::Int64,
num_qubits::Int64)
Given a single-qubit complex-valued target gate, a vector of control qubits (control_qubits
), and a target qubit, this function returns a complex-valued multi-controlled gate (MCT) representable in num_qubits
. The states of control qubits can be any wire preceeding or succeeding the location of the input gate's target qubit. Here are a few examples: (a) ToffoliGate = multicontrolledgate(XGate(), [1,2], 3, 3) (b) Reverse ToffoliGate with one ancilla = multicontrolledgate(XGate(), [2,3], 1, 4) (c) CHRevGate = multicontrolledgate(HGate(), [2], 1, 2) (d) CCZGate = multicontrolledgate(ZGate(), [1,2], 3, 3) (e) CU3Gate(θ,ϕ,λ) = multicontrolledgate(U3Gate(θ,ϕ,λ), [1], 2, 2)
Notes: For any single qubit target gate, an MCT gate, controlled off 𝑖 and targeting 𝑗, is given by 1^⊗𝑁 + 1⊗(𝑖−1) ⊗ |1⟩⟨1| ⊗ {1^⊗(𝑗−𝑖−1)} ⊗ (target_gate − I^⊗1) ⊗ {1^⊗(𝑁−𝑗)}
QuantumCircuitOpt.multi_qubit_global_gate
— Methodmulti_qubit_global_gate(num_qubits::Int64, M::Array{Complex{Float64},2})
Given number of qubits of the circuit and any complex-valued one-qubit gate (G
) in it's matrix form, this function returns a multi-qubit global gate, by applying
Gsimultaneously on all the qubits. For example, given
Gand
num_qubits = 3, this function returns
G⨂G⨂G`.
QuantumCircuitOpt.optimize_QCModel!
— MethodQuantumCircuitOpt.real_to_complex_gate
— Methodreal_to_complex_gate(M::Array{Complex{Float64},2})
Given a real-valued two-dimensional quantum gate of size 2Nx2N, this function returns a complex-valued gate of size NxN, if the input gate is in a valid complex form.
QuantumCircuitOpt.relaxation_bilinear
— Methodrelaxation_bilinear(m::JuMP.Model, xy::JuMP.VariableRef, x::JuMP.VariableRef, y::JuMP.VariableRef)
general relaxation of binlinear term (McCormick), which can be used to obtain specific variants in partiuclar cases of variables (like binary)
z >= JuMP.lower_bound(x)*y + JuMP.lower_bound(y)*x - JuMP.lower_bound(x)*JuMP.lower_bound(y)
z >= JuMP.upper_bound(x)*y + JuMP.upper_bound(y)*x - JuMP.upper_bound(x)*JuMP.upper_bound(y)
z <= JuMP.lower_bound(x)*y + JuMP.upper_bound(y)*x - JuMP.lower_bound(x)*JuMP.upper_bound(y)
z <= JuMP.upper_bound(x)*y + JuMP.lower_bound(y)*x - JuMP.upper_bound(x)*JuMP.lower_bound(y)
QuantumCircuitOpt.round_complex_values
— Methodround_complex_values(M::Array{Complex{Float64},2})
Given a complex-valued matrix, this function returns a complex-valued matrix which rounds the values closest to 0, 1 and -1. This is useful to avoid numerical issues.
QuantumCircuitOpt.round_real_value
— Methodround_real_value(x::T) where T <: Number
Given a real-valued number, this function returns a real-value which rounds the values closest to 0, 1 and -1.
QuantumCircuitOpt.silence
— MethodSuppresses information and warning messages output by QuantumCircuitOpt, for fine grained control use of the Memento package
QuantumCircuitOpt.unique_idx
— Methodunique_idx(x::AbstractArray{T})
This function returns the indices of unique elements in a given array of scalar or vector inputs. Overall, this function computes faster than Julia's built-in findfirst
command.
QuantumCircuitOpt.unique_matrices
— Methodunique_matrices(M::Array{Float64, 3})
This function returns the unique set of matrices and the corresponding indices of unique matrices from the given set of matrices.
QuantumCircuitOpt.validate_circuit_decomposition
— Methodvalidate_circuit_decomposition(data::Dict{String, Any}, id_sequence::Array{Int64,1})
This function validates the circuit decomposition if it is indeed exact with respect to the specified target gate.
QuantumCircuitOpt.variable_domain
— Methodvariable_domain(var::JuMP.VariableRef)
Computes the valid domain of a given JuMP variable taking into account bounds and the varaible's implicit bounds (e.g. binary).
QuantumCircuitOpt.visualize_solution
— Methodvisualize_solution(results::Dict{String, Any}, data::Dict{String, Any}; gate_sequence = false)
Given dictionaries of results and data, and assuming that the optimization model had a feasible solution, this function aids in visualizing the optimal circuit decomposition.