Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

qamomile.linalg.pauli_lcu

Represent general complex matrices as linear combinations of Paulis.

Overview

FunctionDescription
coerce_finite_complex_scalarConvert one numeric scalar to a canonical finite complex value.
coerce_nonnegative_finite_realConvert one numeric scalar to a canonical non-negative finite float.
fwht_complex_pauli_coefficientsCompute complex Pauli coefficients via FWHT.
ClassDescription
PauliLCUStore an immutable Pauli linear-combination decomposition.
PauliLCUTermStore one nonzero complex coefficient and one sparse Pauli word.

Functions

coerce_finite_complex_scalar [source]

def coerce_finite_complex_scalar(value: object, name: str) -> complex

Convert one numeric scalar to a canonical finite complex value.

Parameters:

NameTypeDescription
valueobjectCandidate real or complex numeric scalar.
namestrHuman-readable value name used in diagnostics.

Returns:

complex — Finite Python complex value whose zero components have a positive sign.

Raises:


coerce_nonnegative_finite_real [source]

def coerce_nonnegative_finite_real(value: object, name: str) -> float

Convert one numeric scalar to a canonical non-negative finite float.

Parameters:

NameTypeDescription
valueobjectCandidate real numeric scalar.
namestrHuman-readable value name used in diagnostics.

Returns:

float — Finite non-negative Python float with a positive zero sign.

Raises:


fwht_complex_pauli_coefficients [source]

def fwht_complex_pauli_coefficients(matrix: ArrayLike) -> tuple[np.ndarray, int]

Compute complex Pauli coefficients via FWHT.

Uses the symplectic indexing where qubit k is determined by bit k of each mask::

(x_bit, z_bit) -> Pauli
(0, 0) -> I
(1, 0) -> X
(0, 1) -> Z
(1, 1) -> Y

Qubit 0 corresponds to the least-significant bit of the matrix’s computational-basis indices.

Parameters:

NameTypeDescription
matrixArrayLikeDense finite (N, N) array with N = 2**n.

Returns:

tuple[np.ndarray, int] — tuple[np.ndarray, int]: Pair (coeffs, num_qubits) where coeffs is an (N, N) complex128 array indexed by (x_mask, z_mask).

Raises:

Classes

PauliLCU [source]

class PauliLCU

Store an immutable Pauli linear-combination decomposition.

Parameters:

NameTypeDescription
num_qubitsintNumber of system qubits represented by the Pauli words. Zero is valid for a scalar 1 x 1 matrix.
termstuple[PauliLCUTerm, ...]Ordered nonzero Pauli terms. The empty tuple represents the zero operator.
truncation_error_boundfloatUpper bound on the spectral-norm error caused only by coefficients intentionally removed by :meth:from_matrix. Defaults to 0.0. It does not include floating-point FWHT roundoff.

Raises:

Constructor

def __init__(
    self,
    num_qubits: int,
    terms: tuple[PauliLCUTerm, ...],
    truncation_error_bound: float = 0.0,
) -> None

Attributes

Methods

from_matrix
@classmethod
def from_matrix(cls, matrix: ArrayLike, *, atol: float = 0.0) -> PauliLCU

Decompose a general complex matrix into the Pauli basis.

Qubit zero is the least-significant bit of the matrix’s computational basis index. Coefficients whose magnitude is at most atol are omitted, and their absolute values are accumulated into :attr:truncation_error_bound.

Parameters:

NameTypeDescription
matrixArrayLikeFinite square matrix with dimension 2**n. Hermiticity is not required.
atolfloatNon-negative absolute coefficient threshold. Defaults to 0.0, which removes exact zeros only.

Returns:

PauliLCU — Immutable ordered Pauli decomposition.

Raises:


PauliLCUTerm [source]

class PauliLCUTerm

Store one nonzero complex coefficient and one sparse Pauli word.

The empty operator tuple denotes the identity. Non-identity operators are canonicalized into increasing qubit-index order.

Parameters:

NameTypeDescription
coefficientcomplexFinite, nonzero coefficient multiplying the Pauli word.
operatorstuple[PauliOperator, ...]Sparse Pauli word. Identity operators must be omitted; use an empty tuple for the all-identity word.

Raises:

Constructor

def __init__(self, coefficient: complex, operators: tuple[PauliOperator, ...]) -> None

Attributes