[PPL-devel] [GIT] ppl/ppl(sparse_matrices): PIP_Solution_Node: optimize update_solution () method for sparse matrices.
Marco Poletti
poletti.marco at gmail.com
Sun Mar 14 21:50:14 CET 2010
Module: ppl/ppl
Branch: sparse_matrices
Commit: b57748fb891db5dffb5befcda20d153c8dbd6846
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=b57748fb891db5dffb5befcda20d153c8dbd6846
Author: Marco Poletti <poletti.marco at gmail.com>
Date: Sun Mar 14 21:24:36 2010 +0100
PIP_Solution_Node: optimize update_solution() method for sparse matrices.
---
src/PIP_Tree.cc | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/PIP_Tree.cc b/src/PIP_Tree.cc
index 1fc81d3..8e470b2 100644
--- a/src/PIP_Tree.cc
+++ b/src/PIP_Tree.cc
@@ -3647,16 +3647,19 @@ PIP_Solution_Node
continue;
matrix_row_const_reference_type row = tableau.t[mapping[i]];
- for (dimension_type j = num_all_params; j-- > 0; ) {
- // NOTE: add 1 to column index to account for inhomogenous term.
- const Coefficient& coeff = row[j+1];
+ // Start from index 1 to skip the inhomogenous term.
+ matrix_const_row_const_iterator j = row.lower_bound(1);
+ matrix_const_row_const_iterator j_end = row.end();
+ for ( ; j!=j_end; ++j) {
+ const Coefficient& coeff = (*j).second;
if (coeff == 0)
continue;
norm_coeff = coeff / den;
if (norm_coeff != 0)
- add_mul_assign(sol_i, norm_coeff, Variable(all_param_names[j]));
+ add_mul_assign(sol_i, norm_coeff,
+ Variable(all_param_names[(*j).first-1]));
}
- norm_coeff = row[0] / den;
+ norm_coeff = row.get(0) / den;
sol_i += norm_coeff;
}
More information about the PPL-devel
mailing list