From 019dcfc21dc74f0c735d72918731b5349a62a26a Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Sun, 3 Nov 2013 13:18:56 +0100 Subject: JacobiSVD: move from Lapack to Matlab strategy for the default threshold --- Eigen/src/SVD/JacobiSVD.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Eigen/src/SVD') 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 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 class JacobiSVD { eigen_assert(m_isInitialized || m_usePrescribedThreshold); return m_usePrescribedThreshold ? m_prescribedThreshold - : NumTraits::epsilon(); + : (std::max)(1,m_diagSize)*NumTraits::epsilon(); } inline Index rows() const { return m_rows; } @@ -918,11 +918,11 @@ struct solve_retval, Rhs> // So A^{-1} = V S^{-1} U^* Matrix 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 -- cgit v1.2.3