
Module: ppl/ppl Branch: sparse_matrices Commit: 76c398b3ee72ab472c15d19bd5db2ee3b7887a2d URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=76c398b3ee72a...
Author: Marco Poletti poletti.marco@gmail.com Date: Thu Mar 25 18:54:39 2010 +0100
PIP_Solution_Node: swap elements instead of copy-constructing them, in update_tableau().
---
src/PIP_Tree.cc | 45 ++++++++++++++++++++++++++++++--------------- 1 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/src/PIP_Tree.cc b/src/PIP_Tree.cc index 9f95009..97033ca 100644 --- a/src/PIP_Tree.cc +++ b/src/PIP_Tree.cc @@ -2255,14 +2255,19 @@ PIP_Solution_Node::update_tableau(const PIP_Problem& pip, { std::sort(buffer.begin(), buffer.end()); std::vector<std::pair<dimension_type,Coefficient> > - ::const_iterator j = buffer.begin(); + ::iterator j = buffer.begin(); std::vector<std::pair<dimension_type,Coefficient> > - ::const_iterator j_end = buffer.end(); + ::iterator j_end = buffer.end(); if (j != j_end) { - matrix_row_iterator itr = v_row.find_create(*j); + matrix_row_iterator itr = v_row.find_create(j->first); + // We need to do (*itr).second = j->second, this is faster. + std::swap((*itr).second, j->second); ++j; - for ( ; j != j_end; ++j) - itr = v_row.find_create(*j, itr); + for ( ; j != j_end; ++j) { + itr = v_row.find_create(j->first, itr); + // We need to do (*itr).second = j->second, this is faster. + std::swap((*itr).second, j->second); + } } } buffer.clear(); @@ -2302,14 +2307,19 @@ PIP_Solution_Node::update_tableau(const PIP_Problem& pip, { std::sort(buffer.begin(), buffer.end()); std::vector<std::pair<dimension_type,Coefficient> > - ::const_iterator j = buffer.begin(); + ::iterator j = buffer.begin(); std::vector<std::pair<dimension_type,Coefficient> > - ::const_iterator j_end = buffer.end(); + ::iterator j_end = buffer.end(); if (j != j_end) { - matrix_row_iterator itr = v_row.find_create(*j); + matrix_row_iterator itr = v_row.find_create(j->first); + // We need to do (*itr).second = j->second, this is faster. + std::swap((*itr).second, j->second); ++j; - for ( ; j != j_end; ++j) - itr = v_row.find_create(*j, itr); + for ( ; j != j_end; ++j) { + itr = v_row.find_create(j->first, itr); + // We need to do (*itr).second = j->second, this is faster. + std::swap((*itr).second, j->second); + } } } buffer.clear(); @@ -2324,14 +2334,19 @@ PIP_Solution_Node::update_tableau(const PIP_Problem& pip, { std::sort(buffer.begin(), buffer.end()); std::vector<std::pair<dimension_type,Coefficient> > - ::const_iterator j = buffer.begin(); + ::iterator j = buffer.begin(); std::vector<std::pair<dimension_type,Coefficient> > - ::const_iterator j_end = buffer.end(); + ::iterator j_end = buffer.end(); if (j != j_end) { - matrix_row_iterator itr = v_row.find_create(*j); + matrix_row_iterator itr = v_row.find_create(j->first); + // We need to do (*itr).second = j->second, this is faster. + std::swap((*itr).second, j->second); ++j; - for ( ; j != j_end; ++j) - itr = v_row.find_create(*j, itr); + for ( ; j != j_end; ++j) { + itr = v_row.find_create(j->first, itr); + // We need to do (*itr).second = j->second, this is faster. + std::swap((*itr).second, j->second); + } } } buffer.clear();