[PPL-devel] [GIT] ppl/ppl(master): PIP_Tree: avoid repeated calls to Sparse_Row::get(), in solve().
Marco Poletti
poletti.marco at gmail.com
Mon Feb 14 19:45:45 CET 2011
Module: ppl/ppl
Branch: master
Commit: 24b68b1c48e4552f1085d9a04979e610c8ca79ca
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=24b68b1c48e4552f1085d9a04979e610c8ca79ca
Author: Marco Poletti <poletti.marco at gmail.com>
Date: Mon Feb 14 19:45:34 2011 +0100
PIP_Tree: avoid repeated calls to Sparse_Row::get(), in solve().
---
src/PIP_Tree.cc | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/PIP_Tree.cc b/src/PIP_Tree.cc
index 58fc66b..2660877 100644
--- a/src/PIP_Tree.cc
+++ b/src/PIP_Tree.cc
@@ -2643,20 +2643,23 @@ PIP_Solution_Node::solve(const PIP_Problem& pip,
for (dimension_type i = num_rows; i-- > 0; ) {
Row& s_i = tableau.s[i];
Row& t_i = tableau.t[i];
+ Coefficient s_i_pj = s_i.get(pj);
Row::iterator k = t_i.end();
for (Row::const_iterator
j = t_pivot.begin(), j_end = t_pivot.end(); j != j_end; ++j) {
Coefficient_traits::const_reference t_pivot_j = *j;
// Do nothing if the j-th pivot element is zero.
if (t_pivot_j != 0) {
- /* NOTE: s_i[pj] needs to be recomputed at each iteration,
- as it may have been modified by tableau.scale(). */
- product = t_pivot_j * s_i.get(pj);
+ product = t_pivot_j * s_i_pj;
if (product % s_pivot_pj != 0) {
// Must scale matrix to stay in integer case.
gcd_assign(gcd, product, s_pivot_pj);
exact_div_assign(scale_factor, s_pivot_pj, gcd);
tableau.scale(scale_factor);
+ // s_i[pj] has been modified by scale(), so s_i_pj must be
+ // updated.
+ s_i_pj *= scale_factor;
+ PPL_ASSERT(s_i.get(pj) == s_i_pj);
product *= scale_factor;
}
PPL_ASSERT(product % s_pivot_pj == 0);
More information about the PPL-devel
mailing list