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.periodic_shift_lcu

Represent periodic-shift matrices as immutable LCU decompositions.

Overview

FunctionDescription
as_finite_square_complex_matrixConvert one value to a finite square complex128 matrix.
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.
ClassDescription
PeriodicShiftLCUStore an immutable periodic-shift linear-combination decomposition.
PeriodicShiftLCUTermStore one nonzero coefficient and one canonical periodic offset.

Functions

as_finite_square_complex_matrix [source]

def as_finite_square_complex_matrix(matrix: ArrayLike) -> np.ndarray

Convert one value to a finite square complex128 matrix.

Parameters:

NameTypeDescription
matrixArrayLikeCandidate dense matrix.

Returns:

np.ndarray — np.ndarray: Finite square complex128 matrix.

Raises:


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:

Classes

PeriodicShiftLCU [source]

class PeriodicShiftLCU

Store an immutable periodic-shift linear-combination decomposition.

Axis zero occupies the least-significant bits of the flattened system basis. Each term represents coefficient * T_offset, where every axis of T_offset wraps modulo 2**register_sizes[axis].

Parameters:

NameTypeDescription
register_sizestuple[int, ...]Positive qubit width of every periodic axis. The empty tuple represents a scalar 1 x 1 matrix at the linalg layer.
termstuple[PeriodicShiftLCUTerm, ...]Canonical nonzero terms. Terms are stored in lexicographic offset order. 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 or :meth:from_coefficients. Defaults to 0.0 and excludes host floating-point roundoff.

Raises:

Constructor

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

Attributes

Methods

from_coefficients
@classmethod
def from_coefficients(
    cls,
    coefficients: Mapping[Offset, complex],
    *,
    register_sizes: Sequence[int],
    atol: float = 0.0,
) -> PeriodicShiftLCU

Build a canonical decomposition from periodic-shift coefficients.

Equivalent signed or unsigned offsets are combined before pruning. Coefficients whose magnitude is at most atol are omitted, and the sum of their magnitudes is stored in truncation_error_bound.

Parameters:

NameTypeDescription
coefficientsMapping[int | tuple[int, ...], complex]Finite coefficients keyed by a one-dimensional integer offset or one integer component per axis.
register_sizesSequence[int]Positive qubit width of each periodic axis. The empty sequence describes a scalar decomposition; any supplied offset must then be the empty tuple.
atolfloatNon-negative absolute coefficient threshold. Defaults to 0.0, which removes exact zeros only.

Returns:

PeriodicShiftLCU — Immutable canonical decomposition.

Raises:

from_matrix
@classmethod
def from_matrix(
    cls,
    matrix: ArrayLike,
    *,
    register_sizes: Sequence[int],
    atol: float = 0.0,
) -> PeriodicShiftLCU

Decompose an exact constant-coefficient periodic-shift matrix.

After conversion to complex128, the structural check is exact: every column must be the periodic translation of the first column implied by register_sizes. The atol argument has the same meaning as in :meth:from_coefficients; it prunes extracted coefficients but does not relax the structural check. Hermiticity is not required.

Parameters:

NameTypeDescription
matrixArrayLikeFinite square matrix with dimension 2**sum(register_sizes).
register_sizesSequence[int]Positive qubit width of each axis in flattened least-significant-axis-first order. The empty sequence describes a scalar 1 x 1 matrix.
atolfloatNon-negative absolute coefficient threshold. Defaults to 0.0, which removes exact zeros only.

Returns:

PeriodicShiftLCU — Immutable canonical shift decomposition.

Raises:


PeriodicShiftLCUTerm [source]

class PeriodicShiftLCUTerm

Store one nonzero coefficient and one canonical periodic offset.

Parameters:

NameTypeDescription
coefficientcomplexFinite nonzero coefficient multiplying the periodic shift.
offsettuple[int, ...]Non-negative offset residue for every axis. The enclosing :class:PeriodicShiftLCU validates each component against its corresponding axis size.

Raises:

Constructor

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

Attributes