Cynopolis ab0cea104c Templatize SVD on N: support any Matrix<R,C> with stack-only buffers
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
2026-08-20 10:22:49 -04:00
2025-05-21 17:46:49 -04:00
2025-06-30 14:52:48 -04:00

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

  1. Initialize the repositiory with the command:
cmake -S . -B build -G Ninja
  1. Go into the build folder and run ninja
  2. That's it. You can test out the build by running ./unit-tests/matrix-tests
S
Description
A light weight C++ object for 3d math operations on embedded platforms
Readme
1.4 MiB
Languages
C++ 89%
Python 10.1%
CMake 0.9%