From d610d96888c9bf3f6d3ca968c3dbb821eb9db58c Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Mon, 20 Jun 2016 17:32:27 -0500 Subject: [PATCH] ... --- .../Algorithms/IterativeGaussianModelEstimator.hxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/cpExtensions/Algorithms/IterativeGaussianModelEstimator.hxx b/lib/cpExtensions/Algorithms/IterativeGaussianModelEstimator.hxx index a297c3c..254d201 100644 --- a/lib/cpExtensions/Algorithms/IterativeGaussianModelEstimator.hxx +++ b/lib/cpExtensions/Algorithms/IterativeGaussianModelEstimator.hxx @@ -242,8 +242,15 @@ _SquaredMahalanobis( const TVector& v ) const { if( !this->m_InverseUpdated ) { - this->m_InverseUnbiasedCovariance = - this->m_UnbiasedCovariance.GetInverse( ); + double d = + double( + vnl_determinant( this->m_UnbiasedCovariance.GetVnlMatrix( ) ) + ); + if( std::fabs( d ) > double( 0 ) ) + this->m_InverseUnbiasedCovariance = + this->m_UnbiasedCovariance.GetInverse( ); + else + this->m_InverseUnbiasedCovariance.SetIdentity( ); this->m_InverseUpdated = true; } // fi -- 2.45.1