linear-algebra

    A linear algebra library, a part of LunaFlow.

    linear-algebra
    math
    Download zip
    Author
    Version
    0.2.12
    License
    MIT
    Last updated
    5 months ago
    Downloads
    3K

    #LINEAR-ALGEBRA

    img img img img

    #v0.2.12 - Correctness, Diagnostics & Documentation Alignment

    This documentation tracks the published v0.2.12 release content and reflects the repository state after all changes landed since 0.2.11.

    #Package Positioning

    • immut: Immutable, value-oriented Matrix, Vector, and MatrixFn types for persistent data and explicit copy-on-update semantics.
    • mutable: Execution-oriented Matrix and Vector types with in-place updates, Transpose views, RowView / ColView, and backend-specific implementations for js, wasm, wasm-gc, and native.
    • Shared Core, Different Execution Model: Constructors and core algebraic operators remain aligned across packages, but mutation and access semantics are intentionally different.

    #What Defines v0.2.12

    • Strict Bounds Across Public Accessors: Public matrix, view, and transpose accessors now consistently reject out-of-bounds indices, including 0xN and Nx0 edge cases, instead of relying on backend storage accidents.
    • Immutable Access Semantics Hardened: immut.Matrix indexed access and copy-on-update setters now enforce true 2D bounds rather than allowing flat-storage aliasing.
    • Cross-Package Semantic Alignment: Shared immut / mutable operations now align more closely on explicit edge behavior, including same-index swap no-op semantics.
    • Expanded Benchmark Diagnostics: The benchmark stack now includes richer replay/testing support, a single-case whitebox runner, and better metadata/diagnostic handling across the local reporting flow.
    • Documentation Refresh: The main README and matrix API references were rewritten to match the current exported surface and remove stale or duplicated descriptions.
    • Repository Correctness Audit: The repository now includes a tracked correctness checklist that records validated behavior, confirmed fixes, and remaining structural follow-up risks.

    #API Guidance & Performance

    • Core Algebraic API: Shared operations such as make, transpose, +, -, *, trace, and matrix/vector conversions are intended to stay semantically aligned across immut and mutable.
    • Random Access: In mutable, for high-performance random access, prefer .get(i, j) and .set(i, j, val) directly.
    • Structured Views: For repeated row or column work in mutable, prefer row_view() / col_view() instead of relying on matrix[row] convenience syntax.
    • Strict Bounds: Public matrix, view, and transpose accessors consistently reject out-of-bounds indices, including 0xN and Nx0 edge cases.
    • MatrixFn Alignment: immut.MatrixFn now shares the same non-negative dimension and empty-matrix semantics as the concrete matrix implementations.
    • Public Surface: Internal decomposition helpers remain implementation details. Package users should rely on the documented public matrix methods instead.

    #Key Features

    • Mutable & Immutable Support: Full Matrix and Vector suites with distinct semantics for value-oriented and execution-oriented workloads.
    • Advanced Operations: Includes determinant, inverse, rank, Cholesky decomposition, eigen-related routines, row elimination, transpose views, and matrix/vector conversions.
    • Shared Data Model, Backend-Tuned Kernels: mutable still ships backend-tuned execution paths for Native, Wasm, JS, and Wasm GC targets, but the core matrix storage model is now unified.
    • Benchmark Infrastructure: bench/, src/perf_support, and src/perf_runner now form a full steady-state benchmarking subsystem for backend comparison and diagnostic replay.
    • Correctness First: Coverage now includes immutable laws, cross-package consistency checks, determinant/rank/inverse alignment, and regression tests for numerical behavior.
    • Auditable Public Contracts: Bounds behavior, swap semantics, benchmark fixtures, and documentation are now tracked more explicitly as part of the repository’s correctness story.

    #Benchmark Packages

    • perf: Benchmark entry package used by moon bench for the steady-state matrix suite.
    • perf_support: Public fixture metadata, case registry, runtime loaders, and checksum-oriented execution helpers for benchmark cases.
    • perf_runner: Single-case diagnostic and sampling runner used for replay, local investigation, and richer benchmark artifact generation.

    #Quick Start

    let imm = @immut.Matrix::from_2d_array([[1, 2], [3, 4]])
    let imm_updated = imm.set(0, 1, 9)

    let m = @mutable.Matrix::from_2d_array([[1.0, 2.0], [3.0, 4.0]])
    m.set(0, 1, 9.0)

    let det = m.determinant()
    let maybe_inv = m.inverse()
    let row0 = m.row_view(0).to_array()

    #Documentation

    Comprehensive API documentation is available at mooncakes.io.

    We provide documentation in multiple languages:

    • 🇺🇸 English (doc/en_US)
    • 🇨🇳 简体中文 (doc/zh_CN)
    • 🇯🇵 日本語 (doc/ja_JP)

    Localized README files:

    #Version History

    VersionDateStatusNotes
    0.2.122026-06-06published on mooncakesStrict bounds unification, semantic correctness fixes, benchmark diagnostics expansion, and documentation/audit refresh
    0.2.112026-05-27previous release baselinePerformance-tuned mutable kernels, dedicated wasm-gc backend, benchmark/reporting expansion, and API/doc alignment
    0.2.102026-05-27previous release baselineUnified flattened mutable storage, matrix views, consistency coverage, benchmark coverage, and release-process alignment
    0.2.92026-02-03published on mooncakesPublished from the earlier 3328195 release state
    0.2.82026-02-03historical baselineAlgorithms and stability milestone used as the comparison baseline for later work

    #Current Repository Highlights

    • Current Release Narrative (0.2.12):
      • Public matrix, view, and transpose accessors now enforce explicit bounds contracts across the library, including zero-row and zero-column edge shapes.
      • immut.Matrix and mutable.Matrix are more tightly aligned on shared correctness semantics, while keeping their intended value-vs-mutation execution split.
      • The benchmark stack now includes stronger diagnostic replay/test coverage and cleaner metadata handling around local benchmark workflows.
      • The repository now carries a tracked correctness checklist, and the README plus matrix API docs were refreshed to match the actual exported surface.

    • Previous Release Narrative (0.2.11):
      • mutable.Matrix now combines the shared flat storage model from 0.2.10 with follow-up backend kernel optimizations and a dedicated wasm-gc implementation.
      • Public numerical signatures are aligned around Field / Num / Tolerance, and immutable determinant documentation matches the simplified post-0.2.10 constraint set.
      • The benchmark stack now includes runtime-loaded fixtures, expanded case metadata, richer summary reporting, a local dashboard, optional Rust comparison runs, and diagnostic replay via perf_runner.
      • The release checklist, benchmark docs, package overview, and localized READMEs are aligned to the 0.2.11 release story.

    • Algorithms & Stability (0.2.8):
      • Added LU- and QR-related decomposition support used by determinant, inverse, rank, and eigen routines.
      • Shifted determinant and rank behavior toward more stable elimination-based implementations.

    • Native Optimization (0.2.7):
      • Implemented transposition + dot-product strategy for Native matrix multiplication, outperforming naive implementations by more than 2x.
      • Optimized make, new, and transpose to remove expensive integer division in hot loops.

    • Performance Overhaul (0.2.4):
      • Optimized secondary utilities such as mapi and each_row_col.
      • Improved hybrid matrix multiplication and vector linear-combination performance.

    • Other Fixes & Renames:
      • map_row() / map_col() -> map_row_inplace() / map_col_inplace()
      • eachij() -> each_row_col()
      • Corrected determinant behavior for 0x0 matrices.
      • Fixed copy-on-conversion behavior between vectors and matrices.

    #Development

    Useful local commands:

    moon fmt moon check moon test --enable-coverage ./run_test.sh

    run_test.sh runs the repository test suite: immut, consistency, perf_support, and perf_runner, plus mutable on wasm-gc, js, native, and wasm.

    #Release Checklist

    Before triggering the publish workflow:

    1. Bump moon.mod to the intended next release version before publishing.
    2. Update README.md so the release notes and version history match the package contents.
    3. Run moon check and ./run_test.sh; both are required before publishing.
    4. Trigger publish-package; it will publish the version currently declared in moon.mod.

    If the workflow reports a duplicate version, the package manager already contains that version and a new version bump is required.

    Contribution guidance is available in CONTRIBUTING.md.