From 08c5c8493f8197c892ad3843a729422ed02d2aa3 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Tue, 2 Oct 2007 16:02:21 +0200 Subject: [PATCH] export neg_left_hermite --- barvinok/util.h | 1 + topcom.c | 35 ----------------------------------- util.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 35 deletions(-) diff --git a/barvinok/util.h b/barvinok/util.h index 231d23d..29d4148 100644 --- a/barvinok/util.h +++ b/barvinok/util.h @@ -65,6 +65,7 @@ evalue* ParamLine_Length(Polyhedron *P, Polyhedron *C, struct barvinok_options *options); void Extended_Euclid(Value a, Value b, Value *x, Value *y, Value *g); int unimodular_complete(Matrix *M, int row); +void neg_left_hermite(Matrix *A, Matrix **H_p, Matrix **Q_p, Matrix **U_p); Bool isIdentity(Matrix *M); void Param_Polyhedron_Print(FILE* DST, Param_Polyhedron *PP, char **param_names); void Enumeration_Print(FILE *Dst, Enumeration *en, const char * const *params); diff --git a/topcom.c b/topcom.c index dc92b44..47bea41 100644 --- a/topcom.c +++ b/topcom.c @@ -359,41 +359,6 @@ static Matrix *null_space(Matrix *M) return N; } -/* - * left_hermite may leave positive entries below the main diagonal in H. - * This function postprocesses the output of left_hermite to make - * the non-zero entries below the main diagonal negative. - */ -static void neg_left_hermite(Matrix *A, Matrix **H_p, Matrix **Q_p, Matrix **U_p) -{ - int row, col, i, j; - Matrix *H, *U, *Q; - - left_hermite(A, &H, &Q, &U); - *H_p = H; - *Q_p = Q; - *U_p = U; - - for (row = 0, col = 0; col < H->NbColumns; ++col, ++row) { - while (value_zero_p(H->p[row][col])) - ++row; - for (i = 0; i < col; ++i) { - if (value_negz_p(H->p[row][i])) - continue; - - /* subtract column col from column i in H and U */ - for (j = 0; j < H->NbRows; ++j) - value_subtract(H->p[j][i], H->p[j][i], H->p[j][col]); - for (j = 0; j < U->NbRows; ++j) - value_subtract(U->p[j][i], U->p[j][i], U->p[j][col]); - - /* add row i to row col in Q */ - for (j = 0; j < Q->NbColumns; ++j) - value_addto(Q->p[col][j], Q->p[col][j], Q->p[i][j]); - } - } -} - static void SwapColumns(Value **V, int n, int i, int j) { int r; diff --git a/util.c b/util.c index 4b63e84..6cf4b78 100644 --- a/util.c +++ b/util.c @@ -481,6 +481,41 @@ int unimodular_complete(Matrix *M, int row) } /* + * left_hermite may leave positive entries below the main diagonal in H. + * This function postprocesses the output of left_hermite to make + * the non-zero entries below the main diagonal negative. + */ +void neg_left_hermite(Matrix *A, Matrix **H_p, Matrix **Q_p, Matrix **U_p) +{ + int row, col, i, j; + Matrix *H, *U, *Q; + + left_hermite(A, &H, &Q, &U); + *H_p = H; + *Q_p = Q; + *U_p = U; + + for (row = 0, col = 0; col < H->NbColumns; ++col, ++row) { + while (value_zero_p(H->p[row][col])) + ++row; + for (i = 0; i < col; ++i) { + if (value_negz_p(H->p[row][i])) + continue; + + /* subtract column col from column i in H and U */ + for (j = 0; j < H->NbRows; ++j) + value_subtract(H->p[j][i], H->p[j][i], H->p[j][col]); + for (j = 0; j < U->NbRows; ++j) + value_subtract(U->p[j][i], U->p[j][i], U->p[j][col]); + + /* add row i to row col in Q */ + for (j = 0; j < Q->NbColumns; ++j) + value_addto(Q->p[col][j], Q->p[col][j], Q->p[i][j]); + } + } +} + +/* * Returns a full-dimensional polyhedron with the same number * of integer points as P */ -- 2.11.4.GIT