Add dense kernels with element limits, from_formula for $$ matrices, and linalg-basic-smoke covering 2×2 det/trace/solve/explicit. Co-authored-by: Cursor <cursoragent@cursor.com>
3.0 KiB
title: ext/linalg/linalg description: Formula-first linear algebra (English). MatExpr simplify + display; ABI plugin. import plugin:lib/plugin.mq.md import sys:lib/sys.mq.md
ensure_plugin
Load the ABI v2 linalg plugin once.
p = > plugin.native_path name="linalg"
p
plugin.load path=
p
print text=ext/linalg: native linalg plugin not found (build marqdo_plugin_linalg or marqdo ext add linalg) sys.exit code=1
ping
ensure_plugin > linalg_ping
mul
+ `a`
+ `b`
Matrix product (lazy MatMul; shape-checked).
ensure_plugin > linalg_mul a=
ab=b
add
+ `a`
+ `b`
ensure_plugin > linalg_add a=
ab=b
sub
+ `a`
+ `b`
ensure_plugin > linalg_sub a=
ab=b
transpose
+ `expr`
ensure_plugin > linalg_transpose expr=
expr
inv
+ `expr`
Symbolic inverse (lazy).
ensure_plugin > linalg_inv expr=
expr
simplify
+ `expr`
Apply MatExpr rewrite rules (R1–R5).
ensure_plugin > linalg_simplify expr=
expr
ascii
+ `expr`
ensure_plugin > linalg_ascii expr=
expr
latex
+ `expr`
ensure_plugin > linalg_latex expr=
expr
shape
+ `expr`
ensure_plugin > linalg_shape expr=
expr
show
+ `expr`
+ `path`=None
Record a formula SVG via host plot channel; returns the expr map.
ensure_plugin > linalg_show expr=
exprpath=path
eye
+ `n`
ensure_plugin > linalg_eye n=
n
zeros
+ `rows`
+ `cols`
ensure_plugin > linalg_zeros rows=
rowscols=cols
from_list
+ `data`
Dense leaf from nested list.
ensure_plugin > linalg_from_list data=
data
from_formula
+ `formula`
Absorb a $$ numeric matrix formula (or nested list / dense map) as a dense leaf.
ensure_plugin > linalg_from_formula formula=
formula
explicit
+ `expr`
Evaluate a MatExpr tree of dense/eye/zero ops to linalg_dense (symbols rejected).
ensure_plugin > linalg_explicit expr=
expr
det
+ `expr`
ensure_plugin > linalg_det expr=
expr
trace
+ `expr`
ensure_plugin > linalg_trace expr=
expr
solve
+ `a`
+ `b`
Solve a x = b (Gaussian elimination). Returns linalg_solve.
ensure_plugin > linalg_solve a=
ab=b
matmul
+ `a`
+ `b`
Dense matrix product → linalg_dense.
ensure_plugin > linalg_matmul a=
ab=b
symbol
+ `name`
+ `rows`
+ `cols`
Abstract MatrixSymbol (linalg_expr). Prefer this over matrix.symbol (needs a receiver).
ensure_plugin > linalg_symbol name=
namerows=rowscols=cols
matrix
Constructor-style helpers (call after > la.matrix if you hold an instance; prefer top-level symbol / eye / zeros / from_list).
symbol
+ `name`
+ `rows`
+ `cols`
> linalg_symbol name=name rows=rows cols=cols
eye
+ `n`
> linalg_eye n=n
zeros
+ `rows`
+ `cols`
> linalg_zeros rows=rows cols=cols
from_list
+ `data`
> linalg_from_list data=data