pauli_matrix
Graph.pauli_matrix(label, *, name=None)
Create a Pauli matrix from a label.
Parameters
- label (str) – The string that indicates which Pauli matrix to create.
Must be
'I'
,'X'
,'Y'
,'Z'
,'M'
, or'P'
.'M'
creates the lowering matrix .'P'
creates the raising matrix . We use the convention |\downarrow\rangle = \begin{bmatrix}1\0\end{bmatrix} and |\uparrow\rangle = \begin{bmatrix}0\1\end{bmatrix}. - name (str or None , optional) – The name of the node.
Returns
The Pauli matrix.
Return type
SEE ALSO
Graph.pauli_kronecker_product
: Embed Pauli matrices into a larger Hilbert space.
Examples
Create the Pauli X matrix.
>>> graph.pauli_matrix("X", name="sigma_x")
<Tensor: name="sigma_x", operation_name="pauli_matrix", shape=(2, 2)>
>>> result = bo.execute_graph(graph=graph, output_node_names="sigma_x")
>>> result["output"]["sigma_x"]["value"]
array([[0.+0.j, 1.+0.j],
[1.+0.j, 0.+0.j]])