lmnum reference
Complete reference tables for lmnum CLI flags, environment variables, Num, Matrix, Func, Ode, and System methods, and exit codes.
Command-line flags and environment variables
| Flag or variable | Description |
|---|---|
| --lmcode FILE [FILE ...] | Execute compiled LMScript bytecode FILE and print the JSON result envelope |
| --dry-run --lmcode FILE | Validate bytecode FILE without running numerical solvers or writing files |
| --lmcode-schema | Print human-readable host schema summary |
| --lmcode-schema --json | Print the embedded JSON DSL schema (lmnum + lmcode_std_v3) |
| --lmcode-signatures | Print canonical type, method, and function signatures |
| --version | Print the lmnum release version |
| --notices | Print embedded third-party license notices (Eigen MPL-2.0, SUNDIALS BSD-3-Clause) |
| LMNUM_MAX_MEMORY_MB | Override the default 4096 MiB process memory budget |
Num methods (context object num)
| Method | Signature | Description |
|---|---|---|
| matrix | (rows: int, cols: int) -> Matrix | Create a zero-initialized dense rows x cols matrix |
| identity | (n: int) -> Matrix | Create an n x n identity matrix |
| parse | (text: string) -> Matrix | Parse matrix text with rows separated by ; or newline and entries by space or comma |
| linspace | (a: float, b: float, n: int) -> Matrix | Create an n x 1 column vector of equally spaced points from a to b inclusive |
| random | (rows: int, cols: int, seed: int) -> Matrix | Create a deterministic uniform [0, 1) random matrix using mt19937-64 |
| normal | (rows: int, cols: int, seed: int) -> Matrix | Create a deterministic standard normal N(0, 1) random matrix using mt19937-64 |
| load_csv | (path: string) -> Matrix | Load a whitespace- or comma-separated numeric file (skipping one alphabetic header line) |
| eval | (expr: string) -> float | Evaluate a mathematical expression string with constants pi and e |
| func | (expr: string, vars: string) -> Func | Compile a 1D or 2D expression over comma-separated variable names |
| ode | (n: int) -> Ode | Create an n-equation initial-value ODE system builder for SUNDIALS CVODE |
| system | (n: int) -> System | Create an n-equation nonlinear algebraic system builder for SUNDIALS KINSOL |
| integrate | (expr: string, var: string, a: float, b: float) -> float | Integrate expr over var from a to b using adaptive Gauss-Kronrod quadrature (tol 1e-10) |
| integrate_tol | (expr: string, var: string, a: float, b: float, tol: float) -> float | Integrate expr over var from a to b with user tolerance tol |
| root | (expr: string, var: string, a: float, b: float) -> float | Find a root of expr in [a, b] using Brent's method (requires sign change at endpoints) |
| minimize | (expr: string, vars: string, guess: Matrix) -> Matrix | Minimize multivariate expr from initial column vector guess using Nelder-Mead |
| minimize_path | (expr: string, vars: string, guess: Matrix) -> Matrix | Return all Nelder-Mead simplex iterations as rows x0, ..., x{n-1}, f |
| polyfit | (x: Matrix, y: Matrix, deg: int) -> Matrix | Fit a degree-deg polynomial by least squares and return coefficients |
| polyval | (coeffs: Matrix, x: float) -> float | Evaluate a polynomial returned by polyfit at scalar x |
| interp | (x: Matrix, y: Matrix, xq: float) -> float | Evaluate piecewise linear interpolation of (x, y) at xq (requires strictly increasing x) |
| assert_close | (actual: float, expected: float, tol: float) -> void | Assert that |actual - expected| <= tol, exiting with code 3 on failure or NaN |
| (msg: string) -> void | Write a diagnostic line to stderr | |
| version | () -> string | Return the lmnum version string |
Matrix methods
| Method | Signature | Description |
|---|---|---|
| rows / cols | () -> int | Return row count or column count |
| get | (i: int, j: int) -> float | Read entry at 0-based row i, column j |
| set | (i: int, j: int, val: float) -> Matrix | Write val at 0-based row i, column j in place and return receiver |
| copy | () -> Matrix | Return an independent deep copy of the matrix |
| add / sub / hadamard | (other: Matrix) -> Matrix | Elementwise addition, subtraction, or Hadamard product |
| mul | (other: Matrix) -> Matrix | Matrix multiplication |
| scale / shift | (s: float) -> Matrix | Multiply all entries by s or add s to all entries |
| transpose | () -> Matrix | Return the matrix transpose |
| inverse | () -> Matrix | Return the matrix inverse (errors if singular) |
| det / trace / norm | () -> float | Return determinant, trace, or Frobenius/Euclidean norm |
| solve | (rhs: Matrix) -> Matrix | Solve A * X = rhs with Eigen FullPivLU (errors if numerically singular) |
| lstsq | (rhs: Matrix) -> Matrix | Solve linear least-squares min ||A * X - rhs||_2 |
| eig_sym | () -> Matrix | Return ascending eigenvalues of a symmetric matrix as an n x 1 column |
| eigvec_sym | () -> Matrix | Return orthonormal eigenvectors of a symmetric matrix as columns |
| svd_values | () -> Matrix | Return singular values in descending order as a column vector |
| svd_u / svd_v | () -> Matrix | Return thin left (U) or right (V) singular vector matrices |
| cholesky | () -> Matrix | Return lower triangular Cholesky factor L of a symmetric positive-definite matrix |
| block | (i: int, j: int, r: int, c: int) -> Matrix | Extract an r x c submatrix starting at (i, j) |
| sorted | () -> Matrix | Flatten all entries and sort ascending into a column vector |
| col / row | (k: int) -> Matrix | Extract 0-based column k (n x 1) or row k (1 x m) |
| hstack / vstack | (other: Matrix) -> Matrix | Concatenate matrices horizontally or vertically |
| sum / mean / min / max / std | () -> float | Compute scalar reductions across all entries |
| map | (fn: Func) -> Matrix | Apply a 1-argument Func to every matrix entry |
| to_text | () -> string | Format matrix as human-readable text |
| save_csv | (path: string) -> void | Write space-separated rows with exact round-trip double precision and no header |
Func, Ode, and System methods
| Type and method | Signature | Description |
|---|---|---|
| Func.eval | (x: float) -> float | Evaluate a 1-variable compiled expression at x |
| Func.eval2 | (x: float, y: float) -> float | Evaluate a 2-variable compiled expression at (x, y) |
| Ode.rhs | (i: int, expr: string) -> Ode | Set right-hand side expression for dy_i/dt in terms of t, y0..y{n-1}, and params |
| Ode.init | (i: int, val: float) -> Ode | Set initial value y_i(t0) = val |
| Ode.param | (name: string, val: float) -> Ode | Bind a named scalar parameter for use in rhs expressions |
| Ode.tol | (rtol: float, atol: float) -> Ode | Set relative and absolute integration tolerances (default 1e-8, 1e-10) |
| Ode.stiff | () -> Ode | Switch CVODE solver from Adams-Moulton to BDF for stiff systems |
| Ode.solve | (t0: float, t1: float, points: int) -> Matrix | Integrate from t0 to t1 at points equally spaced times, returning columns t, y0..y{n-1} |
| System.eq | (i: int, expr: string) -> System | Set residual expression F_i(x0..x{n-1}) = 0 for equation i |
| System.solve | (guess: Matrix, tol: float) -> Matrix | Solve nonlinear system from column vector guess with KINSOL to residual tolerance tol |
Exit codes
| Code | Phase | Meaning |
|---|---|---|
| 0 | run | Execution and all numerical assertions succeeded |
| 2 | cli | Invalid CLI argument or metadata flag error |
| 3 | load / run | Bytecode load failure, singular matrix, solver non-convergence, NaN evaluation, failed assert_close, or memory limit exceeded |
| 4 | app | Application or output verification failure |