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:
1 parent
c0fbe9b182
commit
51bb8767e3
16 files changed
+459
-57
No files matched your search
@@ -235,7 +235,7 @@ Install: `marqdo ext add linalg` (ZH id: `线性代数`). Build: `cargo build --
|
||||
|
||||
**Hard rules:** `ext/**` never calls `host_*`; hot path is ABI plugin; prefer top-level `la.symbol` (not `matrix.symbol` without a receiver); quote `kind=` strings; dense `explicit` / factorize obey size guards.
|
||||
|
||||
APIs (EN): `symbol` / `mul` / `simplify` / `ascii` / `show` · `from_formula` / `explicit` / `det` / `solve` · `block` / `kron` / `collapse` · `factorize` / `draw` (`theme=light|dark|bw`) · `lstsq` / `norm` / `cond` / `rank`.
|
||||
APIs (EN): `symbol` → `# matrix`;中缀 `+`/`-`/`*`;方法 `` `A`.T `` / ``.simplify`` / ``.ascii`` · `from_formula` / `explicit` / `factorize` / `draw` · `lstsq` / `norm` / `cond` / `rank`.
|
||||
|
||||
Examples: [linalg-svd](../../examples/linalg-svd/) · [linalg-least-squares](../../examples/linalg-least-squares/). Design: [ext-linalg.md](../../doc/design/ext-linalg.md).
|
||||
|
||||
|
||||
@@ -336,16 +336,25 @@ import la:ext/linalg/linalg.mq.md
|
||||
|
||||
# main
|
||||
|
||||
`M` =
|
||||
$$
|
||||
\begin{bmatrix}2&0\\0&3\end{bmatrix}
|
||||
$$
|
||||
|
||||
*`M` = > la.from_formula formula=`M`*
|
||||
*`f` = > la.factorize matrix=`M` kind="eig"*
|
||||
*_ = > la.draw factor=`f` kind="eig" path="eig.svg"*
|
||||
> print text=ok
|
||||
*`A` = > la.symbol name="A" rows=2 cols=2*
|
||||
*`B` = > la.symbol name="B" rows=2 cols=2*
|
||||
*`C` = `A` + `B`*
|
||||
*`P` = `A` * `B`*
|
||||
*`s` = > `P`.T.simplify* <!-- prefer: *`Pt` = > `P`.T* then simplify -->
|
||||
```
|
||||
|
||||
Prefer:
|
||||
|
||||
```markdown
|
||||
*`A` = > la.symbol name="A" rows=2 cols=2*
|
||||
*`B` = > la.symbol name="B" rows=2 cols=2*
|
||||
*`P` = `A` * `B`*
|
||||
*`Pt` = > `P`.T*
|
||||
*`s` = > `Pt`.simplify*
|
||||
*`t` = > `s`.ascii*
|
||||
> print text=`t`
|
||||
```
|
||||
|
||||
- Infix `+` / `-` / `*` dispatch when both sides are matrices (needs linalg plugin loaded).
|
||||
- `# matrix` methods: `T`, `add`, `mul`, `simplify`, `ascii`, …
|
||||
- Examples: `examples/linalg-svd/`, `examples/linalg-least-squares/`.
|
||||
- After rebuilding: `marqdo ext add linalg` (or `MARQDO_LINALG_PLUGIN`).
|
||||
Reference in new issue
Block a user