Replace the fixed 5x5 SVD implementation with template <uint8_t N>
building blocks over Matrix<N,N> working buffers (N = max(rows, cols)),
removing the 5x5 size limit. Public API (SVD::SVD) is unchanged and the
whole path stays heap-free: peak stack is ~11*N^2 floats, budgeted in
the SVD.hpp header doc.
Fixes found while porting/validating the templated rewrite:
- QL.Identity() was a no-op (static factory returns by value); init
the Householder accumulators with an explicit diagonal loop
- restore the QL column sign-flip in ExtractAndSortSingularValues for
negative unsolved W diagonal entries (Householder sign flips)
- T = B^T B tridiagonal formula: T[i][i] = d[i]^2 + e[i-1]^2 only
(e[i] contributes to T[i+1][i+1], not T[i][i])
- wide-matrix Vt assembly: Vt = QL^T must be filled over the full
m x m (m = columns of A), not just the top n x n
Tests:
- matrix-tests: add large-size instantiation cases beyond the old limit
(tall 7x5 N=7, square 6x6 N=6, wide 5x8 N=8 transpose path with full
orthogonal 8x8 Vt, tall 6x4 near rank-deficient N=6 deflation path),
all checked against numpy/scipy float32 references
- svd-build-blocks-tests: adapt Jacobi test to the Matrix<N,N> interface
- svd-reference-values.py: add the four new reference matrices
- src/QR.hpp / src/QR.cpp: fully templated QR::EigenQR (N >= 2), no heap
allocation (3*N^2 float working buffers on stack). Givens tridiagonalization
(bottom-up) + implicit Wilkinson-shifted QR with bulge chasing, relative
deflation, exact-zero peeling, closed-form 2x2 termination.
- Matrix::EigenQR now delegates to QR::EigenQR (old unshifted body removed);
eigenvalues sorted descending, eigenvectors in columns of the output.
- unit-tests/qr-build-blocks-tests.cpp: 8 building-block test cases
(215 assertions) with scipy/numpy references.
- unit-tests/qr-reference-values.py: numpy/scipy reference generator mirroring
every building block and the full pipeline (eigh, n=3..8).
- CMake: new 'qr' static library; Matrix links against it;
qr-build-blocks-tests target enabled.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
@@ -8,0 +12,4 @@// chain, pull in the full QR library so its template definition is available.namespace QR {template <uint8_t N>void EigenQR(Matrix<N, N> &matrixToDecompose, Matrix<N, N> &eigenVectors,TODO: THis is weird.
No it makes sense because there is a bit of a circular include here.
Matrix.cpp -> includes QR.hpp -> includes Matrix.hpp -> includes Matrix.cpp