ab0cea104cf4f562f877021836ba01a92348a5f1
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
Introduction
This matrix math library is focused on embedded development and avoids any heap memory allocation unless you explicitly ask for it. It uses templates to pre-allocate matrices on the stack.
Building
- Initialize the repositiory with the command:
cmake -S . -B build -G Ninja
- Go into the build folder and run
ninja - That's it. You can test out the build by running
./unit-tests/matrix-tests
Languages
C++
89%
Python
10.1%
CMake
0.9%