InvertPSDMatrix uses dynamic matrices when using SVD

The JacobiSVD algorithm in Eigen does not accept fixed sized
matrices when performing a thin SVD. The assert enforcing this
is only triggered in non-Release builds.

So this change calls JacobiSVD with dynamically sized matrices
as a template parameter rather than a fixed size matrix.

https://github.com/ceres-solver/ceres-solver/issues/304#issuecomment-317965814

Thanks to @debalance for reporting this and @leokoppel for
providing a reproduction.

Change-Id: Ifc3d9ff20d5597f08c0f8573bf2fd99a3ed3d4d3
This commit is contained in:
Sameer Agarwal
2017-07-26 21:03:34 -07:00
parent 87f823617e
commit f402c17247
+1 -2
View File
@@ -60,8 +60,7 @@ typename EigenTypes<kSize, kSize>::Matrix InvertPSDMatrix(
Matrix::Identity(size, size));
}
Eigen::JacobiSVD<typename EigenTypes<kSize, kSize>::Matrix> svd(
m, Eigen::ComputeThinU | Eigen::ComputeThinV);
Eigen::JacobiSVD<Matrix> svd(m, Eigen::ComputeThinU | Eigen::ComputeThinV);
const double tolerance =
std::numeric_limits<double>::epsilon() * size * svd.singularValues()(0);