diff options
author | Gael Guennebaud <g.gael@free.fr> | 2015-03-23 09:40:21 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2015-03-23 09:40:21 +0100 |
commit | 4472f3e57884202b52c551da0b294c2883e2ccbf (patch) | |
tree | 67e3ba0861ba4f16b89a2fe515f57cc805d56dba /Eigen/src/SVD | |
parent | 4e2b18d909f27f03f64c5fd8891f2e94c5e03802 (diff) |
Avoid SVD: consider denormalized small numbers as zero when computing the rank of the matrix
Diffstat (limited to 'Eigen/src/SVD')
-rw-r--r-- | Eigen/src/SVD/SVDBase.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Eigen/src/SVD/SVDBase.h b/Eigen/src/SVD/SVDBase.h index b89393721..ad191085e 100644 --- a/Eigen/src/SVD/SVDBase.h +++ b/Eigen/src/SVD/SVDBase.h @@ -130,9 +130,10 @@ public: inline Index rank() const { using std::abs; + using std::max; eigen_assert(m_isInitialized && "JacobiSVD is not initialized."); if(m_singularValues.size()==0) return 0; - RealScalar premultiplied_threshold = m_singularValues.coeff(0) * threshold(); + RealScalar premultiplied_threshold = (max)(m_singularValues.coeff(0) * threshold(), (std::numeric_limits<RealScalar>::min)()); Index i = m_nonzeroSingularValues-1; while(i>=0 && m_singularValues.coeff(i) < premultiplied_threshold) --i; return i+1; |