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 variableDescription
--lmcode FILE [FILE ...]Execute compiled LMScript bytecode FILE and print the JSON result envelope
--dry-run --lmcode FILEValidate bytecode FILE without running numerical solvers or writing files
--lmcode-schemaPrint human-readable host schema summary
--lmcode-schema --jsonPrint the embedded JSON DSL schema (lmnum + lmcode_std_v3)
--lmcode-signaturesPrint canonical type, method, and function signatures
--versionPrint the lmnum release version
--noticesPrint embedded third-party license notices (Eigen MPL-2.0, SUNDIALS BSD-3-Clause)
LMNUM_MAX_MEMORY_MBOverride the default 4096 MiB process memory budget

Num methods (context object num)

MethodSignatureDescription
matrix(rows: int, cols: int) -> MatrixCreate a zero-initialized dense rows x cols matrix
identity(n: int) -> MatrixCreate an n x n identity matrix
parse(text: string) -> MatrixParse matrix text with rows separated by ; or newline and entries by space or comma
linspace(a: float, b: float, n: int) -> MatrixCreate an n x 1 column vector of equally spaced points from a to b inclusive
random(rows: int, cols: int, seed: int) -> MatrixCreate a deterministic uniform [0, 1) random matrix using mt19937-64
normal(rows: int, cols: int, seed: int) -> MatrixCreate a deterministic standard normal N(0, 1) random matrix using mt19937-64
load_csv(path: string) -> MatrixLoad a whitespace- or comma-separated numeric file (skipping one alphabetic header line)
eval(expr: string) -> floatEvaluate a mathematical expression string with constants pi and e
func(expr: string, vars: string) -> FuncCompile a 1D or 2D expression over comma-separated variable names
ode(n: int) -> OdeCreate an n-equation initial-value ODE system builder for SUNDIALS CVODE
system(n: int) -> SystemCreate an n-equation nonlinear algebraic system builder for SUNDIALS KINSOL
integrate(expr: string, var: string, a: float, b: float) -> floatIntegrate 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) -> floatIntegrate expr over var from a to b with user tolerance tol
root(expr: string, var: string, a: float, b: float) -> floatFind a root of expr in [a, b] using Brent's method (requires sign change at endpoints)
minimize(expr: string, vars: string, guess: Matrix) -> MatrixMinimize multivariate expr from initial column vector guess using Nelder-Mead
minimize_path(expr: string, vars: string, guess: Matrix) -> MatrixReturn all Nelder-Mead simplex iterations as rows x0, ..., x{n-1}, f
polyfit(x: Matrix, y: Matrix, deg: int) -> MatrixFit a degree-deg polynomial by least squares and return coefficients
polyval(coeffs: Matrix, x: float) -> floatEvaluate a polynomial returned by polyfit at scalar x
interp(x: Matrix, y: Matrix, xq: float) -> floatEvaluate piecewise linear interpolation of (x, y) at xq (requires strictly increasing x)
assert_close(actual: float, expected: float, tol: float) -> voidAssert that |actual - expected| <= tol, exiting with code 3 on failure or NaN
print(msg: string) -> voidWrite a diagnostic line to stderr
version() -> stringReturn the lmnum version string

Matrix methods

MethodSignatureDescription
rows / cols() -> intReturn row count or column count
get(i: int, j: int) -> floatRead entry at 0-based row i, column j
set(i: int, j: int, val: float) -> MatrixWrite val at 0-based row i, column j in place and return receiver
copy() -> MatrixReturn an independent deep copy of the matrix
add / sub / hadamard(other: Matrix) -> MatrixElementwise addition, subtraction, or Hadamard product
mul(other: Matrix) -> MatrixMatrix multiplication
scale / shift(s: float) -> MatrixMultiply all entries by s or add s to all entries
transpose() -> MatrixReturn the matrix transpose
inverse() -> MatrixReturn the matrix inverse (errors if singular)
det / trace / norm() -> floatReturn determinant, trace, or Frobenius/Euclidean norm
solve(rhs: Matrix) -> MatrixSolve A * X = rhs with Eigen FullPivLU (errors if numerically singular)
lstsq(rhs: Matrix) -> MatrixSolve linear least-squares min ||A * X - rhs||_2
eig_sym() -> MatrixReturn ascending eigenvalues of a symmetric matrix as an n x 1 column
eigvec_sym() -> MatrixReturn orthonormal eigenvectors of a symmetric matrix as columns
svd_values() -> MatrixReturn singular values in descending order as a column vector
svd_u / svd_v() -> MatrixReturn thin left (U) or right (V) singular vector matrices
cholesky() -> MatrixReturn lower triangular Cholesky factor L of a symmetric positive-definite matrix
block(i: int, j: int, r: int, c: int) -> MatrixExtract an r x c submatrix starting at (i, j)
sorted() -> MatrixFlatten all entries and sort ascending into a column vector
col / row(k: int) -> MatrixExtract 0-based column k (n x 1) or row k (1 x m)
hstack / vstack(other: Matrix) -> MatrixConcatenate matrices horizontally or vertically
sum / mean / min / max / std() -> floatCompute scalar reductions across all entries
map(fn: Func) -> MatrixApply a 1-argument Func to every matrix entry
to_text() -> stringFormat matrix as human-readable text
save_csv(path: string) -> voidWrite space-separated rows with exact round-trip double precision and no header

Func, Ode, and System methods

Type and methodSignatureDescription
Func.eval(x: float) -> floatEvaluate a 1-variable compiled expression at x
Func.eval2(x: float, y: float) -> floatEvaluate a 2-variable compiled expression at (x, y)
Ode.rhs(i: int, expr: string) -> OdeSet right-hand side expression for dy_i/dt in terms of t, y0..y{n-1}, and params
Ode.init(i: int, val: float) -> OdeSet initial value y_i(t0) = val
Ode.param(name: string, val: float) -> OdeBind a named scalar parameter for use in rhs expressions
Ode.tol(rtol: float, atol: float) -> OdeSet relative and absolute integration tolerances (default 1e-8, 1e-10)
Ode.stiff() -> OdeSwitch CVODE solver from Adams-Moulton to BDF for stiff systems
Ode.solve(t0: float, t1: float, points: int) -> MatrixIntegrate from t0 to t1 at points equally spaced times, returning columns t, y0..y{n-1}
System.eq(i: int, expr: string) -> SystemSet residual expression F_i(x0..x{n-1}) = 0 for equation i
System.solve(guess: Matrix, tol: float) -> MatrixSolve nonlinear system from column vector guess with KINSOL to residual tolerance tol

Exit codes

CodePhaseMeaning
0runExecution and all numerical assertions succeeded
2cliInvalid CLI argument or metadata flag error
3load / runBytecode load failure, singular matrix, solver non-convergence, NaN evaluation, failed assert_close, or memory limit exceeded
4appApplication or output verification failure