Playground
Try matten’s shape reasoning below — broadcasting, reshape, axis reductions, matrix
multiplication, and converting mixed data to numeric — computed by a real build of core
matten and shown exactly as it happens, including rejections.
A zero-sized dimension — a shape like 3,0 — is a valid input here. It looks like it should
fail, but matten accepts zero-sized dimensions (RFC-111): try it in any of the four forms
below and the result computes normally, including a matrix product where one side has a
zero dimension.
Broadcasting
Two shapes and their values, combined with +. NumPy-style broadcasting: equal dimensions
match, and a dimension of 1 repeats to fit the other.
Reshape
A shape, its values, and a target shape. Reshape never reorders the underlying values — only the shape used to read them changes.
Axis reductions
A shape, its values, an axis, and a reduction — sum, mean, min, or max. The chosen
axis collapses; the others are kept.
Matrix multiplication
Two shapes and their values, combined with matmul. Accepts any of the four rank
combinations matten supports — [n]×[n], [m,n]×[n], [n]×[n,p], [m,n]×[n,p] —
not only the two-matrix case.
Converting mixed data
A shape and a grid of values that may include text or blank cells. Every cell is shown as
matten reads it — a number, true/false, text, or a blank as None — and then
try_numeric() is run on it: the single point in matten where
mixed data either becomes a plain numeric tensor, or is rejected with the exact cell that
stopped it.
A blank cell is accepted here and shown as None, unlike the four forms above: those build
a numeric tensor directly, where a blank has nothing to become, so it is reported as a
mistake (see Input notes below). On this form a blank is data, not an error —
it is try_numeric(), not the parser, that decides whether None can go further.
Rejections are shown, not hidden
Try an incompatible pair — shapes 2,3 and 4 for broadcasting, or 2,3 and 2,2 for
matmul — and the page shows the same error matten itself produces for that mistake, not a
generic “invalid input”. A rejected operation teaches as much as an accepted one.
Input notes
A shape or values field accepts either commas or newlines as separators — paste a grid the
way it looks, one row per line, and it parses (1, 2, 3 on one line and 1, 2, 3\n4, 5, 6
across two both work). A trailing separator is always fine (1,2,3, is the same as 1,2,3).
A blank cell in the middle of a shape or values field — 1,2,,4 — is never silently
dropped. On the four numeric forms above it is reported by position, since a numeric tensor
has no way to represent “missing” and dropping it would silently shift every value after it.
On the Converting mixed data form it is accepted and shown as None instead — a dynamic
tensor can represent a missing cell, so there it is data to convert or reject explicitly, not
a parsing mistake.
Notes for contributors
Building the WebAssembly module locally
This page needs a WebAssembly build that a plain local mdbook build does not produce.
The .wasm module and its JS bindings are generated by a separate step and are git-ignored,
not committed — the same policy this workspace already applies to
tools/matten-report/tools/matten-migrate/benchmarks’s own Cargo.lock files: build
artifacts of a workspace-excluded, publish = false tool are regenerated on demand, not
tracked. Build it first:
cargo build --manifest-path tools/matten-playground/Cargo.toml \
--target wasm32-unknown-unknown --release
wasm-bindgen --target web \
--out-dir docs/src/playground \
--out-name matten_playground \
tools/matten-playground/target/wasm32-unknown-unknown/release/matten_playground.wasm
Then mdbook build docs (or mdbook serve docs) as usual. In CI this happens automatically
before every book build (.github/workflows/docs.yaml) — a checkout from main and a fresh
mdbook build locally are the only two cases that need the manual step above.
The scope rule
The output on this page is a representation, never a visualization, of what matten
computes (RFC-093 §6, as amended by RFC-095 §3):
- Representation (permitted): showing the tensor’s own structure — rows as rows, columns as columns, numbers as numbers. This is how mathematics writes a matrix and how NumPy prints one. It adds no information that is not already in the shape and the values.
- Visualization (forbidden): encoding a value as visual magnitude or colour — bars,
sparklines, heat maps, axes, lines, colour scales, SVG, canvas. Forbidden regardless of the
medium, including plain characters: a bar chart drawn with
#is visualization and stays out of scope.
The test: does the rendering encode a value as something other than that value? A grid does not. A bar does, however it is drawn. A change that crosses this line needs its own RFC that argues against RFC-093 §6 by name.