linear-algebra

Luna-Flow/linear-algebra is the linear-algebra layer of Luna Flow. It provides dense matrices and vectors in two execution models, value-oriented (immut) and in-place (mutable), numerical routines for floating-point matrices, exact algorithms for integer matrices, and small capability layers (algebra, container) that let generic algorithms run on any matrix or vector type that implements them. This manual describes release 0.5.0.

Packages

PackagePurposePages
immutimmutable Matrix, Vector, lazy MatrixFn; exact determinants and powersAPI · tutorial · design
mutablein-place Matrix, Vector, views; LU, Cholesky, eigenvalues, statisticsAPI · tutorial · design
errorLinearAlgebraError for every checked APIAPI · tutorial · design
arithmeticscalar operation traits and re-exportsAPI · tutorial · design
algebrastructure traits for whole vectors and matrices (experimental)API · tutorial · design
backends/defaultdense wrappers implementing the algebra traitsAPI · tutorial · design
containerstorage-independent operation dictionaries and generic conversions (experimental)API · tutorial · design
container/adaptersdictionaries for every type of this repositoryAPI · tutorial · design
internalshared shape guards (importable only inside this module)API · tutorial · design
consistencycross-package agreement tests (no public items)API · tutorial · design
perf_supportbenchmark cases, fixtures and executionAPI · tutorial · design
perfmoon bench entry packageAPI · tutorial · design
perf_runnersingle-case benchmark executableAPI · tutorial · design

The package src/doc_en_us is not documented separately: it links every page of this manual as a .mbt.md file so that the examples compile and run as tests. The architecture guide shows how the packages depend on each other. The integration chapter explains how external libraries join the algebra and container layers.

Reading paths

Application developers. Start with the mutable tutorial for numerical work on Double matrices, or the immut tutorial for value semantics and exact integer results. Read the error tutorial next, since every operation that can fail returns a LinearAlgebraError.

Library and algorithm authors. Read the algebra tutorial and the backends/default tutorial to write generic code, then the container tutorial for moving data between representations, and the integration guides before publishing implementations for your own types.

Contributors. Read the architecture guide, the conventions, the design pages of the package you change, and the internal and consistency tutorials. Benchmarks are covered by the perf pages.

Install

moon add Luna-Flow/linear-algebra@0.5.0

Import the packages you use in moon.pkg:

///|
import {
  "Luna-Flow/linear-algebra/immut",
  "Luna-Flow/linear-algebra/mutable",
  "Luna-Flow/linear-algebra/error" @la_error,
}

Generic code over scalar types also needs the upstream packages Luna-Flow/luna-generic (0.3.3) and Luna-Flow/arithmetic (0.2.2).

Toolchain

The module requires MoonBit with moonc 0.10 or newer and builds without warnings with moon check --target all. All packages support the wasm-gc, js, wasm and native targets; mutable has a tuned kernel file per target. The benchmark packages are run on native.

Status in 0.5.0

  • algebra, backends/default’s trait layer and container are experimental; their signatures may change.
  • The native OpenBLAS backend is withdrawn in this release because its upstream binding does not compile with MoonBit 0.10. Its source is preserved outside the manual in contrib/openblas_backend; users who need it can stay on 0.4.7.
  • Release history is in the changelog.