/* * Reads a polyhedron file on stdin with rationals and outputs * a canonical form with normalized rhs and sorted constraints. * * David Bremner. bremner@unb.ca * */ #ifndef LRSMP #error This file only compiles with LRSMP #endif #include #include #include #include #include #include "lrsmp.h" #include "ine_io.h" #include "process_args.h" typedef lrs_mp integer_t; #define MP_DIGITS 1000L #include "rat2canon.h" static int *rows=NULL; static int m,n; static lrs_mp **An; static lrs_mp **Ad; int cmprow(const void *i_p,const void *j_p){ int i=*(int *)i_p; int j=*(int *)j_p; int cval; int k=0; /* the trick here is that the denominators are always positive */ while( k< n && ( cval=comprod(An[i][k],Ad[j][k],An[j][k],Ad[i][k])) == 0){ k++; } return cval; } int main(argc,argv) int argc; char **argv; { int i,j; char format[BUFSIZ]; char *ok[]={ "integer", "rational" }; char *type; char buf[BUFSIZ]; process_args(argc,argv,DOCSTRING); lrs_mp_init (MP_DIGITS,stdin,stdout); scan_for_begin(&m,&n,&type); check_type(type, ok, 2); An=calloc(m,sizeof(lrs_mp*)); Ad=calloc(m,sizeof(lrs_mp*)); rows=calloc(m,sizeof(int)); for (i=0; i