loom.eka.utilities.pauli_binary_vector_rep
Copyright (c) Entropica Labs Pte Ltd 2025.
Use, distribution and reproduction of this program in its source or compiled form is prohibited without the express written consent of Entropica Labs Pte Ltd.
- class loom.eka.utilities.pauli_binary_vector_rep.PauliOp[source]
Bases:
ABCAbstract PauliOp class, parent of SignedPauliOp and UnsignedPauliOp.
- Parameters:
DTYPE (np.dtype) – The type of numpy arrays used as bit arrays.
array (np.ndarray) – The array representation of the Pauli operator.
- DTYPE
alias of
int8
-
array:
ndarray
- property is_trivial: bool
Checks if the Pauli operator is identity.
- property nqubits: int
The number of qubits that the Pauli operator acts on.
- property x: array
The array representing the X-component of the Pauli operator in binary representation.
- property z: array
The array representing the Z-component of the Pauli operator in binary representation.
- class loom.eka.utilities.pauli_binary_vector_rep.SignedPauliOp(array, validated=False)[source]
Bases:
PauliOpA class describing a SignedPauliOp, a PauliOp operator with a sign that is + or -.
- Parameters:
array (np.ndarray | Sequence) – The array representation of the SignedPauliOp.
Initialization of the SignedPauliOp via a numpy array.
- Parameters:
array (np.ndarray | Sequence) – The array representation of the SignedPauliOp
- as_sparse_string()[source]
Return the Pauli operator as a sparse Pauli string.
- Returns:
The Pauli operator as a sparse Pauli string.
- Return type:
str
- copy()[source]
Returns a deep copy of the SignedPauliOp object.
- Returns:
Deep copy of the SignedPauliOp object
- Return type:
- classmethod from_sparse_string(pauli_str, nqubits=None)[source]
Create a SignedPauliOp from a sparse Pauli string, like “+X2Z5Y7”
- Parameters:
pauli_str (str) – The sparse Pauli string to create the SignedPauliOp from. It is not case sensitive.
nqubits (int | None) – The total number of qubits the Pauli operator acts on. Since SignedPauliOp is a dense representation, all qubits with index starting from 0 until nqubits-1 will be described by the array. The number of qubits should be greater than the maximum index in the Pauli string. If None, the number of qubits is inferred from the maximum index in the Pauli string.
- Returns:
The SignedPauliOp created from the Pauli string.
- Return type:
- Raises:
ValueError – If the first character of the Pauli string is not ‘+’ or ‘-‘. If there are invalid elements in the Pauli string. If the indices in the Pauli string are not unique. If the number of qubits is not greater than the maximum index in the Pauli string.
- classmethod from_string(pauli_str)[source]
Create a SignedPauliOp from a Pauli string, like “+IXZZY”
- Parameters:
pauli_str (str) – The Pauli string to create the SignedPauliOp from.
- Returns:
The SignedPauliOp created from the Pauli string.
- Return type:
- Raises:
ValueError – If the first character of the Pauli string is not ‘+’ or ‘-‘.
- classmethod identity(nqubits, negative=False)[source]
Create an identity operator acting on nqubits. Can be used to create a negative identity operator as well.
- Parameters:
nqubits (int) – The number of qubits the identity operator should act on.
negative (bool) – If True, return a negative identity operator.
- Returns:
The identity operator acting on nqubits.
- Return type:
- property is_minus_identity: bool
Check if the Pauli operator is a minus identity operator. Returns True if the Pauli operator is a minus identity operator, False otherwise.
- multiply_with_anticommuting_operator(other)[source]
Multiply two Pauli operators that anti-commute by including a factor of i. For 2 Pauli operators A and B that anti-commute, A.multiply_with_anticommuting_operator(B) returns the SignedPauliOp i * A * B.
- Parameters:
other (SignedPauliOp) – The other Pauli operator to multiply with.
- Returns:
The product of the two Pauli operators with a factor of i.
- Return type:
- reindexed(qubit_map, nqubits=None)[source]
Return a copy of the operator with the qubits reindexed according to the qubit map.
- Parameters:
qubit_map (list[int]) – The mapping of the new qubit indices to the old qubit indices.
nqubits (int | None) – The total number of qubits the Pauli operator acts on. If None, the number of qubits is inferred from the maximum index in the qubit map.
- Returns:
The Pauli operator with the reindexed qubits.
- Return type:
- property sign: int8
The sign of the Pauli operator, either 0 or 1.
- class loom.eka.utilities.pauli_binary_vector_rep.UnsignedPauliOp(array, validated=False)[source]
Bases:
PauliOpA class describing an UnsignedPauliOp, a Pauli operator without a sign.
Initialization of the UnsignedPauliOp via a numpy array.
- Parameters:
array (np.ndarray | Sequence) – The array representation of the UnsignedPauliOp