Skip to main content

Module matrix

Module matrix 

Source
Expand description

Matrix intrinsics — full migration to typed marshal layer.

Per the intrinsics-typed-CC migration’s per-file table, all 4 matrix intrinsics (matmul_vec, matmul_mat, mat_add, mat_sub) migrate to register_typed_fn_2 typed entries via create_matrix_intrinsics_module.

Inputs use the existing Phase 2d Array Vec<Arc<HeapValue>> FromSlot for nested Array<Array<number>> matrix arguments and Arc<Vec<f64>> for flat Array<number> vector arguments. Outputs project through ConcreteReturn::ArrayHeapValue(Vec<Arc<HeapValue>>) for nested-array returns (Phase 2d Array landed; production-active per arrow_module / csv_module / process_ops migrations) and ConcreteReturn::ArrayF64 for flat returns.

Body-side row extraction was previously via direct Arc<HeapValue> pattern-match against HeapValue::TypedArray(TypedArrayData::F64(buf)) and TypedArrayData::I64(...) arms (mirror of Arc<DataTable>’s shape at marshal.rs:200-217). Per V3-S5 ckpt-1 (2026-05-15) the TypedArrayData enum was DELETED at crates/shape-value/src/heap_value.rs (W12-typed-array-data-deletion audit §3.5 + ADR-006 §2.7.24 Q25.A SUPERSEDED). The previous per-variant row-extraction + row-rebuild path cascade-breaks here; production migration target is the v2-raw TypedArray<f64> flat-struct carrier per audit §1.2 + §3.1 scalar recipe (the only existing monomorphization for f64 rows). The HeapValue::TypedArray(Arc<TypedArrayData>) arm at heap_variants.rs:476 is ckpt-4 territory; until that arm migrates, row-extract / row-rebuild surface-and-stop at runtime via the body helpers below.

Matrices are represented as Array<Array<number>> at runtime. This module validates matrix shape once, flattens to contiguous row-major buffers, and runs tight numeric kernels.

Functions§

create_matrix_intrinsics_module
Create the matrix intrinsics module with all 4 typed-marshal entry points.