[PPL-devel] [GIT] ppl/ppl(pip): Implemented the Rational_Matrix normalize method.
François Galea
francois.galea at uvsq.fr
Wed Sep 16 20:18:34 CEST 2009
Module: ppl/ppl
Branch: pip
Commit: 1024999dddcc6d7646b0f7bf26f0255652babad4
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=1024999dddcc6d7646b0f7bf26f0255652babad4
Author: François Galea <francois.galea at uvsq.fr>
Date: Wed Sep 16 18:21:41 2009 +0200
Implemented the Rational_Matrix normalize method.
---
src/PIP_Tree.cc | 30 +++++++++++++++++++++++++++++-
1 files changed, 29 insertions(+), 1 deletions(-)
diff --git a/src/PIP_Tree.cc b/src/PIP_Tree.cc
index d528d37..8578048 100644
--- a/src/PIP_Tree.cc
+++ b/src/PIP_Tree.cc
@@ -298,7 +298,35 @@ PIP_Decision_Node::solve(PIP_Tree_Node*& parent_ref, const Matrix& context) {
void
PIP_Solution_Node::Rational_Matrix::normalize() {
- //FIXME
+ if (denominator == 1)
+ return;
+ dimension_type i_max = num_rows();
+ dimension_type j_max = num_columns();
+ dimension_type i, j;
+ PPL_DIRTY_TEMP_COEFFICIENT(gcd);
+ gcd = denominator;
+
+ for (i=0; i<i_max; ++i) {
+ const Row &row = rows[i];
+ for (j=0; j<j_max; ++j) {
+ const Coefficient &x = row[j];
+ if (x != 0) {
+ gcd_assign(gcd, x, gcd);
+ if (gcd == 1)
+ return;
+ }
+ }
+ }
+
+ // Divide the coefficients by the GCD.
+ for (i=0; i<i_max; ++i) {
+ Row &row = rows[i];
+ for (j=0; j<j_max; ++j) {
+ Coefficient &x = row[j];
+ exact_div_assign(x, x, gcd);
+ }
+ }
+ exact_div_assign(denominator, denominator, gcd);
}
void
More information about the PPL-devel
mailing list