Polynomial Coordinate Functions
The coordinates module provides lightweight helpers for manipulating 6-D complex phase-space vectors.
_clean_coordinates()
The _clean_coordinates()
function removes tiny numerical artefacts from a complex coordinate vector.
- hiten.algorithms.polynomial.coordinates._clean_coordinates()[source]
Remove tiny numerical artefacts from a complex coordinate vector.
- Parameters:
coords (numpy.ndarray) – Input array of shape
(6,)
interpreted as complex coordinates. The function accepts any real- or complex-typed array that can be cast tonp.complex128
.tol (float, default 1e-30) – Absolute threshold below which real or imaginary components are set to zero. The default is conservative and tailored to IEEE-754 double precision.
- Returns:
Cleaned copy of coords with the same dtype as numpy.complex128.
- Return type:
Notes
The routine operates element-wise. If any changes are made, a warning is emitted via
logger()
.Examples
>>> import numpy as np >>> from hiten.algorithms.polynomial.coordinates import _clean_coordinates >>> c = np.array([1+1e-40j, 0+0j, 1e-32+2j, 0j, -3e-31, 5], dtype=complex) >>> _clean_coordinates(c, tol=1e-30) array([1.+0.j, 0.+0.j, 0.+2.j, 0.+0.j, 0.+0.j, 5.+0.j])
_substitute_coordinates()
The _substitute_coordinates()
function applies a linear substitution matrix to a coordinate vector.
- hiten.algorithms.polynomial.coordinates._substitute_coordinates()[source]
Apply a linear substitution matrix to a coordinate vector.
The operation performed is
y_i = sum_{j=1}^6 M_ij * x_j
where M is matrix, x is coords and the result y is returned.
- Parameters:
coords (numpy.ndarray) – Source coordinates with shape
(6,)
.matrix (numpy.ndarray) – Transformation matrix with shape
(6, 6)
. Only non-zero entries are accessed so sparse structures are inexpensive although matrix itself must support NumPy indexing.
- Returns:
Transformed coordinates with dtype numpy.complex128.
- Return type:
- Raises:
ValueError – If matrix is not of shape
(6, 6)
.
Notes
The implementation avoids temporary allocations by accumulating directly into the output array. Real inputs are seamlessly promoted to complex.
Examples
>>> import numpy as np >>> from hiten.algorithms.polynomial.coordinates import _substitute_coordinates >>> M = np.eye(6) >>> M[0, 1] = 2 # simple shear: q1 -> q1 + 2*q2 >>> _substitute_coordinates(np.arange(6), M) array([ 2.+0.j, 1.+0.j, 2.+0.j, 3.+0.j, 4.+0.j, 5.+0.j])