mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Fix a bug in the 3x3 direct eigensolver's Gram-Schmidt orthogonalization for near-degenerate eigenvalues. The code was subtracting the projection onto eivecs.col(l) (itself) instead of onto eivecs.col(k): // Before (bug): subtracts scalar multiple of self — does nothing useful eivecs.col(l) -= eivecs.col(k).dot(eivecs.col(l)) * eivecs.col(l); // After (fix): removes component along eivecs.col(k) eivecs.col(l) -= eivecs.col(k).dot(eivecs.col(l)) * eivecs.col(k); This path is taken when two of three eigenvalues are nearly equal, which is common for covariance matrices of near-planar point clouds. Also add comprehensive small fixed-size matrix benchmarks covering the operations that dominate robotics/CV inner loops: matmul, matvec, inverse, determinant, LLT, LDLT, PartialPivLU, ColPivHouseholderQR, JacobiSVD, SelfAdjointEigenSolver (iterative and direct) for sizes 2x2 through 8x9. Note: the direct 3x3 eigensolver (computeDirect) is 3x faster than the iterative solver but has 5-6 orders of magnitude worse residuals for near-degenerate eigenvalues. This is inherent to the closed-form algorithm, not a consequence of the Gram-Schmidt bug. Users should prefer compute() when accuracy matters and computeDirect() only when speed is critical and eigenvalues are well-separated. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>