Coefficient of the orthogonal projection of row onto basisRow.
When the basis row has zero norm we use 0, which matches the degenerate
case of Gram-Schmidt where the corresponding projection term vanishes.
Equations
- Hex.GramSchmidt.projectionCoeff row basisRow = if basisRow.dotProduct basisRow = 0 then 0 else row.dotProduct basisRow / basisRow.dotProduct basisRow
Instances For
Subtract the projection of row onto basisRow.
Equations
- Hex.GramSchmidt.subtractProjection row basisRow = row - Hex.GramSchmidt.projectionCoeff row basisRow • basisRow
Instances For
Over Rat, a vector whose self-dot-product is zero is the zero vector, so
its dot product with any other row also vanishes. Used to discharge the
degenerate zero-norm basis row case when reasoning about orthogonality.
Reduce a row against the previously constructed orthogonal basis rows.
Equations
- Hex.GramSchmidt.reduceAgainstBasis basisRev row = List.foldl Hex.GramSchmidt.subtractProjection row basisRev
Instances For
Left-to-right Gram-Schmidt orthogonalization on a list of rows.
Equations
- Hex.GramSchmidt.basisRowsAux basisRev [] = basisRev.reverse
- Hex.GramSchmidt.basisRowsAux basisRev (row :: rows) = Hex.GramSchmidt.basisRowsAux (Hex.GramSchmidt.reduceAgainstBasis basisRev row :: basisRev) rows
Instances For
Left-to-right Gram-Schmidt orthogonalization on a matrix's rows.
Equations
Instances For
Rebuild a matrix from its row list after Gram-Schmidt orthogonalization.
Equations
- Hex.GramSchmidt.basisMatrix b = Hex.Matrix.ofRows (Vector.ofFn fun (i : Fin n) => (Hex.GramSchmidt.basisRows b.rows.toList)[↑i]!)
Instances For
Gram-Schmidt coefficient matrix for an already-cast rational input.
Equations
- Hex.GramSchmidt.coeffMatrix rows basis = Hex.Matrix.ofFn fun (i j : Fin n) => if _hlt : ↑j < ↑i then Hex.GramSchmidt.projectionCoeff (rows.getRow i) (basis.getRow j) else if i = j then 1 else 0
Instances For
Cast an integer matrix into the rational matrix space used by Gram-Schmidt.
Equations
- Hex.GramSchmidt.castIntMatrix b = Hex.Matrix.ofRows (Vector.map (fun (row : Vector Int m) => Vector.map (fun (x : Int) => ↑x) row) b.rows)
Instances For
The row-prefix matrix containing rows 0 through i.
Equations
- Hex.GramSchmidt.prefixRows M i hi = Hex.Matrix.ofRows (Vector.ofFn fun (j : Fin (i + 1)) => M.row ⟨↑j, ⋯⟩)
Instances For
Executable row-span membership in the first i + 1 rows of a matrix.
Equations
- Hex.GramSchmidt.prefixSpan M i hi v = ∃ (c : Vector Rat (i + 1)), Hex.Matrix.vecMul c (Hex.GramSchmidt.prefixRows M i hi) = v