marqdo

07-linalgok

features/07-linalg.mq.md

Structure

importla:ext/linalg/linalg.mq.md
fn · h1Formula documents with ext/linalg
comment

Not stdlib. Install: marqdo ext add linalg (or build marqdo_plugin_linalg).

comment

Idea: if the .mq.md runs and the asserted form matches, the identity holds under the library rules. Algebra reads like a lecture; factorize / lstsq / draw stay explicit calculation steps.

fn · h1main
comment

Declare symbols in a table, multiply, transpose — T_ascii is one-step display (auto-simplify).

bind `shapes` = [{name: A, rows: 2, cols: 3}, {name: B, rows: 3, cols: 2}]
bind `env` = > la.declare table=`shapes`
bind `A` = [A](`env`)
bind `B` = [B](`env`)
bind `P` = `A` * `B`
bind `t` = > `P`.T_ascii
call> print text=`t`
branch
arm`t` == B^T*A^T
call> print text=formula-doc-ok
armelse
call> print text=formula-doc-fail
call> print text=see-examples-linalg-transpose
Functions
Variables
  • A matrix
    _typematrix
    asciiA
    cols3
    kindsymbol
    latexA
    nameA
  • B matrix
    _typematrix
    asciiB
    cols2
    kindsymbol
    latexB
    nameB
  • P matrix
    _typematrix
    asciiA*B
    factorsList(2)
    kindmul
    latexAB
    shapeList(2)
  • env matrix_env
    AMap(8)
    BMap(8)
    _typematrix_env
  • shapes list · 2
    #namerowscols
    1A23
    2B32
  • t text
    B^T*A^T

Execution

B^T*A^T formula-doc-ok see-examples-linalg-transpose

Source

---
title: How to write a linear-algebra formula document
description: ext/linalg formula-doc — declare, infix, run-implies-correct
import la:ext/linalg/linalg.mq.md
---

# Formula documents with ext/linalg

Not stdlib. Install: `marqdo ext add linalg` (or build `marqdo_plugin_linalg`).

*Idea:* if the `.mq.md` runs and the asserted form matches, the identity holds under the library rules. Algebra reads like a lecture; `factorize` / `lstsq` / `draw` stay explicit calculation steps.

# main

Declare symbols in a table, multiply, transpose — `T_ascii` is one-step display (auto-simplify).

`shapes` =

| @ | name | rows | cols |
|---|------|------|------|
| 1 | A | 2 | 3 |
| 2 | B | 3 | 2 |

**`env` = > la.declare table=`shapes`**
**`A` = [A](env)**
**`B` = [B](env)**
**`P` = `A` * `B`**
**`t` = > `P`.T_ascii**
> print text=`t`
1. `t` == "B^T*A^T"
  > print text=formula-doc-ok
2. *
  > print text=formula-doc-fail

> print text=see-examples-linalg-transpose

Variable