From d2140c5917891df45c4b70ad7d88fc62c78b1ab9 Mon Sep 17 00:00:00 2001
From: Abdullah Alperen <alperena@msu.edu>
Date: Tue, 20 Feb 2018 09:41:57 -0500
Subject: [PATCH] bug fixed in the setup of SAI

---
 sPuReMD/src/lin_alg.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/sPuReMD/src/lin_alg.c b/sPuReMD/src/lin_alg.c
index 5ddead00..23eed875 100644
--- a/sPuReMD/src/lin_alg.c
+++ b/sPuReMD/src/lin_alg.c
@@ -308,7 +308,11 @@ void setup_sparse_approx_inverse( const sparse_matrix * const A, sparse_matrix *
 
     for( i = left; i <= right ; ++i )
     {
-        list[i] = abs( A->val[i] );
+        list[i] = A->val[i];
+        if(list[i] < 0.0)
+        {
+            list[i] = -list[i];
+        }
     }
 
     turn = 0;
@@ -362,6 +366,11 @@ void setup_sparse_approx_inverse( const sparse_matrix * const A, sparse_matrix *
         }
     }
 
+    if(threshold < 1.000000)
+    {
+        threshold = 1.000001;
+    }
+
     sfree( list, "setup_sparse_approx_inverse::list" );
 
     /* fill sparsity pattern */
@@ -382,7 +391,6 @@ void setup_sparse_approx_inverse( const sparse_matrix * const A, sparse_matrix *
     }
     (*A_spar_patt)->start[A->n] = size;
 
-
     compute_full_sparse_matrix( A, A_full );
     compute_full_sparse_matrix( *A_spar_patt, A_spar_patt_full );
 
-- 
GitLab