mimiqcircuits.operations.gates.standard.hadamard

Hadamard (H) and related gates (HXY, HYZ, HXZ).

Classes

GateH()

Single qubit Hadamard gate.

GateHXY()

Single qubit HXY gate.

GateHXZ()

Single qubit HXZ gate (alias for GateH).

GateHYZ()

Single qubit HYZ gate.

class mimiqcircuits.operations.gates.standard.hadamard.GateH[source]

Bases: Gate

Single qubit Hadamard gate.

Matrix representation:

\[\begin{split}\operatorname{H} = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}\end{split}\]

Examples

>>> from mimiqcircuits import *
>>> GateH()
H
>>> GateH().matrix()
[0.707106781186548, 0.707106781186548]
[0.707106781186548, -0.707106781186548]

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

>>> GateH().power(2), GateH().inverse()
(ID, H)
>>> GateH().decompose()
1-qubit circuit with 1 instruction:
└── U((1/2)*pi, 0, pi, 0.0) @ q[0]
inverse()[source]

Raise an error, as non-unitary operators cannot be inverted.

This method is not implemented for non-unitary operators and will raise a NotImplementedError if called.

Raises:

NotImplementedError – If the method is called.

class mimiqcircuits.operations.gates.standard.hadamard.GateHXY[source]

Bases: Gate

Single qubit HXY gate.

Matrix representation:

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

Examples

>>> from mimiqcircuits import *
>>> GateHXY()
HXY
>>> GateHXY().matrix()
[0, 0.707106781186548 - 0.707106781186548*I]
[0.707106781186548 + 0.707106781186548*I, 0]

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

>>> GateHXY().power(2), GateHXY().inverse()
(HXY**2, HXY)
>>> GateHXY().decompose()
1-qubit circuit with 5 instructions:
├── H @ q[0]
├── Z @ q[0]
├── H @ q[0]
├── S @ q[0]
└── U(0, 0, 0, (-1/4)*pi) @ q[0]
inverse()[source]

Raise an error, as non-unitary operators cannot be inverted.

This method is not implemented for non-unitary operators and will raise a NotImplementedError if called.

Raises:

NotImplementedError – If the method is called.

class mimiqcircuits.operations.gates.standard.hadamard.GateHYZ[source]

Bases: Gate

Single qubit HYZ gate.

Matrix representation:

\[\begin{split}\operatorname{HYZ} = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & -i \\ i & -1 \end{pmatrix}\end{split}\]

Examples

>>> from mimiqcircuits import *
>>> GateHYZ()
HYZ
>>> GateHYZ().matrix()
[0.707106781186548, -0.0 - 0.707106781186548*I]
[0.0 + 0.707106781186548*I, -0.707106781186548]

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

>>> GateHYZ().power(2), GateHYZ().inverse()
(HYZ**2, HYZ)
>>> GateHYZ().decompose()
1-qubit circuit with 5 instructions:
├── H @ q[0]
├── S @ q[0]
├── H @ q[0]
├── Z @ q[0]
└── U(0, 0, 0, (-1/4)*pi) @ q[0]
inverse()[source]

Raise an error, as non-unitary operators cannot be inverted.

This method is not implemented for non-unitary operators and will raise a NotImplementedError if called.

Raises:

NotImplementedError – If the method is called.

class mimiqcircuits.operations.gates.standard.hadamard.GateHXZ[source]

Bases: Gate

Single qubit HXZ gate (alias for GateH).

Matrix representation:

\[\begin{split}\operatorname{H} = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}\end{split}\]

Examples

The HXZ gate behaves exactly like the Hadamard gate:

>>> from mimiqcircuits import *
>>> GateHXZ()
H
>>> GateHXZ().matrix()
[0.707106781186548, 0.707106781186548]
[0.707106781186548, -0.707106781186548]

Adding GateHXZ to a circuit:

>>> c = Circuit().push(GateHXZ(), 0)

Power and inverse of the gate:

>>> GateHXZ().power(2), GateHXZ().inverse()
(ID, H)

Decomposition of the gate:

>>> GateHXZ().decompose()
1-qubit circuit with 1 instruction:
└── U((1/2)*pi, 0, pi, 0.0) @ q[0]