feat(linalg): L4 factorize and structure SVG draw

Add LU/QR/SVD/eig/chol dense factorizations, teaching structure SVGs,
LU reuse via solve(factor=), and linalg-factor-smoke gold.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-09-07 14:31:44 +08:00
1 parent b6f116108c
commit 70fb2fbfb2
11 files changed
+903 -16

No files matched your search

+23 -3
View File
@@ -144,13 +144,14 @@ Evaluate a MatExpr tree of dense/eye/zero ops to `linalg_dense` (symbols rejecte
**> linalg_trace expr=`expr`**
## solve
+ `a`
+ `a`=None
+ `b`
+ `factor`=None
Solve `a x = b` (Gaussian elimination). Returns `linalg_solve`.
Solve `a x = b` (Gaussian elimination), or reuse `factorize kind=lu` via `factor` + `b`.
> ensure_plugin
**> linalg_solve a=`a` b=`b`**
**> linalg_solve a=`a` b=`b` factor=`factor`**
## matmul
+ `a`
@@ -186,6 +187,25 @@ Block-level collapse (`Block*Block` → block of products).
> ensure_plugin
**> linalg_collapse expr=`expr`**
## factorize
+ `matrix`
+ `kind`="lu"
Dense factorization → `linalg_factor` (`kind` = `lu` | `qr` | `svd` | `eig` | `chol`).
> ensure_plugin
**> linalg_factorize matrix=`matrix` kind=`kind`**
## draw
+ `factor`
+ `kind`=None
+ `path`=None
Structure SVG for a factor or dense matrix (`eig` | `svd` | `qr` | `lu` | `ge` | `chol` | `structure` | `heatmap` | `hinton`).
> ensure_plugin
**> linalg_draw factor=`factor` kind=`kind` path=`path`**
## symbol
+ `name`
+ `rows`
+23 -3
View File
@@ -138,13 +138,14 @@ import sys:lib/sys.mq.md
**> linalg_trace expr=`式`**
## 求解
+ `左`
+ `左`=None
+ `右`
+ `分解`=None
解 `左 · x = 右`,返回 `linalg_solve`。
解 `左 · x = 右`,或复用 `分解`(`kind=lu`)+ `右`。
> 确保插件
**> linalg_solve a=`左` b=`右`**
**> linalg_solve a=`左` b=`右` factor=`分解`**
## 稠密乘
+ `左`
@@ -178,6 +179,25 @@ import sys:lib/sys.mq.md
> 确保插件
**> linalg_collapse expr=`式`**
## 分解
+ `矩阵`
+ `类型`="lu"
稠密分解 → `linalg_factor`(`类型` = `lu` | `qr` | `svd` | `eig` | `chol`)。
> 确保插件
**> linalg_factorize matrix=`矩阵` kind=`类型`**
## 绘图
+ `分解`
+ `类型`=None
+ `路径`=None
分解/稠密结构 SVG(`eig` | `svd` | `qr` | `lu` | `ge` | `chol` | `structure` | `heatmap` | `hinton`)。
> 确保插件
**> linalg_draw factor=`分解` kind=`类型` path=`路径`**
## 符号
+ `名`
+ `行`