qdk_chemistry.utils.pauli_matrix module
Pure-Python Pauli matrix utilities.
Provides the same functionality as the C++ pybind11 pauli_matrix module
using only NumPy (and SciPy for sparse output), preserving the original
bitmask algorithms to minimise memory cost and keep efficiency.
All functions use Little-Endian label convention: label[0] corresponds to
qubit n-1 (MSB).
- qdk_chemistry.utils.pauli_matrix.pauli_string_to_masks(pauli_str)[source]
Decompose a Pauli label string into bitmasks and phase factor.
X sets a bit in x_mask, Z sets a bit in z_mask, Y sets both. The cumulative phase factor
(i)^(number of Y operators)is also returned.
- qdk_chemistry.utils.pauli_matrix.pauli_to_dense_matrix(pauli_strings, coefficients)[source]
Build a dense Hamiltonian matrix from Pauli strings and coefficients.
Computes \(H = \sum_t \mathrm{coeff}[t] \cdot P_t\) where each \(P_t\) is a Pauli string in Little-Endian convention.
- qdk_chemistry.utils.pauli_matrix.pauli_to_sparse_matrix(pauli_strings, coefficients)[source]
Build a sparse CSR Hamiltonian matrix from Pauli strings and coefficients.
Computes \(H = \sum_t \mathrm{coeff}[t] \cdot P_t\) and returns the result as a
scipy.sparse.csr_matrix.- Return type:
- Parameters:
- Returns:
Sparse complex matrix of shape
(2**n, 2**n).- Raises:
RuntimeError – If the matrix dimensions exceed int32 index limits.