11#include " krbalancing.hpp"
22
3- // kr_balancing::kr_balancing(const SparseMatrixCol & input){
4- // A = input;
5- // e.resize(A.rows(),1);
6- // e.setOnes();
7- // /*Replace zeros with 0.00001 on the main diagonal*/
8- // SparseMatrixCol I;
9- // I.resize(A.rows(),A.cols());
10- // I.setIdentity();
11- // I = I*0.00001;
12- // A = A + I;
13- // rescaled = false;
14- // }
15-
163kr_balancing::kr_balancing (const int64_t &input_rows, const int64_t &input_cols,
174 const int64_t &input_nnz,
185 const Eigen::Ref<VectorXint64> input_indptr,
@@ -44,6 +31,7 @@ kr_balancing::kr_balancing(const int64_t &input_rows, const int64_t &input_cols,
4431 }
4532 A.setFromTriplets (triplets.begin (), triplets.end ()); // bottleneck
4633
34+
4735 triplets.clear ();
4836
4937 e.resize (A.rows (), 1 );
@@ -211,6 +199,7 @@ void kr_balancing::compute_normalised_matrix(bool &rescale)
211199{
212200
213201 assert (A.rows () == A.cols ());
202+
214203 if (rescale == true && rescaled == false )
215204 {
216205 rescale_norm_vector ();
@@ -227,6 +216,7 @@ void kr_balancing::compute_normalised_matrix(bool &rescale)
227216 for (SparseMatrixCol::InnerIterator it (A, k); it; ++it)
228217 {
229218 it.valueRef () = it.value () * x.coeff (it.row (), 0 ) * x.coeff (it.col (), 0 );
219+
230220 }
231221 }
232222}
@@ -258,7 +248,6 @@ void kr_balancing::rescale_norm_vector()
258248 }
259249 }
260250 }
261-
262251 std::cout << " normalisation factor is " << std::sqrt (norm_vector_sum / original_sum) << std::endl;
263252 x /= std::sqrt (norm_vector_sum / original_sum);
264253}
@@ -274,6 +263,7 @@ const SparseMatrixCol *kr_balancing::get_normalisation_vector(bool &rescale)
274263
275264 if (rescale == true && rescaled == false )
276265 {
266+
277267 rescale_norm_vector ();
278268 rescaled = true ;
279269 }
0 commit comments