[PPL-devel] [GIT] ppl/ppl(sparse_matrices): PIP_Tree: optimize static function merge_assign() for sparse matrices.
Marco Poletti
poletti.marco at gmail.com
Tue Mar 9 14:11:07 CET 2010
Module: ppl/ppl
Branch: sparse_matrices
Commit: 11194ae3cfe869768989cd1b1f6b10d92483758b
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=11194ae3cfe869768989cd1b1f6b10d92483758b
Author: Marco Poletti <poletti.marco at gmail.com>
Date: Tue Mar 9 13:48:25 2010 +0100
PIP_Tree: optimize static function merge_assign() for sparse matrices.
---
src/PIP_Tree.cc | 23 +++++++++++++++++++++--
1 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/src/PIP_Tree.cc b/src/PIP_Tree.cc
index 9137180..c14f369 100644
--- a/src/PIP_Tree.cc
+++ b/src/PIP_Tree.cc
@@ -172,14 +172,33 @@ merge_assign(PIP_Tree_Node::matrix_type& x,
y_end = y.end(); y_i != y_end; ++y_i, ++i) {
PPL_ASSERT(y_i->is_nonstrict_inequality());
PIP_Tree_Node::matrix_row_reference_type x_i = x[i];
- x_i[0] = y_i->inhomogeneous_term();
+ const Coefficient& inhomogeneous_term = y_i->inhomogeneous_term();
+ if (inhomogeneous_term != 0)
+ x_i[0] = inhomogeneous_term;
Variables_Set::const_iterator pj;
dimension_type j = 1;
+ PIP_Tree_Node::matrix_row_iterator last = x_i.begin();
for (pj = param_begin; pj != param_end; ++pj, ++j) {
Variable vj(*pj);
if (vj.space_dimension() > cs_space_dim)
break;
- x_i[j] = y_i->coefficient(vj);
+ const Coefficient& c = y_i->coefficient(vj);
+ if (c != 0) {
+ last = x_i.find_create(j,c);
+ ++pj;
+ ++j;
+ break;
+ }
+ }
+ for ( ; pj != param_end; ++pj, ++j) {
+ Variable vj(*pj);
+ if (vj.space_dimension() > cs_space_dim)
+ break;
+ const Coefficient& c = y_i->coefficient(vj);
+ if (c != 0) {
+ last = x_i.find_create(j,c,last);
+ break;
+ }
}
}
}
More information about the PPL-devel
mailing list