quick reimplementation of SVD from the numeral recipes book:

this is still not Eigen style code but at least it works for
n>m and it is more accurate than the JAMA based version. (I needed
it now, this is why I did that)
This commit is contained in:
Gael Guennebaud
2009-07-06 13:47:41 +02:00
parent 0cd158820c
commit 0c2232e5d9
3 changed files with 254 additions and 350 deletions

View File

@@ -50,7 +50,7 @@ template<typename MatrixType> void svd(const MatrixType& m)
MatrixType sigma = MatrixType::Zero(rows,cols);
MatrixType matU = MatrixType::Zero(rows,rows);
sigma.block(0,0,cols,cols) = svd.singularValues().asDiagonal();
matU.block(0,0,rows,cols) = svd.matrixU();
matU = svd.matrixU();
VERIFY_IS_APPROX(a, matU * sigma * svd.matrixV().transpose());
}