In-Place Dense Homogeneous Kernels #
A memory-efficient executable variant of the dense Gauss-Jordan homogeneous-kernel backend.
The functions in RowOps.lean and Kernel.lean thread a whole DenseMatrix
structure through every row operation. Because scaleRow/addScaledRow/swapRows
read the matrix through M.get while the structure M is still live, the backing
Array is multiply-referenced at the first setD, so Array.setIfInBounds copies
the entire array on every row-operation call. Gauss-Jordan elimination performs
Θ(rows) row operations per pivot and Θ(min rows cols) pivots, so the copies turn
an O(n³) algorithm into O(n⁴) work plus Θ(n⁴) words of short-lived allocation.
This module performs the same arithmetic, in the same order, threading a bare
Array F (with the dimensions carried as separate Nat arguments) through the
reduction. The array is uniquely referenced as it flows from one operation to the
next, so setIfInBounds mutates in place after at most one fork from a shared input.
The reduced matrix and pivot data are bit-for-bit identical to rref, so the
extracted witnesses agree with homogeneousWitness.
The free-column witness extraction (freeColumns, basisVectorForFreeColumn) is
cheap and shared verbatim with Kernel.lean.
Reduced row-echelon form with pivot-column metadata, computed in place.
This destructures M so the backing array is owned by the reduction loop rather
than aliased through the structure, which is what lets setIfInBounds mutate in
place. The result equals rref M.
Instances For
Homogeneous kernel basis extracted from the in-place RREF free columns.
Instances For
One nonzero homogeneous-kernel witness via in-place reduction, if a free
column exists. Output-identical to homogeneousWitness.