linalg op• Data kinds: matrix × signal → table
• Call: import mathops; mathops.mat_lstsq(a, b, rcond=None) (or opsmath.get("mat_lstsq"))
Least-squares solution of an over-determined system `A x ≈ b (LAPACK gelsd`, SVD-based).
*a* is `(m, n) with m >= n` (at least as many equations as unknowns;
an under-determined system is refused — its minimum-norm answer is a
different question, ask :func:mat_pinv). *b* is `(m,) or (m, k)`.
*rcond* is the singular-value cutoff relative to the largest (`None` =
numpy's machine-precision default); singular values below it are treated
as zero, which is what keeps a noisy rank-deficient fit stable.
Returns a dict — the fit and its honesty telemetry together:
`x solution (n,) or (n, k) · residual_ss` sum of squared
residuals `||b - A x||² (float, or (k,)` per column — computed
explicitly, so it is present even when the matrix is rank-deficient) ·
`rank effective rank at *rcond* · singular_values` of *A*
(descending). `rank < n` means the data does not determine every
parameter — report that, don't hide it.
HALCON: `solve_matrix` on a non-square system (same normal-equation
machinery behind `vector_to_hom_mat2d` and friends).
Every mathops op validates its input before computing (nothing slips through silently):
• **complex input raises ValueError** — coercing to float64 silently discards the imaginary part (numpy only emits a ComplexWarning and returns a plausible-looking wrong real number). State .real/.imag/abs() explicitly, or use complexops, which handles complex data.
• **masked arrays with masked elements raise ValueError** — the implicit conversion that peels off the mask and uses the raw values underneath is refused. Say explicitly whether to fill or to drop.
• **NaN/Inf raises ValueError on every input** (refused with the count stated — it propagates through the whole result).
• Shapes are strict: 1-D and 2-D are never implicitly promoted or broadcast (a matrix in a vector slot, or a vector in a matrix slot, raises ValueError; reshape explicitly).
• Size cap: ops that take a matrix, and the stat_histogram bins, raise ValueError beyond mathops.MAX_ELEMENTS (2^26 ≈ 67 million elements).
• blas_threads_and_memory — 行列分解が遅い理由の知識 — BLAS スレッド・キャッシュ・メモリ配置
• Sample-data catalog (download URLs / licences) — 2-D uses skimage.data (BSD/public domain) plus synthetic images; 3-D lists download URLs for real data sources (Stanford, PDS, …).
• Operator provenance and references — the sources of the research/methods this op family came from.
• The canonical algorithm (author, year) and its uses are named in the family usage guide above.
• math_metrology — py -3.11 examples/math_metrology.py
• poc_sea_ice_concentration — py -3.11 examples/poc_sea_ice_concentration.py
• poc_solar_limb_darkening — py -3.11 examples/poc_solar_limb_darkening.py
table as input)—
linalg)mat_solve · mat_svd · mat_eigh · mat_pinv · mat_cond
*Provenance: mathops.py — MATH operator registry. This per-op note is generated by tools/opdocs.py md (do not hand-edit).*
© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.