Documentation

CslibFrontier.Algorithms.WordRAM.MatrixMultiplication.Schonhage.BandProgram

Native preparation and encoding of shared matrix bands #

The input is L :: m :: N :: X ++ Y, with both matrices in row-major order and their signed entries encoded by Signed.encode. The native length header occupies address zero. The program snapshots the complete initialized input before using the encoder's low workspace, computes its subset tables, prepares and encodes each band once, and restores the input.

The dense inverse table uses zero for an unselected mask and rank plus one for a selected mask. The forward table lists the first K0² masks of cardinality m in increasing numeric order. The shared output catalogue consists of all left bands followed by all right bands, with 10^L consecutive cells per band. A tile refers to its two band entries in this catalogue.

LeftVar.equiv and RightVar.equiv identify the mathematical alphabets with Fin 3 ⊕ (Fin 2 × Fin 2), and Term.equiv identifies terms with Option (Fin 3 × Fin 3). The existing native Encoding.leftDigits, Encoding.rightDigits and Encoding.termDigits also fix the executable flat Fin 7/Fin 10 order: the nine product terms are row-major, with digit 3*i+j, and P0 has digit 9. This preparation retains that numbering unchanged.

Main definitions #

References #

Selective adaptation of the band preparation in [AlmanWilliams2026, Section 2.4.1] and Anthropic's formal-math revision 16a5ce41304fcdaea4e0be7c132e1c361dc26da5, band-array preparation and all-band encoding. The mask scans, dense inverse table, native control and memory layout here are new; the source's Light machine and execution semantics are not used.

Original initialized input prefix, including the native length header and three parameters.

The encoder's low workspace and the original input are both below the snapshot.

Forward selected-mask table; 2^L cells are reserved.

Shared encoding catalogue, after the snapshot and both tables.

Every left band, then every right band, occupies one block of 10^L words.

Explicit input-parameter bound used to derive every unsigned arithmetic/address fit. The signed magnitude condition is separate. This is an ordinary numerical inequality, without quantification over executions or intermediate states.

Row-major signed matrix input; no table, power or encoded band is supplied by the caller.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

@[reducible, inline]

Low registers are reserved for the existing encoder and copy routines. Persistent parameters and preparation counters occupy registers 32 through 84 of a fixed bank of 96.

Register embedding for the unchanged shared encoders.

Register embedding for the unchanged seven-register copy program.

Embed the five-register native power routine in the caller's chosen scalar registers.

The actual native power routine, with register renaming only.

Popcount is computed by an explicit fixed-depth loop of divisions and remainders.

Compute the three header parameters, powers and addresses with charged native code.

Embed the six-register integer square-root kernel into the band-preparation register bank.

Compute the integer square root and its square by renaming NatSqrt.program and charging one final multiplication. No square-root instruction is added to the native basis.

Complete scalar band parameters from native mask counting and root computation.

Store the two table entries belonging to the current mask and advance both counters.

Materialize both tables, explicitly initializing every inverse-table cell.

One base-seven digit, with only ordinary native arithmetic and control.

Decode a base-seven string into its inner mask and compressed base-three/base-four offsets, in increasing level order. Every division, remainder, product and increment is native.

Read a real matrix cell only after checking the padded row/column against N. In particular, the potentially oversized row-major product is inside the guard.

Prepare every entry of one low-workspace band array, including all zero padding.

Set up the actual encoder-output copy, including its catalogue address arithmetic.

Copy the actual encoder output to this band's shared catalogue entry.

Prepare, encode and collect one shared band, then advance its counter.

Each row/column band calls the actual unchanged finite native encoder exactly once.

Restore the complete original initialized input after all low-workspace calls.

One fixed finite native program for the entire band-preparation component. Halt returns catalogue, the base address of the shared encodings; it is appended by Code.program.