Scientific computing for MoonBit
Algebraic traits, number types and numerical methods that work together. Write an algorithm once, then run it on integers, floating point, decimals, complex numbers or matrices.
Numerical semantics
Same equations. Two number systems.
One Runge–Kutta integrator runs the Lorenz system twice from the same point, once in Float and once in Double. Rounding alone sends them apart. Luna Flow makes the number system an explicit choice.
One algorithm
Written once, evaluated in every world
Horner's rule needs only a semiring. The same function evaluates over machine integers, floating point, big integers, complex numbers and matrices. It has no root among the integers, a root in the complex numbers, and a rotation as a root among matrices.
/// Horner's rule, written once for every semiring.
fn[R : Semiring] horner(coefficients : Array[R], x : R) -> R {
let mut acc : R = Zero::zero()
for i = coefficients.length() - 1; i >= 0; i = i - 1 {
acc = acc * x + coefficients[i]
}
acc
}horner([1, 0, 1], 7)
// => 50horner([1.0, 0.0, 1.0], 0.5)
// => 1.25horner([1N, 0N, 1N], 10000000000N)
// => 100000000000000000001horner([one, zero, one], i)
// => 0 + 0ihorner([id, zero, id], quarter_turn)
// => [[0, 0], [0, 0]]Structure-preserving maps
Structure travels with the map
A homomorphism proven once lifts to polynomials, matrices and products without a new proof. Two paths that must agree, agree: evaluate then map, or map then evaluate.
Principles
Abstraction before implementation
Begin from structures and laws. Implementation details stay inside the layer that needs them.
Semantics made explicit
Floating point, arbitrary precision and decimal values all add, but they do not mean the same thing. Luna Flow keeps the difference visible.
Interoperability over isolation
Independent libraries join through small traits and lightweight adapters, then compose into one computational world.
Write the mathematics once. Choose the numbers later.
Algebraic traits describe what an algorithm needs. Number types decide what it means. Luna Flow keeps the two apart, so the choice stays yours.
Library
Open the documentation
Every repository documents its API, its design and a tutorial in the same structure, in English, Chinese and Japanese.
Foundations
Shared traits, generic structures, and utilities that connect the ecosystem.
- arithmetic
Analytic capability traits for Luna Flow numeric types: elementary functions, checked and contextual operations with explicit precision and diagnostics, and enclosure relations.
- luna-generic
Algebraic traits and default numeric instances that define the generic foundation for LunaFlow math packages.
- luna-utils
Generic array and comparison helpers for Luna-Flow projects, constrained by luna-generic traits.
Numbers & Representations
Concrete and generic representations for numerical computation.
- floating
Arbitrary-precision binary, decimal, and ball arithmetic for MoonBit, with checked operations and explicit numeric semantics.
- luna-complex
Generic complex-number arithmetic for LunaFlow, with analytic and transcendental functions for complex doubles.
- quaternion
Generic quaternions for MoonBit with arithmetic, normalization, 3D rotation, interpolation and Euler-angle conversion.
- luna-poly
Canonical dense, sparse and named-variable polynomials for MoonBit, as immutable values and mutable containers.
Analysis & Optimization
Linear, numerical, and symbolic tools for higher-level mathematics.
- linear-algebra
Dense matrices and vectors for MoonBit in immutable and in-place forms, with checked numerical routines and capability traits for generic linear algebra.
- linear-program
A MoonBit library for defining linear programs and solving them with the two-phase simplex method.
- calculus-numerical
Numerical differentiation and Gauss–Kronrod integration of real functions for MoonBit, part of Luna-Flow.
- autodiff
Forward-mode automatic differentiation over Luna Flow algebraic and arithmetic structures.
Systems & Research
Experimental systems, proof tooling, and ecosystem-scale projects.
- luna_thread
Parallel plans and workflow graphs for MoonBit, validated in MoonBit and executed by a native C runtime through the FFI.
- QED
A kernel-first theorem prover written in MoonBit, governed by a formal specification.
- stella
A work-in-progress proof assistant written in MoonBit, built around a type checker for Martin-Löf type theory.
- mooncake_impact_factor
Local ranking and search toolkit for MoonBit packages, combining dependency, release, and download signals.
- type_theory
Names, binding, capture-avoiding substitution, rewriting and lambda-calculus normalizers shared by Luna Flow's symbolic packages.
- geometry3d
A small 3D rendering pipeline for MoonBit on Luna-Flow/linear-algebra, with terminal, Canvas and GSAP SVG backends.
- mare_mark
Reproducible benchmarking, statistical comparison, tuning, and self-contained reports for MoonBit payloads.
- diff_bench
Differential correctness and performance benchmarks for Luna-Flow MoonBit packages.