:py:mod:`matrices.pauli` ======================== .. py:module:: matrices.pauli .. autoapi-nested-parse:: Pauli matrices. Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: matrices.pauli.pauli .. py:function:: pauli(ind, is_sparse = False) Produce a Pauli operator :cite:`WikiPauli`. Provides the 2-by-2 Pauli matrix indicated by the value of :code:`ind`. The variable :code:`ind = 1` gives the Pauli-X operator, :code:`ind = 2` gives the Pauli-Y operator, :code:`ind = 3` gives the Pauli-Z operator, and :code:`ind = 0` gives the identity operator. Alternatively, :code:`ind` can be set to "I", "X", "Y", or "Z" (case insensitive) to indicate the Pauli identity, X, Y, or Z operator. The 2-by-2 Pauli matrices are defined as the following matrices: .. math:: \begin{equation} \begin{aligned} X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}, \quad Y = \begin{pmatrix} 0 & -i \\ i & 0 \end{pmatrix}, \quad Z = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}, \quad I = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}. \end{aligned} \end{equation} .. rubric:: Examples Example for identity Pauli matrix. >>> from toqito.matrices import pauli >>> pauli("I") array([[1., 0.], [0., 1.]]) Example for Pauli-X matrix. >>> from toqito.matrices import pauli >>> pauli("X") array([[0, 1], [1, 0]]) Example for Pauli-Y matrix. >>> from toqito.matrices import pauli >>> pauli("Y") array([[ 0.+0.j, -0.-1.j], [ 0.+1.j, 0.+0.j]]) Example for Pauli-Z matrix. >>> from toqito.matrices import pauli >>> pauli("Z") array([[ 1, 0], [ 0, -1]]) .. rubric:: References .. bibliography:: :filter: docname in docnames :param ind: The index to indicate which Pauli operator to generate. :param is_sparse: Returns a compressed sparse row array if set to True and a non compressed sparse row array if set to False.