Elementary row and column operations.
This module contains the primitive executable row/column operations and their
entrywise access lemmas. Algebraic preservation theorems for multiplication and
inverse tracking live downstream in HexRowReduce.RowEchelon.
Swap rows i and j in a dense matrix.
Implemented with Vector.swap, which updates the dense backing store in place
when M is uniquely referenced, rather than reading both rows and writing them
back through two sets (which forces a copy of the outer vector).
Instances For
Diagonal-entry corollary of getElem_rowSwap for square matrices: when
pivot ≠ k, the (k, k) entry of rowSwap M k pivot is the original
(pivot, k) entry.
Scale row i by c.
Vector.modify frees the row slot before applying the update, so when M is
uniquely referenced both the outer vector and the row itself are updated in
place: Vector.map reuses the freed row's backing store.
Equations
Instances For
Replace row dst by row dst + c * row src.
The source row is read once into rsrc, so the only remaining reference to M
is the consuming Vector.modify, which updates the outer vector in place when
M is uniquely referenced (dropping the old row dst). The replacement row is
built fresh, since every entry of it changes.
Equations
Instances For
rowScale as a single set of the scaled row. The executable definition
goes through Vector.modify for in-place update; this is the value-level
characterization for callers that reason about the result as a set.
rowAdd as a single set of the combined row. The executable definition
goes through Vector.modify for in-place update; this is the value-level
characterization for callers that reason about the result as a set.
Replace column dst by col dst + c * col src.
Rather than rebuilding the whole matrix with ofFn, each row is mapped to its
update of the single dst entry. Vector.map frees each row slot before
applying the function, so the outer vector is reused when M is uniquely
referenced, and each row's single-entry update is itself in place when that row
vector is uniquely referenced.
Equations
Instances For
Replace column dst by col dst + col src * c.
This is the right-scalar variant of colAdd. It is the column-add operation
whose right-multiplication wrapper is valid over a noncommutative ring.
Equations
Instances For
Read an entry of colAddRight M src dst c by cases on the column index:
column dst returns M[i][dst] + M[i][src] * c, any other column is
unchanged.
Column dst of colAddRight M src dst c is the pointwise column
combination with right scalar multiplication.
Any column other than dst is unchanged by colAddRight M src dst c.
Source-column entries are unchanged by colAddRight M src dst c when
src ≠ dst.
The source column is unchanged by colAddRight M src dst c when
src ≠ dst.
Row i of colAddRight M src dst c is row i of M with the dst entry
replaced by M[i][dst] + M[i][src] * c.
Swap columns i and j in a dense matrix.
The swap is done row by row via mapRows: each row's i and j entries are
exchanged with Vector.swap, reusing the freed row slot when M is uniquely
referenced. The column mirror of rowSwap.
Instances For
Scale column j by c.
In-place per-entry column update via modifyCol: each row's single j entry is
multiplied by c, reusing the freed row slot when M is uniquely referenced.
The column mirror of rowScale.