Files
marqdo/ext/linalg/index.mq.md
T
cflmy 9331af78e2 release(2.8.0): 合入 CHANGELOG/README/发版说明/skills prove 任务;CI 链接指向 doc/releases
- CHANGELOG.md:v2.8.0 条目(中英双语);
- README.md:版本行 2.7.1→2.8.0 + 愿景第 6 条(知识可证明);
- doc/releases/v2.8.0.md:双语发版说明(亮点/用法/已知限制);
- skills/marqdo-dev/index.mq.md:新增 prove 任务(路径/目录模式/
  require_lean/json;参数用 + 行声明升参,check 与 narrative-ratio 通过);
- 设计文档 §12.5 标记已合入;发版链接统一指向 doc/releases/v2.8.0.md。
2026-11-18 10:29:26 +08:00

55 lines
2.5 KiB
Markdown
Executable File

---
markup: occlusion
title: Linear algebra — readable matrix workflows
import:
algebra: ext/linalg/linalg.mq.md
---
Start here for a complete matrix workflow, then read [the English API](linalg.mq.md) or
[the Chinese API](线性代数.mq.md). Both expose matrix construction, symbolic expressions,
dense evaluation, solving and reusable factorization. Author matrix methods require an actual
receiver; the free functions accept the expression or matrix explicitly.
Build the native dependency with cargo build -p marqdo_plugin_linalg. This offline workflow
needs plugin permission and no files, network, live services or guessed handles:
```sh
marqdo call ext/linalg/index.mq.md solve_example --effects plugin --json
```
The source matrix and right-hand side below are visible as native matrix formulas. A factorization is a native
structured result, not a string that should be parsed by callers. Reuse a factor only with
compatible dimensions. Rendering is separate: show/draw can write SVG when a path is supplied,
so production examples must state output ownership and cleanup.
Develop matrix semantics in the native linalg implementation and keep public wrappers readable.
Add a new free operation and its EN/ZH counterpart, then update object conveniences only where
useful. Verify dimensions, singular systems and the numeric tolerance appropriate to the method;
a successful call alone does not prove that a numerical result is accurate.
## solve_example
| 返回 | 类型 | 说明 |
|---|---|---|
| result | any | Native solve result with x.data equal to [[2], [1]] for the displayed system |
This example solves two x plus y equals five, and x plus three y equals five. The matrix is
factored once as LU and then reused with the right-hand side. It demonstrates the real data
path without introducing a second formula parser or embedding an external language program.
`coefficients` =
$$
\begin{bmatrix}2&1\\1&3\end{bmatrix}
$$
`right_hand_side` =
$$
\begin{pmatrix}5\\5\end{pmatrix}
$$
We create **matrix = [Construct the coefficient matrix](algebra.from_formula(formula=`coefficients`))**
and **right = [Construct the right-hand-side column](algebra.from_formula(formula=`right_hand_side`))**.
Next **factor = [Factor the coefficient matrix once](algebra.factorize(matrix=`matrix`, kind="lu"))**
retains the native factor for this system. We return *[Solve using the prepared factor](algebra.solve(b=`right`, factor=`factor`))*.
The expected entries are two and one; use the solve result fields rather than interpreting a display string.