Matrix
A matrix is a keyed business structure — row key -> ordered values — stored as
a plain object: Record<string, readonly T[]>.
API Reference
@teakit/matrix is not a linear-algebra library. It models keyed
two-dimensional business data (forecasts, budgets, occupancy, KPIs, asset
models), not matrix multiplication, inverses, determinants, or eigenvalues.
Core types
Invariants
- Key order: integer-index keys sort numerically first, then other string
keys lexicographically. Fixed-width period keys (
YYYY,YYYY-MM) therefore sort in time order. All returning APIs emit keys ascending;map,reduce, andentriestraverse in that same order. - No-data vs missing: aggregation and
rollupskip both"-"andundefined;merge,zip,normalize, andtransposepass"-"through verbatim and never invent it. - Immutability: every operation returns a new object; inputs are not mutated. Row arrays are copied; cell values are not deep-copied.
Agent Contract
Agent Notes
- Import with
import { Matrix } from "@teakit/matrix"; no default import. - Do not call
Matrix(...)ornew Matrix(...); it is a namespace of static functions, not a class. - Keep matrices as plain objects and arrays; do not wrap them in classes.
- See period-shapes for the fixed period shapes and errors for the error model.