QuantumCircuitOpt Function References

QuantumCircuitOpt.Gate — Type
Gate

The struct, Gate, holds the label, the qubits and the matrix form of the gate, primarily for post-optimization.

source
QuantumCircuitOpt.GateData — Type
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.QCModelOptions — Type
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.QuantumCircuitModel — Type
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.CCZGate — Method
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.CHGate — Method
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.CHRevGate — Method
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.CNotGate — Method
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.CNotRevGate — Method
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.CRXGate — Method
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.CRXRevGate — Method
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.CRYGate — Method
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.CRYRevGate — Method
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.CRZGate — Method
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.CRZRevGate — Method
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.CSGate — Method
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.CSXGate — Method
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.CSXRevGate — Method
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.CSdaggerGate — Method
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.CSwapGate — Method
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.CTGate — Method
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.CTdaggerGate — Method
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.CU3Gate — Method
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.CU3RevGate — Method
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.CVGate — Method
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.CVRevGate — Method
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.CVdaggerGate — Method
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.CVdaggerRevGate — Method
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.CXGate — Method
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.CXRevGate — Method
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.CYGate — Method
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.CYRevGate — Method
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.CZGate — Method
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.CiSwapGate — Method
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.DCXGate — Method
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.GRGate — Method
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.GroverDiffusionGate — Method
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.HGate — Method
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.IGate — Method
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.MGate — Method
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.MargolusGate — Method
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.PeresGate — Method
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.PhaseGate — Method
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.QFT2Gate — Method
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.QFT3Gate — Method
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.RCCXGate — Method
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.RGate — Method
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.RXGate — Method
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.RYGate — Method
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.RZGate — Method
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.SGate — Method
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.SSwapGate — Method
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.SXGate — Method
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.SXdaggerGate — Method
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.SdaggerGate — Method
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.SwapGate — Method
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.SycamoreGate — Method
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.TGate — Method
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.TdaggerGate — Method
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.ToffoliGate — Method
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.U1Gate — Method
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.U2Gate — Method
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.U3Gate — Method
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.WGate — Method
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.XGate — Method
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.YGate — Method
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.ZGate — Method
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_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.

source
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.

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

source
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.

source
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.

source
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.

source
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.

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

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

source
QuantumCircuitOpt.auxiliary_variable_bounds — Method
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.circuit_unitary — Method
circuit_unitary(layers::Vector{Vector{Gate}})

Returns the overall unitary matrix representing a quantum circuit by multiplying the unitary matrices of each layer (left to right).

source
QuantumCircuitOpt.complex_to_real_gate — Method
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.compress_circuit — Method
compress_circuit(gates::Vector{Gate}, num_qubits::Int)

This function compresses a quantum circuit by placing gates into the earliest possible layer where they can be executed in parallel. Gates can be placed in the same layer if they operate on disjoint sets of qubits. If no suitable layer is found, a new layer is created. This function reduces circuit depth while preserving the total number of gates and the logical operation.

source
QuantumCircuitOpt.fSwapGate — Method
fSwapGate()

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

source
QuantumCircuitOpt.gate_element_bounds — Method
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_pairs — Method
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_data — Method
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_full_sized_kron_gate — Method
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_gates — Method
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_dict — Method
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_gates — Method
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_pairs — Method
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_gate — Method
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.iSwapGate — Method
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_real — Method
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.isapprox_global_phase — Method
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_layer — Method
kron_layer(layer::Vector{Gate}, num_qubits::Int)::String

Converts a layer of quantum gates into a human-readable string representation. The function formats the layer as a tensor product (⊗) of gates, with identity gates (I) inserted for qubits that don't have an explicit gate in the layer.

source
QuantumCircuitOpt.kron_single_qubit_gate — Method
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_gate — Method
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_controlled_gate — Method
multi_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^⊗(𝑁−𝑗)}

source
QuantumCircuitOpt.multi_qubit_global_gate — Method
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.print_circuit — Function
print_circuit(circuit_layers::Vector{Vector{Gate}}, num_qubits::Int)

Print a quantum circuit in a human-readable format, showing each layer of gates.

source
QuantumCircuitOpt.real_to_complex_gate — Method
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_bilinear — Method
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_values — Method
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_value — Method
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.silence — Method

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

source
QuantumCircuitOpt.unique_idx — Method
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_matrices — Method
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.unitary — Method
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.variable_domain — Method
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_solution — Method
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