mimiqcircuits.operations.gates.standard.cpauli

Controlled-Pauli (CX, CY, CZ) gates.

Classes

GateCX([num_controls, operation])

Two qubit Controlled-X gate (or CNOT).

GateCY([num_controls, operation])

Two qubit Controlled-Y gate.

GateCZ([num_controls, operation])

Two qubit Controlled-Z gate.

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

Bases: Control

Two qubit Controlled-X gate (or CNOT).

By convention, the first qubit is the control and the second is the target

Matrix representation:

\[\begin{split}\operatorname{CX} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{pmatrix}\end{split}\]

Examples

>>> from mimiqcircuits import *
>>> GateCX(), GateCX().num_controls, GateCX().num_targets
(CX, 1, 1)
>>> GateCX().matrix()
[1.0, 0, 0, 0]
[0, 1.0, 0, 0]
[0, 0, 0, 1.0]
[0, 0, 1.0, 0]

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

>>> GateCX().power(2), GateCX().inverse()
(CID, CX)
>>> GateCX().decompose()
2-qubit circuit with 1 instruction:
└── CX @ q[0], q[1]
__init__(num_controls=1, operation=None)[source]

Initialize a CX gate.

Parameters:
  • num_controls – Ignored, always 1 for CX.

  • operation – Ignored, always GateX() for CX.

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

Bases: Control

Two qubit Controlled-Y gate.

By convention, the first qubit is the control and the second is the target

Matrix representation:

\[\begin{split}\operatorname{CY} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & -i \\ 0 & 0 & i & 0 \end{pmatrix}\end{split}\]

Examples

>>> from mimiqcircuits import *
>>> GateCY(), GateCY().num_controls, GateCY().num_targets
(CY, 1, 1)
>>> GateCY().matrix()
[1.0, 0, 0, 0]
[0, 1.0, 0, 0]
[0, 0, 0, -0.0 - 1.0*I]
[0, 0, 0.0 + 1.0*I, 0]

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

>>> GateCY().power(2), GateCY().inverse()
(CID, CY)
>>> GateCY().decompose()
2-qubit circuit with 3 instructions:
├── S† @ q[1]
├── CX @ q[0], q[1]
└── S @ q[1]
__init__(num_controls=1, operation=None)[source]

Initialize a CY gate.

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

Bases: Control

Two qubit Controlled-Z gate.

By convention, the first qubit is the control and the second is the target

Matrix representation:

\[\begin{split}\operatorname{CZ} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & -1 \end{pmatrix}\end{split}\]

Examples

>>> from mimiqcircuits import *
>>> GateCZ(), GateCZ().num_controls, GateCZ().num_targets
(CZ, 1, 1)
>>> GateCZ().matrix()
[1.0, 0, 0, 0]
[0, 1.0, 0, 0]
[0, 0, 1.0, 0]
[0, 0, 0, -1.0]

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

>>> GateCZ().power(2), GateCZ().inverse()
(CID, CZ)
>>> GateCZ().decompose()
2-qubit circuit with 3 instructions:
├── H @ q[1]
├── CX @ q[0], q[1]
└── H @ q[1]
__init__(num_controls=1, operation=None)[source]

Initialize a CZ gate.