Mova0.6 pre-release

mlab — a computing language in the spirit of MATLAB/Octave

mlab follows the logic of Octave as a small alternative to MATLAB. It is an interpreter for a subset of the language in Rust: matrices, 1-based indexing, colon, end, element-wise operations, functions, control flow, linear algebra, polynomials, FFT, numerical methods. Every linear algebra result passes a verification gate: a wrong answer produces a warning, not silence.

This is the natural plan language for the LLM (the teacher writes such code fluently), while the SLM executes it (Context, layers and memory). Our difference from Octave is the gates. There is no exact mode and no step output yet (see "Limits").

How it works

modulewhat it does
lexer.rstokens with position and a "space before" flag; an apostrophe is a transpose or a string depending on context; %/#, %{ … %}, ...
parser.rsrecursive descent with the language's precedences; a space inside [...] separates elements ([1 -2] — two, [1 - 2] — one); end in an index; command syntax (format long)
ast.rstree: expressions, statements, functions
value.rsValue: Mat (f64 column-major + class double/logical/char + optional imaginary part), Func (named/anonymous with capture), Table (named columns of different types), Exact (reserved for an exact mode; an empty enum — the slot already exists in every match)
interp.rsworkspace and call frames, execution, end context, calls (variable → script function → builtin), output
ops.rsoperators with implicit expansion (broadcasting), complex numbers, matrix multiplication (faer for large ones), division, power, ranges, concatenation
index.rsreading A(I), A(I,J); assignment with growth; deletion A(I) = []
display.rsOctave-style x = … and disp output; printing of anonymous functions
builtins/an extensible registry (Registry::register): core, elem, reduce, io, linalg, poly, fft, numeric, table, stats
table.rs, fileio.rs, mcgate.rstables (columns, output, keys, dates), CSV/TSV/JSON, a Monte Carlo gate for p-values
rng.rsxoshiro256** + splitmix64, normals by Marsaglia's polar method; deterministic with a seed
suite.rs, main.rsscenario suite; CLI
vm.rsVM: a compiler from the tree to register bytecode and an executor; fallback to the tree is transparent (section "Register VM")
builtins/files.rsvfs: files and folders via the vfs::FileSystem trait; all file builtins go through Interp::fs (section "File system: vfs")

The language

Builtins

mlab builtins prints the list. Groups:

Output format (our specification in the style of Octave format short)

Result verification gates

Checking is easier than generating, so the check is a gate. The threshold is 1000 · n · eps; stable algorithms lie orders of magnitude below, so the gate is silent on correct answers and shouts on wrong ones.

operationgate
A \ b (square)backward error ‖A·x − b‖ / (‖A‖‖x‖ + ‖b‖)
A \ b (least squares, singular)normal equations ‖Aᵀ(A·x − b)‖ / (‖A‖₁(‖A‖‖x‖ + ‖b‖))
inv(A)‖A·inv(A) − I‖ / (‖A‖‖inv(A)‖)
[V, D] = eig(A)‖A·V − V·D‖ / (‖A‖‖V‖); eigenvalues only — Σλ versus the trace
[U, S, V] = svd(A)‖U·S·Vᵀ − A‖ / ‖A‖; singular values only — Σσ² versus ‖A‖²_F
lu, qr, chol‖P·A − L·U‖, ‖Q·R − A‖, ‖RᵀR − A‖ relative to ‖A‖

On failure — warning: gate mldivide: |A*x - b| / (|A|*|x| + |b|) = 2.3e-01 exceeds 4.4e-13. A gate warning is not suppressed by warning off. Separately, as in Octave, — warning: matrix singular to machine precision for a singular matrix (rcond estimate by the Hager–Higham method < eps): then \ gives the minimum-norm solution (SVD), and inv of an exactly singular matrix gives Inf.

Negative control of the gate: Interp::fault = Some("gate:mldivide") (gate:inv, gate:eig, gate:svd) plants a wrong answer before the check; the test gates_silent_on_good_answers_and_loud_on_wrong_ones requires silence on correct answers and a warning on planted ones.

CLI

cargo build --release
../target/release/mlab run file.m            # script; output to stdout, warning/error to stderr; exit code 1 on error
../target/release/mlab -e "A = magic(4); rank(A)"
../target/release/mlab test data/suite-v1.txt [--fault sum] [-v]   # scenario suite, summary by category
../target/release/mlab builtins              # list of builtins
../target/release/mlab run examples/demo.m --fault gate:mldivide   # see how the gate catches a planted error
../target/release/mlab run file.m --vm       # the same on the register VM (--vm also works with -e and test)
../target/release/mlab vmgate data/suite-v1.txt data/suite-v2.txt [--fault vm:add]   # VM equivalence gate
../target/release/mlab vmbench examples/vmbench   # tree versus VM, 3 runs, best
../target/release/mlab vmdump file.m         # bytecode listing
../target/release/mlab run file.m --fs mem   # (default) files only in memory; see "File system: vfs"
../target/release/mlab run file.m --fs-import data:/in --fs-export out:/out [--fs-limits file=64M] [--fs-journal j.tsv]
../target/release/mlab run file.m --fs dir:./data   # a real folder, the root is the boundary
../target/release/mlab run file.m --fs real  # the real FS without restrictions — only explicitly

examples/demo.m is a short demo: indexing, \ with the gate, eig, roots, integral to ∞, user functions, ode45. --fault NAME for run/-e/test is a negative control (a broken builtin or a wrong answer before the gate).

Scenario suites

Linear algebra backend: faer. It gives eigenvectors of non-symmetric matrices ([V, D] = eig(A)), which nalgebra does not; bench/ is the measurement crate that compares the two.

Tables, files, statistics

Statistics and Excel-like work with tables, export and import; table computations in RAM.

Tables — columnar, in memory

Import and export

Statistics

ttest2: two-sample t-test for independent samples (Welch)
  H0: μx = μy; H1: μx ≠ μy (two-sided), α = 0.05
  assumptions:
    independence of observations within and between samples — not checked from the data
    normality of both populations (or large n) — nx = 5, ny = 6
    equal variances not required (Welch); max s²/min s² = 1.80556
  steps:
    x̄ = 5.6, ȳ = 4.4, s²x = 0.325, s²y = 0.18
    SE = √(s²x/nx + s²y/ny) = 0.308221
    t = (x̄ − ȳ)/SE = 3.89331, df (Welch — Satterthwaite) = 7.3003
    p = 2·P(T ≥ |t|) = 0.00548141
  conclusion: p < α → reject H0 (h = 1); 95% CI for μx − μy: [0.477208, 1.92279]

Statistics gates

Suite suite-v2

data/suite-v2.txt covers tables, files, descriptive statistics, distributions, tests, regression and errors. It was written and frozen before the code: sha256 012d330d0a428cf4242bc90a45f4978f222549fdd64c943030adf1a1bd1508c1 (test suite_v2_is_frozen). Expected values come from exact formulas and identities (t² = F, correlation p = slope p, χ² 2×2 = n(ad − bc)²/(r1·r2·c1·c2), F(1, ν) = t(ν)², binomial and Poisson fractions) and from textbook and R documentation examples: sleep (Student 1908), PlantGrowth, Agresti (2007), Anscombe's quartet.

Grouping is a (stable) sort of indices by keys and a pass over runs; joins use a hash index of the right table. Assigning a column does not copy the table (Rc::make_mut). examples/bench_table.m is a 1M-row table benchmark.

Table and statistics differences from MATLAB

Register VM

A register VM, as in Lua 5 (Context, layers and memory). mlab run file.m --vm compiles the program to bytecode and executes it; whatever the compiler does not handle is executed by the tree walker, transparently for the user. Code — src/vm.rs, gate — tests/vm.rs.

How it works

Equivalence gate

mlab vmgate and the test vm_gate_frozen_suites_byte_identical: every scenario runs through the tree walker and the VM; all output, including warnings and errors, must match byte for byte; the first discrepancy is red and stops.

mlab vmbench examples/vmbench times the tree and the VM (best of 3, including parsing and compilation) and checks that both give the same output.

WASM

rustup target add wasm32-wasip1 → cargo build --release --target wasm32-wasip1 builds mlab.wasm without changes (with vfs); it runs in our WASI host (section "mlab.wasm in our WASI host").

VM limits

Independent tests

The suite-v1/suite-v2 suites share an author with the code, so they check conformance to the specification. These tests use independent sources: scenarios written by the teacher and external reference data.

LLM scenarios (tests/data/vmm/, tests/vmm_suites.rs)

NIST StRD (tests/data/ext/nist/, tests/ext_nist.rs)

NIST Statistical Reference Datasets (public domain, .dat files as is): regressions, ANOVA and descriptive statistics. The yardstick is LRE, the number of correct significant digits (McCullough 1998), capped at 15; each dataset has a minimum LRE threshold in the test.

Boost.Math (tests/data/ext/boost/, tests/ext_boost.rs)

Boost 1.92.0 test data (BSL-1.0, LICENSE_1_0.txt alongside): values with 35–40 digits for erf, erfc and gamma; the test bounds the relative error in eps. erf, erfc and tgamma come from libm 0.2.16 (MIT, a port of musl/fdlibm; already in the tree via statrs), not from home-grown formulas, which lose accuracy through cancellation near zero and near negative integers. mlab has no beta function.

Octave tests (tests/octave_ext.rs, #[ignore])

%!assert, %!test, %!error blocks from the GNU Octave 11.3.0 source files (GPL: only in tests-octave, they do not enter the repo; the tool takes only %! lines, the implementation code is not read). Each block is a separate mlab run process with a limit of 10 s; only blocks all of whose calls are mlab builtins are run. A panic instead of an error counts as a crash; the regression cases (trapz(h, Y) with a scalar step, polyfit(x, y, Inf), primes(Inf), corr of constant data, corrcoef([])) are errors.

File system: vfs

The vfs crate (vfs — file system for the execution sandbox) is an in-memory file system with snapshots. mlab accesses files only through it.

vfs gates (tests/fs.rs, tests/suite.rs)

mlab.wasm in our WASI host

wasi-host (vfs — file system for the execution sandbox, section "WASI host") runs mlab.wasm on wasmi. WASI calls go to the same vfs::Vfs. The guest is started with --fs real: the guest's std::fs → WASI → the host's Vfs.

The guest must give the same output as native mlab with --fs mem on suite-fs, suite-v1 and suite-v2 (tree and VM). The exception is the errata scenario la-18 (a singular matrix): the faer build for wasm32 reports "svd: failed to converge".

Known differences from Octave/MATLAB

Licenses

Dependencies (the cargo tree tree; each crate's license was checked against the crates.io API /api/v1/crates/<name>/<version> on 2026-09-26):

crateversionlicense (crates.io)role
autocfg1.5.1Apache-2.0 OR MITbuild only (proc-macro / build.rs)
bitflags2.13.2MIT OR Apache-2.0in the binary
bytemuck1.25.2Zlib OR Apache-2.0 OR MITin the binary
cfg-if1.0.5MIT OR Apache-2.0in the binary
defer0.2.1MIT OR Apache-2.0build only (proc-macro / build.rs)
dyn-stack-macros0.1.3MITbuild only (proc-macro / build.rs)
dyn-stack0.13.2MITin the binary
equator-macro0.2.1MITbuild only (proc-macro / build.rs)
equator-macro0.6.0MITbuild only (proc-macro / build.rs)
equator0.2.2MITin the binary
equator0.6.0MITin the binary
faer-traits0.24.0MITin the binary
faer0.24.4MITdirect; in the binary
gemm-c320.19.0MITin the binary
gemm-c640.19.0MITin the binary
gemm-common0.19.0MITin the binary
gemm-f320.19.0MITin the binary
gemm-f640.19.0MITin the binary
gemm0.19.0MITin the binary
generativity1.2.1MIT OR Apache-2.0in the binary
interpol0.2.1MITbuild only (proc-macro / build.rs)
libc0.2.189MIT OR Apache-2.0in the binary
libm0.2.16MITdirect (erf, erfc, tgamma); in the binary
nano-gemm-c320.2.1MITin the binary
nano-gemm-c640.2.1MITin the binary
nano-gemm-codegen0.2.1MITbuild only (proc-macro / build.rs)
nano-gemm-core0.2.1MITin the binary
nano-gemm-f320.2.1MITin the binary
nano-gemm-f640.2.1MITin the binary
nano-gemm0.2.2MITin the binary
num-complex0.4.6MIT OR Apache-2.0in the binary
num_cpus1.17.0MIT OR Apache-2.0in the binary
num-integer0.1.47MIT OR Apache-2.0in the binary
num-traits0.2.19MIT OR Apache-2.0in the binary
once_cell1.21.4MIT OR Apache-2.0in the binary
paste1.0.15MIT OR Apache-2.0build only (proc-macro / build.rs)
primal-check0.3.4MIT OR Apache-2.0in the binary
private-gemm-x860.1.20MITin the binary
proc-macro21.0.107MIT OR Apache-2.0build only (proc-macro / build.rs)
pulp0.22.3MITin the binary
pulp-wasm-simd-flag0.1.1MITin the binary
qd0.8.0MITin the binary
quote1.0.47MIT OR Apache-2.0build only (proc-macro / build.rs)
raw-cpuid11.6.0MITin the binary
reborrow0.5.5MITin the binary
rustfft6.4.1MIT OR Apache-2.0direct; in the binary
seq-macro0.3.6MIT OR Apache-2.0build only (proc-macro / build.rs)
strength_reduce0.2.4MIT OR Apache-2.0in the binary
syn1.0.109MIT OR Apache-2.0build only (proc-macro / build.rs)
syn2.0.119MIT OR Apache-2.0build only (proc-macro / build.rs)
transpose0.2.3MIT OR Apache-2.0in the binary
unicode-ident1.0.26(MIT OR Apache-2.0) AND Unicode-3.0build only (proc-macro / build.rs)
version_check0.9.5MIT OR Apache-2.0build only (proc-macro / build.rs)
statrs0.19.1MITdirect; in the binary (without default features: no nalgebra or rand)
approx0.5.1Apache-2.0in the binary
thiserror2.0.21MIT OR Apache-2.0in the binary
thiserror-impl2.0.21MIT OR Apache-2.0build only (proc-macro)

All crates match crates.io; statrs — MIT, approx — Apache-2.0, thiserror and thiserror-impl — MIT OR Apache-2.0. CSV and JSON are our own code, without crates. Summary: MIT — 29, MIT OR Apache-2.0 — 22, bytemuck — Zlib OR Apache-2.0 OR MIT (we take MIT), unicode-ident — (MIT OR Apache-2.0) AND Unicode-3.0. Unicode-3.0 is the permissive Unicode data license (OSI), and this crate is used only at build time (the proc-macro2 → syn chain), it does not end up in the binary. GPL/LGPL — none. The benchmark (bench/) additionally pulls in nalgebra (Apache-2.0) and its dependencies — only for measurement, not in mlab.

Limits

Licence

Elamur Cosmic License (Elamur Cosmic License). Third-party data keeps its own terms, as noted where it is used.

This page in Markdown https://md.mova.elamur.ai/free/en/docs/mlab/