8 using Eigen::ComputeFullV;
9 using Eigen::ComputeThinU;
10 using Eigen::ComputeThinV;
13 const double threshold) {
14 SVD_t svd(_inputMatrix, ComputeThinU | ComputeThinV);
15 SVD_t::SingularValuesType m_singularValues = svd.singularValues();
16 SVD_t::SingularValuesType singularValues_inv;
17 singularValues_inv.resizeLike(m_singularValues);
18 for (
long i = 0;
i < m_singularValues.size(); ++
i) {
19 if (m_singularValues(
i) > threshold)
20 singularValues_inv(
i) = 1.0 / m_singularValues(
i);
22 singularValues_inv(
i) = 0;
24 _inverseMatrix = (svd.matrixV() * singularValues_inv.asDiagonal() *
25 svd.matrixU().transpose());
29 const double threshold) {
30 typedef SVD_t::SingularValuesType SV_t;
31 Eigen::ArrayWrapper<const SV_t> sigmas(svd.singularValues());
33 SV_t sv_inv(sigmas / (sigmas.cwiseAbs2() + threshold * threshold));
36 _inverseMatrix.noalias() = (svd.matrixV().leftCols(m) * sv_inv.asDiagonal() *
37 svd.matrixU().leftCols(m).transpose());
42 const double threshold) {
43 SVD_t svd(_inputMatrix, ComputeThinU | ComputeThinV);
49 Sref = svd.singularValues();
53 const double threshold) {
54 SVD_t svd(_inputMatrix, ComputeThinU | ComputeFullV);
Eigen::JacobiSVD< Matrix > SVD_t
void pseudoInverse(Matrix &_inputMatrix, Matrix &_inverseMatrix, const double threshold=1e-6)
void dampedInverse(const SVD_t &svd, Matrix &_inverseMatrix, const double threshold=1e-6)