Documentation Index Fetch the complete documentation index at: https://prod-mint.classiq.io/llms.txt
Use this file to discover all available pages before exploring further.
View on GitHub Open this notebook in GitHub to run it yourself
The Classiq platform provides many standard gates.
Some key standard gates are shown here in detail.
All gates are covered in the reference manual .
Single Qubit Gates
An example is given for X X X gate.
The gates I I I , X X X , Y Y Y , Z Z Z , H H H , T T T are used in the same way.
For example: X
Function: X
Arguments:
@qfunc
def main ( q : Output[QBit]):
allocate(q)
X(q)
qmod = create_model(main)
qprog = synthesize(qmod)
Single Qubit Rotation Gates
An example is given for R Z RZ RZ gate.
The gates R X RX RX , R Y RY R Y , R Z RZ RZ are used in the same way except for parameter name.
Parameter names for different rotation gates
RX: theta
RY: theta
RZ: phi
For example: RZ
R Z ( θ ) = ( e − i θ 2 0 0 e i θ 2 ) \begin{split}RZ(\theta) = \begin{pmatrix}
{e^{-i\frac{\theta}{2}}} & 0 \\
0 & {e^{i\frac{\theta}{2}}} \\
\end{pmatrix}\end{split} RZ ( θ ) = ( e − i 2 θ 0 0 e i 2 θ )
Function: RZ
Arguments:
theta: CReal
target: QBit
@qfunc
def main ( q : Output[QBit]):
allocate(q)
theta = 1.9
RZ(theta, q)
qmod = create_model(main)
qprog = synthesize(qmod)
R Gate
Rotation by θ \theta θ around the c o s ( ϕ ) X + s i n ( ϕ ) Y cos(\phi)X + sin(\phi)Y cos ( ϕ ) X + s in ( ϕ ) Y axis.
R ( θ , ϕ ) = ( c o s ( θ 2 ) − i e − i ϕ s i n ( θ 2 ) − i e i ϕ s i n ( θ 2 ) c o s ( θ 2 ) ) \begin{split}R(\theta, \phi) = \begin{pmatrix}
cos(\frac{\theta}{2}) & -ie^{-i\phi}sin(\frac{\theta}{2}) \\
-ie^{i\phi}sin(\frac{\theta}{2}) & cos(\frac{\theta}{2}) \\
\end{pmatrix}\end{split} R ( θ , ϕ ) = ( cos ( 2 θ ) − i e i ϕ s in ( 2 θ ) − i e − i ϕ s in ( 2 θ ) cos ( 2 θ ) )
Parameters:
theta: CReal
phi: CReal
target: QBit
@qfunc
def main ( q : Output[QBit]):
allocate(q)
theta = 1
phi = 2
R(theta, phi, q)
qmod = create_model(main)
qprog = synthesize(qmod)
Phase Gate
Rotation about the Z axis by λ \lambda λ with global phase of λ 2 \frac{\lambda}{2} 2 λ .
P H A S E ( λ ) = ( 1 0 0 e i λ ) \begin{split}PHASE(\lambda) = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\lambda} \end{pmatrix}\end{split} P H A SE ( λ ) = ( 1 0 0 e iλ )
Parameters:
theta: CReal
target: QBit
@qfunc
def main ( q : Output[QBit]):
allocate(q)
theta = 1
PHASE(theta, q)
qmod = create_model(main)
qprog = synthesize(qmod)
Double Qubits Rotation Gates
An example is given for R Z Z RZZ RZZ gate.
The gates R X X RXX RXX , R Y Y RYY R YY , R Z Z RZZ RZZ are used in the same way.
RZZ Gate
Rotation about ZZ.
R Z Z ( θ ) = ( e − i θ 2 0 0 0 0 e i θ 2 0 0 0 0 e i θ 2 0 0 0 0 e − i θ 2 ) \begin{split}RZZ(\theta) = \begin{pmatrix}
{e^{-i\frac{\theta}{2}}} & 0 & 0 & 0 \\
0 & {e^{i\frac{\theta}{2}}} & 0 & 0 \\
0 & 0 & {e^{i\frac{\theta}{2}}} & 0 \\
0 & 0 & 0 & {e^{-i\frac{\theta}{2}}} \\
\end{pmatrix}\end{split} RZZ ( θ ) = e − i 2 θ 0 0 0 0 e i 2 θ 0 0 0 0 e i 2 θ 0 0 0 0 e − i 2 θ
Parameters:
theta: CReal
target: QArray[QBit]
@qfunc
def main ( q : Output[QArray]):
allocate( 2 , q)
theta = 1
RZZ(theta, q)
qmod = create_model(main)
qprog = synthesize(qmod)
Controlled Gates
An example is given for C X CX CX gate.
The gates C X CX CX , C Y CY C Y , C Z CZ CZ , C H CH C H , C S X CSX CSX , C C X CCX CCX are used in a similar way.
In C C X CCX CCX Gate the ctrl_state parameter receives a value suitable for 2 control qubits. for example: "01".
CX Gate
The Controlled X X X gate.
Applies X X X Gate on the target qubit, based on the state of the control qubit
(by default if the controlled state is ∣ 1 ⟩ |1\rangle ∣1 ⟩ ).
C X = ( 1 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 ) \begin{split}CX = \begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & 0 & 1 \\
0 & 0 & 1 & 0 \\
\end{pmatrix}\end{split} CX = 1 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0
Parameters:
control: QBit
target: QBit
@qfunc
def main ( q_target : Output[QBit], q_control : Output[QBit]):
allocate(q_target)
allocate(q_control)
CX(q_control, q_target)
qmod = create_model(main)
qprog = synthesize(qmod)
Controlled Rotations
An example is given for C R X CRX CRX gate.
The gates C R X CRX CRX , C R Y CRY CR Y , C R Z CRZ CRZ , CPhase are used in the same way.
CRX Gate
Controlled rotation around the X axis.
C R X ( θ ) = ( 1 0 0 0 0 1 0 0 0 0 cos ( θ 2 ) − i sin ( θ 2 ) 0 0 − i sin ( θ 2 ) cos ( θ 2 ) ) \begin{split}CRX(\theta) = \begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & \cos(\frac{\theta}{2}) & -i\sin(\frac{\theta}{2}) \\
0 & 0 & -i\sin(\frac{\theta}{2}) & \cos(\frac{\theta}{2}) \\
\end{pmatrix}\end{split} CRX ( θ ) = 1 0 0 0 0 1 0 0 0 0 cos ( 2 θ ) − i sin ( 2 θ ) 0 0 − i sin ( 2 θ ) cos ( 2 θ )
Parameters:
theta: CReal
control: QBit
target: QBit
@qfunc
def main ( q_target : Output[QBit], q_control : Output[QBit]):
allocate(q_target)
allocate(q_control)
theta = 1
CRX(theta, q_control, q_target)
qmod = create_model(main)
qprog = synthesize(qmod)
Swap Gate
Swaps between two qubit states.
S W A P = ( 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 ) \begin{split}SWAP = \begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & 0 & 1 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & 0 & 1 \\
\end{pmatrix}\end{split} S W A P = 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1
Parameters:
@qfunc
def main ( q1 : Output[QBit], q2 : Output[QBit]):
allocate(q1)
allocate(q2)
SWAP(q1, q2)
qmod = create_model(main)
qprog = synthesize(qmod)
U Gate
The single-qubit gate applies phase and rotation with three Euler angles.
Matrix representation:
U ( γ , ϕ , θ , λ ) = e i γ ( cos ( θ 2 ) − e i λ sin ( θ 2 ) e i ϕ sin ( θ 2 ) e i ( ϕ + λ ) cos ( θ 2 ) ) U(\gamma,\phi,\theta,\lambda) = e^{i\gamma}\begin{pmatrix}
\cos(\frac{\theta}{2}) & -e^{i\lambda}\sin(\frac{\theta}{2}) \\
e^{i\phi}\sin(\frac{\theta}{2}) & e^{i(\phi+\lambda)}\cos(\frac{\theta}{2}) \\
\end{pmatrix} U ( γ , ϕ , θ , λ ) = e iγ ( cos ( 2 θ ) e i ϕ sin ( 2 θ ) − e iλ sin ( 2 θ ) e i ( ϕ + λ ) cos ( 2 θ ) )
Parameters:
theta: CReal
phi: CReal
lam: CReal
gam: CReal
target: QBit
@qfunc
def main ( q : Output[QBit]):
allocate(q)
theta = 1
phi = 2
lam = 1.5
gam = 1.1
U(theta, phi, lam, gam, q)
qmod = create_model(main)
qprog = synthesize(qmod)