# Computing Singular Value Decomposition of small ($4\times 4$) matrices

I need to compute the Singular Value Decomposition (SVD) of many $$4 \times 4$$ matrices. I'm looking for SVD algorithms specialized for small matrices. I've read that the std::vector sorting algorithm in the C++ STL is often hardcoded for short vectors for optimal performance. I want to hard code the SVD for the case $$4 \times 4$$ matrices.

What information is there about optimally solving small cases of SVD?

• – Federico Poloni Sep 10 '20 at 8:17
• That said, I would be skeptical of anything that does not rely on orthogonal transformations, even if it claims to be 'closed-form'. – Federico Poloni Sep 10 '20 at 8:21
• The Eigen library provides templates to perform SVD on fixed-size matrices. This will save some memory, and may provide some performance advantage with vectorized operations. I think Eigen::JacobiSVD<Matrix<float, 4, 4>, Eigen::NoQRPreconditioner> would be optimal for your problem, as no preconditioner is required for square matrices. eigen.tuxfamily.org/dox/classEigen_1_1JacobiSVD.html – Charlie S Sep 10 '20 at 12:52