mimiqcircuits.operations.gates.standard.csx

Controlled-SX and Controlled-SXDG gates.

Classes

GateCSX([num_controls, operation])

Two qubit Controled-SX gate.

GateCSXDG([num_controls, operation])

Two qubit \({CSX}^\dagger\) gate.

class mimiqcircuits.operations.gates.standard.csx.GateCSX(num_controls=None, operation=None, *args, **kwargs)[source]

Bases: Control

Two qubit Controled-SX gate.

By convention, the first qubit is the control and second one is the targets.

Matrix representation:

\[\begin{split}\operatorname{CSX} =\begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \frac{1+i}{2} & \frac{1-i}{2} \\ 0 & 0 & \frac{1-i}{2} & \frac{1+i}{2} \end{pmatrix}\end{split}\]

Examples

>>> from mimiqcircuits import *
>>> GateCSX(), GateCSX().num_controls, GateCSX().num_targets, GateCSX().num_qubits
(CSX, 1, 1, 2)
>>> GateCSX().matrix()
[1.0, 0, 0, 0]
[0, 1.0, 0, 0]
[0, 0, 0.5 + 0.5*I, 0.5 - 0.5*I]
[0, 0, 0.5 - 0.5*I, 0.5 + 0.5*I]

>>> c = Circuit().push(GateCSX(), 0, 1)
>>> c
2-qubit circuit with 1 instruction:
└── CSX @ q[0], q[1]

>>> GateCSX().power(2), GateCSX().inverse()
(CX, C(SX†))
>>> GateCSX().decompose()
2-qubit circuit with 4 instructions:
├── C(S†) @ q[0], q[1]
├── CH @ q[0], q[1]
├── C(S†) @ q[0], q[1]
└── CU(0, 0, 0, (1/4)*pi) @ q[0], q[1]
__init__(num_controls=1, operation=None)[source]

Initialize a CSX gate.

class mimiqcircuits.operations.gates.standard.csx.GateCSXDG(num_controls=None, operation=None, *args, **kwargs)[source]

Bases: Control

Two qubit \({CSX}^\dagger\) gate.

Matrix representation:

\[\begin{split}\operatorname{CSX}^{\dagger} =\begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & \frac{1-i}{2} & \frac{1+i}{2} \\ 0 & 0 & \frac{1+i}{2} & \frac{1-i}{2} \end{pmatrix}\end{split}\]

Examples

>>> from mimiqcircuits import *
>>> GateCSXDG(), GateCSXDG().num_controls, GateCSXDG().num_targets, GateCSXDG().num_qubits
(C(SX†), 1, 1, 2)
>>> GateCSXDG().matrix()
[1.0, 0, 0, 0]
[0, 1.0, 0, 0]
[0, 0, 0.5 - 0.5*I, 0.5 + 0.5*I]
[0, 0, 0.5 + 0.5*I, 0.5 - 0.5*I]

>>> c = Circuit().push(GateCSXDG(), 0, 1)
>>> c
2-qubit circuit with 1 instruction:
└── C(SX†) @ q[0], q[1]

>>> GateCSXDG().power(2), GateCSXDG().inverse()
(C((SX†)**2), CSX)
>>> GateCSXDG().decompose()
2-qubit circuit with 4 instructions:
├── CS @ q[0], q[1]
├── CH @ q[0], q[1]
├── CS @ q[0], q[1]
└── CU(0, 0, 0, (-1/4)*pi) @ q[0], q[1]
__init__(num_controls=1, operation=None)[source]

Initialize a CSXDG gate.