Skip to content

gen_pauli_x

Produces a generalized Pauli-X operator matrix.

gen_pauli_x

gen_pauli_x(dim: int) -> ndarray

Produce a dim-by-dim gen_pauli_x matrix 1.

Returns the gen_pauli_x matrix of dimension dim described in 1. The gen_pauli_x matrix generates the following dim-by-dim matrix:

\[ \Sigma_{1, d} = \begin{pmatrix} 0 & 0 & 0 & \ldots & 0 & 1 \\ 1 & 0 & 0 & \ldots & 0 & 0 \\ 0 & 1 & 0 & \ldots & 0 & 0 \\ 0 & 0 & 1 & \ldots & 0 & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots & \vdots \\ 0 & 0 & 0 & \ldots & 1 & 0 \end{pmatrix} \]

The gen_pauli_x matrix is primarily used in the construction of the generalized Pauli operators.

Parameters:

  • dim (int) –

    Dimension of the matrix.

Returns:

  • ndarray

    dim-by-dim gen_pauli_x matrix.

Examples:

The gen_pauli_x matrix generated from \(d = 3\) yields the following matrix:

\[ \Sigma_{1, 3} = \begin{pmatrix} 0 & 0 & 1 \\ 1 & 0 & 0 \\ 0 & 1 & 0 \end{pmatrix} \]
from toqito.matrices import gen_pauli_x

print(gen_pauli_x(3))
[[0. 0. 1.]
 [1. 0. 0.]
 [0. 1. 0.]]

References

1 Wikipedia. Generalizations of {P}auli matrices. link.

Source code in toqito/matrices/gen_pauli_x.py
def gen_pauli_x(dim: int) -> np.ndarray:
    r"""Produce a `dim`-by-`dim` gen_pauli_x matrix [@wikipediageneralizedpauli].

    Returns the gen_pauli_x matrix of dimension `dim` described in [@wikipediageneralizedpauli].
    The gen_pauli_x matrix generates the following `dim`-by-`dim` matrix:

    \[
        \Sigma_{1, d} = \begin{pmatrix}
                        0 & 0 & 0 & \ldots & 0 & 1 \\
                        1 & 0 & 0 & \ldots & 0 & 0 \\
                        0 & 1 & 0 & \ldots & 0 & 0 \\
                        0 & 0 & 1 & \ldots & 0 & 0 \\
                        \vdots & \vdots & \vdots & \ddots & \vdots & \vdots \\
                        0 & 0 & 0 & \ldots & 1 & 0
                    \end{pmatrix}
    \]

    The gen_pauli_x matrix is primarily used in the construction of the generalized
    Pauli operators.

    Args:
        dim: Dimension of the matrix.

    Returns:
        `dim`-by-`dim` gen_pauli_x matrix.

    Examples:
        The gen_pauli_x matrix generated from \(d = 3\) yields the following matrix:

        \[
            \Sigma_{1, 3} =
            \begin{pmatrix}
                0 & 0 & 1 \\
                1 & 0 & 0 \\
                0 & 1 & 0
            \end{pmatrix}
        \]

        ```python exec="1" source="above" result="text"
        from toqito.matrices import gen_pauli_x

        print(gen_pauli_x(3))
        ```

    """
    # First column of the identity matrix becomes the last column due to `shift = -1` and `axis=1`
    return np.roll(np.identity(dim), -1, axis=1)