Gates Module

Definition of common quantum gates.

This module contains the matrix definition of common single and two qubit quantum gates.

The module also contains functions to generate parametric gates:
qdecomp.utils.gates.I

Identity gate.

Type:

NDArray[float]

qdecomp.utils.gates.X

‘NOT’.

Type:

NDArray[float]

Type:

Pauli X gate. Alias

qdecomp.utils.gates.Y

Pauli Y gate.

Type:

NDArray[float]

qdecomp.utils.gates.Z

Pauli Z gate.

Type:

NDArray[float]

qdecomp.utils.gates.H

Hadamard gate.

Type:

NDArray[float]

qdecomp.utils.gates.S

Phase gate. S is the square root of the Pauli Z gate.

Type:

NDArray[float]

qdecomp.utils.gates.V

V gate. V is the square root of the Pauli X gate.

Type:

NDArray[float]

qdecomp.utils.gates.T

T gate. T is the fourth root of the Pauli Z gate.

Type:

NDArray[float]

qdecomp.utils.gates.W

W gate. W is the global omega phase gate

Type:

Complex

qdecomp.utils.gates.CNOT

CNOT | CX gate. Controlled-Not with the control on the first qubit. Alias ‘CX’.

Type:

NDArray[float]

qdecomp.utils.gates.CNOT1

CNOT gate with the control on the second qubit. Alias ‘CX1’.

Type:

NDArray[float]

qdecomp.utils.gates.DCNOT

DCNOT (Double CNOT) gate. CNOT gate followed by an inverted CNOT gate. Alias ‘DCX’.

Type:

NDArray[float]

qdecomp.utils.gates.INV_DCNOT

Inverted DCNOT gate. Inverted CNOT gate followed by a CNOT gate. Alias ‘INV_DCX’.

Type:

NDArray[float]

qdecomp.utils.gates.SWAP

SWAP gate.

Type:

NDArray[float]

qdecomp.utils.gates.ISWAP

iSWAP gate.

Type:

NDArray[float]

qdecomp.utils.gates.CY

Controlled Y gate with the control on the first qubit.

Type:

NDArray[float]

qdecomp.utils.gates.CY1

Controlled Y gate with the control on the second qubit.

Type:

NDArray[float]

qdecomp.utils.gates.CZ

Controlled Z gate with the control on the first qubit.

Type:

NDArray[float]

qdecomp.utils.gates.CZ1

Controlled Z gate with the control on the second qubit.

Type:

NDArray[float]

qdecomp.utils.gates.CH

Controlled Hadamard gate with the control on the first qubit.

Type:

NDArray[float]

qdecomp.utils.gates.CH1

Controlled Hadamard gate with the control on the second qubit.

Type:

NDArray[float]

qdecomp.utils.gates.MAGIC

Magic gate. The magic gate is used in various decompositions algorithms.

Type:

NDArray[float]

qdecomp.utils.gates.power_pauli_y(p: float) ndarray[tuple[Any, ...], dtype[floating]][source]

Return the Pauli Y power gate.

Parameters:

p (float) – Power of the Pauli Y gate.

Returns:

Pauli Y power gate.

Return type:

NDArray[float]

qdecomp.utils.gates.power_pauli_z(p: float) ndarray[tuple[Any, ...], dtype[floating]][source]

Return the Pauli Z power gate.

Parameters:

p (float) – Power of the Pauli Z matrix.

Returns:

Pauli Z power gate.

Return type:

NDArray[float]

qdecomp.utils.gates.canonical_gate(tx: float, ty: float, tz: float) ndarray[tuple[Any, ...], dtype[floating]][source]

Return the matrix form of the canonical gate for the given parameters.

Parameters:
  • tx (float) – Parameters of the canonical gates.

  • ty (float) – Parameters of the canonical gates.

  • tz (float) – Parameters of the canonical gates.

Returns:

Matrix form of the canonical gate.

Return type:

NDArray[float]

qdecomp.utils.gates.get_matrix_from_name(name: str) ndarray[tuple[Any, ...], dtype[floating]][source]

Get the matrix of a gate by its name. If the name ends with “dag”, “dagger”, “_dag” or “_dagger”, the dagger of the gate is returned.

Parameters:

name (str) – Name of the gate.

Returns:

Matrix of the gate.

Return type:

NDArray[float]

Raises:

ValueError – If the gate name is not recognized.