feat(linalg): matrix infix ops and # matrix methods

Dispatch +/−/* to the linalg plugin for matrix values, retag for EN/ZH
method chains, and expand # matrix with T/simplify/ascii-style methods.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-09-07 15:13:47 +08:00
1 parent c0fbe9b182
commit 51bb8767e3
16 files changed
+459 -57

No files matched your search

+79 -8
View File
@@ -246,21 +246,87 @@ Numerical rank (SVD).
+ `rows`
+ `cols`
Abstract `MatrixSymbol` (`linalg_expr`). Prefer this over `matrix.symbol` (needs a receiver).
Abstract matrix symbol. Returns a `# matrix` instance (supports `+` / `*` and methods).
> ensure_plugin
**> linalg_symbol name=`name` rows=`rows` cols=`cols`**
**> matrix name=`name` rows=`rows` cols=`cols`**
# matrix
+ `name`=None
+ `rows`=None
+ `cols`=None
+ `data`=None
+ `formula`=None
+ `n`=None
Constructor-style helpers (call after `> la.matrix` if you hold an instance; prefer top-level `symbol` / `eye` / `zeros` / `from_list`).
Matrix value (`_type=matrix`). Prefer infix `A + B` / `A * B`, or methods `` `A`.T ``.
## symbol
+ `name`
+ `rows`
+ `cols`
> ensure_plugin
1. `formula`
**> linalg_from_formula formula=`formula`**
2. `data`
**> linalg_from_list data=`data`**
3. `name`
**> linalg_symbol name=`name` rows=`rows` cols=`cols`**
4. `n`
**> linalg_eye n=`n`**
5. `rows`
**> linalg_zeros rows=`rows` cols=`cols`**
6. *
> print text=ext/linalg: matrix needs name= / data= / formula= / n= / rows=
**None**
**> linalg_symbol name=`name` rows=`rows` cols=`cols`**
## T
**> linalg_transpose expr=`self`**
## add
+ `b`
**> linalg_add a=`self` b=`b`**
## sub
+ `b`
**> linalg_sub a=`self` b=`b`**
## mul
+ `b`
**> linalg_mul a=`self` b=`b`**
## inv
**> linalg_inv expr=`self`**
## simplify
**> linalg_simplify expr=`self`**
## ascii
**> linalg_ascii expr=`self`**
## latex
**> linalg_latex expr=`self`**
## explicit
**> linalg_explicit expr=`self`**
## det
**> linalg_det expr=`self`**
## trace
**> linalg_trace expr=`self`**
## show
+ `path`=None
**> linalg_show expr=`self` path=`path`**
## eye
+ `n`
@@ -277,3 +343,8 @@ Constructor-style helpers (call after `> la.matrix` if you hold an instance; pre
+ `data`
**> linalg_from_list data=`data`**
## from_formula
+ `formula`
**> linalg_from_formula formula=`formula`**
+80 -7
View File
@@ -238,19 +238,87 @@ import sys:lib/sys.mq.md
+ `行`
+ `列`
抽象矩阵符号(`linalg_expr`)。
抽象矩阵符号。返回 `# 矩阵` 实例(可用 `+` / `*` 与方法)。
> 确保插件
**> linalg_symbol name=`名` rows=`行` cols=`列`**
**> 矩阵 名=`名` 行=`行` 列=`列`**
# 矩阵
+ `名`=None
+ `行`=None
+ `列`=None
+ `数据`=None
+ `公式`=None
+ `阶`=None
## 符号
+ `名`
+ `行`
+ `列`
矩阵值(`_type=矩阵`)。优先中缀 `A + B` / `A * B`,或 `` `A`.转置 ``。
**> linalg_symbol name=`名` rows=`行` cols=`列`**
> 确保插件
1. `公式`
**> linalg_from_formula formula=`公式`**
2. `数据`
**> linalg_from_list data=`数据`**
3. `名`
**> linalg_symbol name=`名` rows=`行` cols=`列`**
4. `阶`
**> linalg_eye n=`阶`**
5. `行`
**> linalg_zeros rows=`行` cols=`列`**
6. *
> print text=ext/linalg: 矩阵需要 名= / 数据= / 公式= / 阶= / 行=
**None**
## 转置
**> linalg_transpose expr=`self`**
## 加
+ `右`
**> linalg_add a=`self` b=`右`**
## 减
+ `右`
**> linalg_sub a=`self` b=`右`**
## 乘
+ `右`
**> linalg_mul a=`self` b=`右`**
## 逆
**> linalg_inv expr=`self`**
## 化简
**> linalg_simplify expr=`self`**
## 文本
**> linalg_ascii expr=`self`**
## 乳胶
**> linalg_latex expr=`self`**
## 求值
**> linalg_explicit expr=`self`**
## 行列式
**> linalg_det expr=`self`**
## 迹
**> linalg_trace expr=`self`**
## 展示
+ `路径`=None
**> linalg_show expr=`self` path=`路径`**
## 单位
+ `阶`
@@ -267,3 +335,8 @@ import sys:lib/sys.mq.md
+ `数据`
**> linalg_from_list data=`数据`**
## 自公式
+ `公式`
**> linalg_from_formula formula=`公式`**