]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 20 Jun 2016 22:32:27 +0000 (17:32 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 20 Jun 2016 22:32:27 +0000 (17:32 -0500)
lib/cpExtensions/Algorithms/IterativeGaussianModelEstimator.hxx

index a297c3cad08bbeb33de78329dd7480bb447f59f9..254d201452ec6cd5ac5ad1cfa7f8215334dd4b11 100644 (file)
@@ -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