From f2f3ec70cd3c86583c1eb03b0da63f74b6aefe05 Mon Sep 17 00:00:00 2001 From: bremner Date: Tue, 11 Jul 2006 11:15:06 +0000 Subject: git-svn-id: file:///export/data/bremner/svn/trunk/inetools@5464 09fa754a-f411-0410-976a-da6bfa213b30 --- Makefile | 11 ++++++++--- README | 8 ++++++-- rat2canon.c | 50 ++++++++------------------------------------------ 3 files changed, 22 insertions(+), 47 deletions(-) diff --git a/Makefile b/Makefile index 8c7e98d..db57b12 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ .SUFFIXES: .doc .h -BIN= rat2float float2rat rat2canon countrows +BIN= rat2float float2rat rat2canon countrows rat2int MPOBJ= DOCHEADERS=rat2float.h float2rat.h rat2canon.h countrows.h @@ -43,8 +43,13 @@ rat2float: rat2float.c rat2float.h $(MPOBJ) process_args.o rat2canon.h: rat2canon.doc -rat2canon: rat2canon.c rat2canon.h process_args.o $(MPOBJ) - $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ process_args.o $(MPOBJ) $(LDFLAGS) $< +rat2canon: rat2canon.c rat2canon.h process_args.o ine_io.o $(MPOBJ) + $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ process_args.o ine_io.o $(MPOBJ) $(LDFLAGS) $< + +rat2int.h: rat2int.doc + +rat2int: rat2int.c rat2int.h process_args.o ine_io.o $(MPOBJ) + $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ process_args.o ine_io.o $(MPOBJ) $(LDFLAGS) $< countrows.h: countrows.doc diff --git a/README b/README index 2fd0250..52b061d 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ $Id$ -Release 0.8 +Release 0.9 This directory contains some tools for manipulating lrs/cdd ine files. @@ -22,6 +22,8 @@ At the moment there is rat2canon put the inequalities/vectors in a canonical form This one only compiles with multiprecision support + rat2int convert all rows to integer. This makes more sense for + inequalities. Multiprecision only rat2float convert to floating point. Note that this necessarily loses precision. Also, @@ -30,7 +32,9 @@ At the moment there is multiprecision support. -NEW for release 0.7: +NEWS + +Release 0.7: All utilities take optional parameters for input file and output file. diff --git a/rat2canon.c b/rat2canon.c index bc38132..4225462 100644 --- a/rat2canon.c +++ b/rat2canon.c @@ -51,62 +51,26 @@ int main(argc,argv) char **argv; { int i,j; - - char format[BUFSIZ]; - char buf[BUFSIZ]; - - - char *cursor; - + char *ok[]={ "integer", "rational" }; + char *type; + char buf[BUFSIZ]; process_args(argc,argv,DOCSTRING); - - lrs_mp_init (MP_DIGITS,stdin,stdout); - while ( fgets(buf,BUFSIZ,stdin) !=NULL ) - { - fputs(buf,stdout); - for (cursor=buf; isblank(*cursor); cursor++); - if (strncmp(cursor,"begin",5)==0) break; - } - - if (fgets(buf,BUFSIZ,stdin)==NULL) { - fprintf(stderr,"No parameter line"); - exit(1); - } + scan_for_begin(&m,&n,&type); + check_type(type, ok, 2); - m=strtol(buf,&cursor,10); - if (errno==ERANGE || m==0){ - fprintf(stderr,"Missing or absurd row count"); - exit(1); - } - An=calloc(m,sizeof(lrs_mp*)); Ad=calloc(m,sizeof(lrs_mp*)); rows=calloc(m,sizeof(int)); - n=strtol(cursor,&cursor,10); - if (errno==ERANGE || m==0){ - fprintf(stderr,"Missing or absurd column count"); - exit(1); - } for (i=0; i