QuantumCircuitOpt Function References

QuantumCircuitOpt.GateDataType
GateData

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.

source
QuantumCircuitOpt.QCModelOptionsType
QCModelOptions

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.

source
QuantumCircuitOpt.QuantumCircuitModelType
QuantumCircuitModel

The composite mutable struct, QuantumCircuitModel, holds dictionaries for input data, abstract JuMP model for optimization, variable references and result from solving the JuMP model.

source
QuantumCircuitOpt.CCZGateMethod
CCZGate()

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

source
QuantumCircuitOpt.CHGateMethod
CHGate()

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

source
QuantumCircuitOpt.CHRevGateMethod
CHRevGate()

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

source
QuantumCircuitOpt.CNotGateMethod
CNotGate()

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

source
QuantumCircuitOpt.CNotRevGateMethod
CNotRevGate()

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

source
QuantumCircuitOpt.CRXGateMethod
CRXGate(θ::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}\]

source
QuantumCircuitOpt.CRXRevGateMethod
CRXRevGate(θ::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}\]

source
QuantumCircuitOpt.CRYGateMethod
CRYGate(θ::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}\]

source
QuantumCircuitOpt.CRYRevGateMethod
CRYRevGate(θ::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}\]

source
QuantumCircuitOpt.CRZGateMethod
CRZGate(θ::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}\]

source
QuantumCircuitOpt.CRZRevGateMethod
CRZRevGate(θ::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}\]

source
QuantumCircuitOpt.CSGateMethod
CSGate()

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

source
QuantumCircuitOpt.CSXGateMethod
CSXGate()

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

source
QuantumCircuitOpt.CSXRevGateMethod
CSXRevGate()

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

source
QuantumCircuitOpt.CSdaggerGateMethod
CSdaggerGate()

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

source
QuantumCircuitOpt.CSwapGateMethod
CSwapGate()

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

source
QuantumCircuitOpt.CTGateMethod
CTGate()

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

source
QuantumCircuitOpt.CTdaggerGateMethod
CTdaggerGate()

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

source
QuantumCircuitOpt.CU3GateMethod
CU3Gate(θ::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}\]

source
QuantumCircuitOpt.CU3RevGateMethod
CU3RevGate(θ::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}\]

source
QuantumCircuitOpt.CVGateMethod
CVGate()

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

source
QuantumCircuitOpt.CVRevGateMethod
CVRevGate()

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

source
QuantumCircuitOpt.CVdaggerGateMethod
CVdaggerGate()

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

source
QuantumCircuitOpt.CVdaggerRevGateMethod
CVdaggerRevGate()

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

source
QuantumCircuitOpt.CXGateMethod
CXGate()

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

source
QuantumCircuitOpt.CXRevGateMethod
CXRevGate()

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

source
QuantumCircuitOpt.CYGateMethod
CYGate()

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

source
QuantumCircuitOpt.CYRevGateMethod
CYRevGate()

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

source
QuantumCircuitOpt.CZGateMethod
CZGate()

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

source
QuantumCircuitOpt.CiSwapGateMethod
CiSwapGate()

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

source
QuantumCircuitOpt.DCXGateMethod
DCXGate()

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

source
QuantumCircuitOpt.GRGateMethod
GRGate(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) \]

source
QuantumCircuitOpt.GroverDiffusionGateMethod
GroverDiffusionGate()

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

source
QuantumCircuitOpt.HGateMethod
HGate()

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

source
QuantumCircuitOpt.IGateMethod
IGate(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}\]

source
QuantumCircuitOpt.MGateMethod
MGate()

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

source
QuantumCircuitOpt.MargolusGateMethod
MargolusGate()

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

source
QuantumCircuitOpt.PeresGateMethod
PeresGate()

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

source
QuantumCircuitOpt.PhaseGateMethod
PhaseGate(λ::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}\]

source
QuantumCircuitOpt.QFT2GateMethod
QFT2Gate()

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

source
QuantumCircuitOpt.QFT3GateMethod
QFT3Gate()

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

source
QuantumCircuitOpt.RCCXGateMethod
RCCXGate()

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

source
QuantumCircuitOpt.RGateMethod
RGate(θ::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}\]

source
QuantumCircuitOpt.RXGateMethod
RXGate(θ::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}\]

source
QuantumCircuitOpt.RYGateMethod
RYGate(θ::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}\]

source
QuantumCircuitOpt.RZGateMethod
RZGate(θ::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}\]

source
QuantumCircuitOpt.SGateMethod
SGate()

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

source
QuantumCircuitOpt.SSwapGateMethod
SSwapGate()

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

source
QuantumCircuitOpt.SXGateMethod
SXGate()

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

source
QuantumCircuitOpt.SXdaggerGateMethod
SXdaggerGate()

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

source
QuantumCircuitOpt.SdaggerGateMethod
SdaggerGate()

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

source
QuantumCircuitOpt.SwapGateMethod
SwapGate()

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

source
QuantumCircuitOpt.SycamoreGateMethod
SycamoreGate()

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

source
QuantumCircuitOpt.TGateMethod
TGate()

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

source
QuantumCircuitOpt.TdaggerGateMethod
TdaggerGate()

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

source
QuantumCircuitOpt.ToffoliGateMethod
ToffoliGate()

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

source
QuantumCircuitOpt.U1GateMethod
U1Gate(λ::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}\]

source
QuantumCircuitOpt.U2GateMethod
U2Gate(ϕ::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}\]

source
QuantumCircuitOpt.U3GateMethod
U3Gate(θ::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}\]

source
QuantumCircuitOpt.WGateMethod
WGate()

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

source
QuantumCircuitOpt.XGateMethod
XGate()

Single-qubit Pauli-X gate ($\sigma_x$), equivalent to U3Gate($\pi,0,\pi$)

Matrix Representation

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

source
QuantumCircuitOpt.YGateMethod
YGate()

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

source
QuantumCircuitOpt.ZGateMethod
ZGate()

Single-qubit Pauli-Z gate ($\sigma_z$), equivalent to U3Gate($0,0,\pi$)

Matrix Representation

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

source
QuantumCircuitOpt._catch_input_gate_errorsMethod
_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.

source
QuantumCircuitOpt._determinant_test_for_infeasibilityMethod
_determinant_test_for_infeasibility(data::Dict{String,Any})

Given the processed data dictionary, this function performs a few simple tests based on the determinant values of elementary and target gates to detect MIP infeasibility.

source
QuantumCircuitOpt._get_constraint_slope_interceptMethod
_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.

source
QuantumCircuitOpt._get_elementary_gates_fixed_indicesMethod
_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]).

source
QuantumCircuitOpt._get_matrix_product_fixed_indicesMethod
_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.

source
QuantumCircuitOpt._get_nonzero_idx_of_complex_matrixMethod
_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.

source
QuantumCircuitOpt._get_nonzero_idx_of_complex_to_real_matrixMethod
_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.

source
QuantumCircuitOpt._get_unitary_variables_fixed_indicesMethod
_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.

source
QuantumCircuitOpt._lt_filterMethod
_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.

source
QuantumCircuitOpt._orientationMethod
_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.

source
QuantumCircuitOpt._parse_gate_stringMethod
_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]).

source
QuantumCircuitOpt._parse_gates_with_kron_symbolMethod
_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"]).

source
QuantumCircuitOpt.auxiliary_variable_boundsMethod
auxiliary_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.

source
QuantumCircuitOpt.complex_to_real_gateMethod
complex_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.

source
QuantumCircuitOpt.controlled_gateMethod
controlled_gate(gate::Array{Complex{Float64},2}, num_control_qubits::Int64; reverse = false)

Given a complex-valued matrix (gate) of N qubits, and number of control qubits (NCQ), this function returns a complex-valued controlled gate representable in N+NCQ qubits. The state of control qubit is applied NCQ times to every wire preceeding the location of the input gate. Note that this function does not account for the actual location of the controlled gate in the circuit. Here are a few examples: (a) ToffoliGate = controlledgate(XGate(), 2) = controlledgate(CNotGate(), 1) (b) CCCCCZGate = controlled_gate(ZGate(), 5) (c) TCCGate = controlled(TGate(), 2, reverse = true)

source
QuantumCircuitOpt.convex_hullMethod
convex_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

source
QuantumCircuitOpt.gate_element_boundsMethod
gate_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.

source
QuantumCircuitOpt.get_commutative_gate_pairsMethod
get_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.

source
QuantumCircuitOpt.get_dataMethod
get_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.

source
QuantumCircuitOpt.get_depth_compressed_circuitMethod
get_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.

source
QuantumCircuitOpt.get_full_sized_kron_gateMethod
get_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.

source
QuantumCircuitOpt.get_idempotent_gatesMethod
get_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.

source
QuantumCircuitOpt.get_input_circuit_dictMethod
get_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.

source
QuantumCircuitOpt.get_involutory_gatesMethod
get_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.

source
QuantumCircuitOpt.get_redundant_gate_product_pairsMethod
get_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.

source
QuantumCircuitOpt.get_target_gateMethod
get_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.

source
QuantumCircuitOpt.get_unitaryMethod
get_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.

source
QuantumCircuitOpt.iSwapGateMethod
iSwapGate()

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

source
QuantumCircuitOpt.is_gate_realMethod
is_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.

source
QuantumCircuitOpt.is_multi_qubit_gateMethod
is_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.

source
QuantumCircuitOpt.isapprox_global_phaseMethod
isapprox_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.

source
QuantumCircuitOpt.kron_single_qubit_gateMethod
kron_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.

source
QuantumCircuitOpt.kron_two_qubit_gateMethod
kron_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.

source
QuantumCircuitOpt.multi_qubit_global_gateMethod
multi_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 applyingGsimultaneously on all the qubits. For example, givenGandnum_qubits = 3, this function returnsG⨂G⨂G`.

source
QuantumCircuitOpt.real_to_complex_gateMethod
real_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.

source
QuantumCircuitOpt.relaxation_bilinearMethod
relaxation_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)
source
QuantumCircuitOpt.round_complex_valuesMethod
round_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.

source
QuantumCircuitOpt.round_real_valueMethod
round_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.

source
QuantumCircuitOpt.silenceMethod

Suppresses information and warning messages output by QuantumCircuitOpt, for fine grained control use of the Memento package

source
QuantumCircuitOpt.unique_idxMethod
unique_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.

source
QuantumCircuitOpt.unique_matricesMethod
unique_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.

source
QuantumCircuitOpt.variable_domainMethod
variable_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).

source
QuantumCircuitOpt.visualize_solutionMethod
visualize_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.

source