
Module: ppl/ppl Branch: sparse_matrices Commit: 742786aa3e321f73f0494b8293ede324b8edf5fe URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=742786aa3e321...
Author: Marco Poletti poletti.marco@gmail.com Date: Tue Mar 16 13:46:20 2010 +0100
PIP_Solution_Node::Tableau: optimize scale() method for sparse matrices.
---
src/PIP_Tree.cc | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/PIP_Tree.cc b/src/PIP_Tree.cc index e448c5b..5cd9ad0 100644 --- a/src/PIP_Tree.cc +++ b/src/PIP_Tree.cc @@ -1557,12 +1557,20 @@ PIP_Solution_Node::Tableau::normalize() { void PIP_Solution_Node::Tableau::scale(Coefficient_traits::const_reference ratio) { for (dimension_type i = s.num_rows(); i-- > 0; ) { - matrix_row_reference_type s_i = s[i]; - for (dimension_type j = s.num_columns(); j-- > 0; ) - s_i[j] *= ratio; - matrix_row_reference_type t_i = t[i]; - for (dimension_type j = t.num_columns(); j-- > 0; ) - t_i[j] *= ratio; + { + matrix_row_reference_type s_i = s[i]; + matrix_row_iterator j = s_i.begin(); + matrix_row_iterator j_end = s_i.end(); + for ( ; j!=j_end; ++j) + (*j).second *= ratio; + } + { + matrix_row_reference_type t_i = t[i]; + matrix_row_iterator j = t_i.begin(); + matrix_row_iterator j_end = t_i.end(); + for ( ; j!=j_end; ++j) + (*j).second *= ratio; + } } denom *= ratio; }