Skip to content

Add LU factorization, linear solves, determinants, and inverses - #55

Merged
LunaStev merged 1 commit into
wavefnd:masterfrom
LunaStev:feat/lu-linear-solvers
Oct 27, 2026
Merged

LunaStev merged 1 commit into
wavefnd:masterfrom
LunaStev:feat/lu-linear-solvers

Conversation

@LunaStev

Copy link
Copy Markdown
Member

HMath could construct and multiply dense matrices but could not factor them or solve linear systems. Add HMath.Matrix.LU, re-exported through HMath, with partial row pivoting, reusable factors, vector and multiple-column RHS solves, determinants, and inverses. Extend the runnable Haskell example with a pivoted system.

The checked API distinguishes exact-zero and small nonzero pivots, supports a configurable relative tolerance (default n * epsilon), and rejects nonfinite inputs and arithmetic results. Empty systems preserve their shapes. Determinants multiply the computed U pivots exactly before final floating-point rounding to avoid intermediate product overflow and underflow. This is a pure reference implementation for RealFloat scalars.

Validation on Linux x86-64 / GHC 9.10.3:

  • 160 Haskell test groups, including 69 new LU groups, 625 independent 2x2 determinant cases, 496 invertible 2x2 systems, later pivot swaps, Float/Double, residuals, error paths, and empty shapes.
  • Meson Release and Debug: all 9 tests pass in each configuration, including C/Python FFI regressions.
  • Clean GHC build with -Wall -Werror; runnable Haskell example passes.
  • Haddock builds with full coverage for the new module; cabal check and source distribution succeed with the existing metadata/optimization warnings. Verified the source archive contains the new module/tests.

Refs #12, #11, #43, #48.

@LunaStev LunaStev added this to the 1.0.0 milestone Oct 27, 2026 — with ChatGPT Codex Connector
@LunaStev LunaStev added enhancement New feature or request linear algebra Vectors, dense and sparse matrices, decompositions, and solvers. haskell Native Haskell API, types, errors, and resource management. testing Numerical correctness, regression coverage, and CI. labels Oct 27, 2026 — with ChatGPT Codex Connector
@LunaStev
LunaStev merged commit 27c7563 into wavefnd:master Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request haskell Native Haskell API, types, errors, and resource management. linear algebra Vectors, dense and sparse matrices, decompositions, and solvers. testing Numerical correctness, regression coverage, and CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant