1
1
#include " krbalancing.hpp"
2
2
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
-
16
3
kr_balancing::kr_balancing (const int64_t &input_rows, const int64_t &input_cols,
17
4
const int64_t &input_nnz,
18
5
const Eigen::Ref<VectorXint64> input_indptr,
@@ -44,6 +31,7 @@ kr_balancing::kr_balancing(const int64_t &input_rows, const int64_t &input_cols,
44
31
}
45
32
A.setFromTriplets (triplets.begin (), triplets.end ()); // bottleneck
46
33
34
+
47
35
triplets.clear ();
48
36
49
37
e.resize (A.rows (), 1 );
@@ -211,6 +199,7 @@ void kr_balancing::compute_normalised_matrix(bool &rescale)
211
199
{
212
200
213
201
assert (A.rows () == A.cols ());
202
+
214
203
if (rescale == true && rescaled == false )
215
204
{
216
205
rescale_norm_vector ();
@@ -227,6 +216,7 @@ void kr_balancing::compute_normalised_matrix(bool &rescale)
227
216
for (SparseMatrixCol::InnerIterator it (A, k); it; ++it)
228
217
{
229
218
it.valueRef () = it.value () * x.coeff (it.row (), 0 ) * x.coeff (it.col (), 0 );
219
+
230
220
}
231
221
}
232
222
}
@@ -258,7 +248,6 @@ void kr_balancing::rescale_norm_vector()
258
248
}
259
249
}
260
250
}
261
-
262
251
std::cout << " normalisation factor is " << std::sqrt (norm_vector_sum / original_sum) << std::endl;
263
252
x /= std::sqrt (norm_vector_sum / original_sum);
264
253
}
@@ -274,6 +263,7 @@ const SparseMatrixCol *kr_balancing::get_normalisation_vector(bool &rescale)
274
263
275
264
if (rescale == true && rescaled == false )
276
265
{
266
+
277
267
rescale_norm_vector ();
278
268
rescaled = true ;
279
269
}
0 commit comments