moonlight-linalg: Dense tensor and algebraic matrix core for Pale Meridian.

[ library, math, mit ] [ Propose Tags ] [ Report a vulnerability ]

Typed dense and sparse matrices, GF(2) and Smith-normal-form backends, symmetry-indexed operators, and restarted Krylov and Lanczos spectral solvers over a typed shape-and-domain failure vocabulary.


[Skip to Readme]

library moonlight-linalg

library moonlight-linalg:moonlight-linalg-laws

library moonlight-linalg:moonlight-linalg-native

library moonlight-linalg:moonlight-linalg-spectral

library moonlight-linalg:moonlight-linalg-statics

library moonlight-linalg:moonlight-linalg-sparse

library moonlight-linalg:moonlight-linalg-domain

library moonlight-linalg:moonlight-linalg-dense

library moonlight-linalg:moonlight-linalg-geometry

library moonlight-linalg:moonlight-linalg-eigen

library moonlight-linalg:moonlight-linalg-structured

library moonlight-linalg:moonlight-linalg-carrier

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1
Change log CHANGELOG.md
Dependencies base (>=4.22 && <5), containers (>=0.6 && <0.9), deepseq (>=1.4 && <1.6), moonlight-algebra (>=0.1 && <0.2), moonlight-core (>=0.1 && <0.2), moonlight-linalg, moonlight-pale (>=0.1 && <0.2), primitive (>=0.8 && <0.10), tasty (>=1.4 && <1.6), tasty-hunit (>=0.10 && <0.11), tasty-quickcheck (>=0.10 && <0.12), transformers (>=0.6 && <1), vector (>=0.13 && <0.14) [details]
Tested with ghc ==9.14.1
License MIT
Copyright (c) 2026 Blue Rose
Author Blue Rose
Maintainer rosaliafialkova@gmail.com
Uploaded by bluerose at 2026-08-22T01:26:02Z
Category Math
Home page https://github.com/PaleRoses/moonlight
Bug tracker https://github.com/PaleRoses/moonlight/issues
Source repo head: git clone https://github.com/PaleRoses/moonlight.git(moonlight-linalg)
this: git clone https://github.com/PaleRoses/moonlight.git(tag moonlight-linalg-0.1.0.1)(moonlight-linalg)
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 6 total (6 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for moonlight-linalg-0.1.0.1

[back to package description]

moonlight-linalg

Part of Moonlight, the sheaf-theoretic computation layer beneath Melusine and Pale Meridian.

Typed dense, sparse, finite-field, and Krylov linear algebra for Pale Meridian's foundation packages.

moonlight-linalg is Moonlight's numerical linear-algebra tier. Building on moonlight-core and moonlight-algebra, it provides the matrix, vector, GF(2), sparse-storage, Smith-normal-form, eigen, and Krylov machinery used by homology, analysis, sheaf, geometry, and solver packages.

The front door is the umbrella module Moonlight.LinAlg, whose header carries the type-indexed MoonlightError contract, the role map across the public surface, and the quick-start recipe. This page maps the public modules and the benchmark tooling.

Public modules

Module Surface
Moonlight.LinAlg Broad public surface for dense, sparse, operator, spectral, domain, geometry, statics, and immutable Krylov modules.
Moonlight.LinAlg.Dense Dense vectors/matrices, validated dense-row authoring, GF(2), exterior algebra, basic operations, decompositions, field operations, direct solvers, and primitives.
Moonlight.LinAlg.Sparse Sparse matrix carriers, packed sparse operators, sealed preconditioner families, and sparse iterative solvers.
Moonlight.LinAlg.Operator Abstract affine-normalized linear operators with explicit self-adjoint construction boundaries.
Moonlight.LinAlg.Spectral Eigenvalue/eigenpair requests and contiguous result views, dispatched by demand and operator structure above Krylov.
Moonlight.LinAlg.Krylov Public Arnoldi/Lanczos decomposition, projected tridiagonal/block-tridiagonal carriers, and block Lanczos surface.
Moonlight.LinAlg.Native Effectful native LAPACK backend boundary. On macOS it links Accelerate; elsewhere it expects BLAS/LAPACK libraries.
Moonlight.LinAlg.Domain Domain-level algebraic operations, including Smith normal form.
Moonlight.LinAlg.Geometry Vec2, Vec3, AABB/AABB2, frames, affine transforms, and compact symmetric 2D/3D carriers.
Moonlight.LinAlg.Statics Statics types, assembly, equilibrium compilation, and support checking.

The Moonlight.LinAlg.Pure.*, Moonlight.LinAlg.Internal.*, and Moonlight.LinAlg.Effect.* leaves live in graded implementation sublibraries (carrier, structured, eigen, geometry, dense, domain, sparse, statics, spectral, native), with the dependency DAG cabal-enforced and native linkage confined to moonlight-linalg-native. Public callers use the public modules above; the slice modules define implementation ownership behind that public vocabulary.

Hackage's package page aggregates dependencies from the main library, every sublibrary, tests, and benchmarks. A normal consumer inherits only the components named in its own build-depends; depending on moonlight-linalg does not pull in the laws, test harness, native backend, or benchmark closure.

Benchmark artifacts

Repository tooling generates benchmark artifacts:

scripts/tooling/generate_moonlight_linalg_bench_artifacts.py

The generator runs cabal test moonlight-linalg-test -j1, then runs the short default moonlight-linalg-bench target with a CSV tasty-bench report and renders SVG artifacts under /tmp by default. Use --output-dir to choose a destination.

The default bench is decomposed across dense-row validation, dense decompositions/solvers, sparse storage, sparse iterative solvers, domain algebra, GF(2), exterior powers, geometry/statics, spectral demand dispatch, sparse Krylov, native LAPACK, and structured projected block eigensolve. Heavier strata stay opt-in:

  • --broad-medium / MOONLIGHT_LINALG_BENCH_ENABLE_BROAD_MEDIUM=1
  • --broad-large / MOONLIGHT_LINALG_BENCH_ENABLE_BROAD_LARGE=1
  • --sparse-large / MOONLIGHT_LINALG_BENCH_ENABLE_SPARSE_LARGE=1
  • --include-100k / MOONLIGHT_LINALG_BENCH_ENABLE_100K=1
  • --projected-medium / MOONLIGHT_LINALG_BENCH_ENABLE_PROJECTED_MEDIUM=1
  • --large-projected / MOONLIGHT_LINALG_BENCH_ENABLE_PROJECTED_LARGE=1
  • --native-large / MOONLIGHT_LINALG_BENCH_ENABLE_NATIVE_LARGE=1

Use --diagnostic-sweep for the medium broad rows, 50k sparse row, and 144-dimensional projected rows.

The default native LAPACK group keeps small DSYEV rows and a small DSTEMR selected-tridiagonal row. The 10k DSTEMR path-Laplacian row is opt-in because it is a native-boundary stress case for deeper runs.

For a fast local sanity sweep, skip the default calibrated sampling ceremony:

cabal bench moonlight-linalg:moonlight-linalg-bench -j1 --benchmark-options='--once'

This executes every default benchmark row once through the same workload owners and reports the slowest rows. Use the calibrated default only when the numbers are going into evidence.

Benchmark outputs are generated explicitly for each measurement run.

Relationship to external linear-algebra packages

General-purpose Haskell linear algebra packages are better choices for ordinary numerical applications. moonlight-linalg exists because Pale Meridian needs compact compiler-local carriers, GF(2) and integer-domain hooks, exact shape/domain failures, and structured Krylov/projected-operator types that compose with the rest of the Moonlight foundation stack. Its strongest hot path is selected structured spectra, especially path-Laplacian/tridiagonal modes. Dense nested rows serve validated authoring. The native LAPACK boundary is deliberately effectful and isolated from pure APIs.

License

MIT; see LICENSE. Third-party attribution is recorded in THIRD_PARTY_NOTICES.md.