diff options
author | Gael Guennebaud <g.gael@free.fr> | 2013-11-03 13:18:56 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2013-11-03 13:18:56 +0100 |
commit | 019dcfc21dc74f0c735d72918731b5349a62a26a (patch) | |
tree | c0eec562f65934030e25453427e6c32b21cb7bac /Eigen | |
parent | 19521c83b8d5c9b0567ceadebe7ad4b1119dd7cc (diff) |
JacobiSVD: move from Lapack to Matlab strategy for the default threshold
Diffstat (limited to 'Eigen')
-rw-r--r-- | Eigen/src/SVD/JacobiSVD.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Eigen/src/SVD/JacobiSVD.h b/Eigen/src/SVD/JacobiSVD.h index fcf404587..98a3ba22a 100644 --- a/Eigen/src/SVD/JacobiSVD.h +++ b/Eigen/src/SVD/JacobiSVD.h @@ -530,7 +530,7 @@ template<typename _MatrixType, int QRPreconditioner> class JacobiSVD m_isAllocated(false), m_usePrescribedThreshold(false), m_computationOptions(0), - m_rows(-1), m_cols(-1) + m_rows(-1), m_cols(-1), m_diagSize(0) {} @@ -726,7 +726,7 @@ template<typename _MatrixType, int QRPreconditioner> class JacobiSVD { eigen_assert(m_isInitialized || m_usePrescribedThreshold); return m_usePrescribedThreshold ? m_prescribedThreshold - : NumTraits<Scalar>::epsilon(); + : (std::max<Index>)(1,m_diagSize)*NumTraits<Scalar>::epsilon(); } inline Index rows() const { return m_rows; } @@ -918,11 +918,11 @@ struct solve_retval<JacobiSVD<_MatrixType, QRPreconditioner>, Rhs> // So A^{-1} = V S^{-1} U^* Matrix<Scalar, Dynamic, Rhs::ColsAtCompileTime, 0, _MatrixType::MaxRowsAtCompileTime, Rhs::MaxColsAtCompileTime> tmp; - Index nonzeroSingVals = dec().rank(); + Index rank = dec().rank(); - tmp.noalias() = dec().matrixU().leftCols(nonzeroSingVals).adjoint() * rhs(); - tmp = dec().singularValues().head(nonzeroSingVals).asDiagonal().inverse() * tmp; - dst = dec().matrixV().leftCols(nonzeroSingVals) * tmp; + tmp.noalias() = dec().matrixU().leftCols(rank).adjoint() * rhs(); + tmp = dec().singularValues().head(rank).asDiagonal().inverse() * tmp; + dst = dec().matrixV().leftCols(rank) * tmp; } }; } // end namespace internal |