aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbremner <bremner@09fa754a-f411-0410-976a-da6bfa213b30>2006-07-11 11:15:06 +0000
committerbremner <bremner@09fa754a-f411-0410-976a-da6bfa213b30>2006-07-11 11:15:06 +0000
commitf2f3ec70cd3c86583c1eb03b0da63f74b6aefe05 (patch)
treeb7ca132811f02c0d88df78ccfa938cbb74d6086b
parent8f05bec6673c1d3e7fdce52e305b712bd6f989ac (diff)
git-svn-id: file:///export/data/bremner/svn/trunk/inetools@5464 09fa754a-f411-0410-976a-da6bfa213b30
-rw-r--r--Makefile11
-rw-r--r--README8
-rw-r--r--rat2canon.c50
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<m; i++){
rows[i]=i;
An[i]=calloc(n,sizeof(lrs_mp));
Ad[i]=calloc(n,sizeof(lrs_mp));
}
-
- while (isblank(*cursor)){
- cursor++;
- }
-
- if (strncmp(cursor,"integer",7) != 0 && strncmp(cursor,"rational",8)){
- fprintf(stderr,"oops. I don't know what to do with a file of type %s\n",
- cursor);
- exit(1);
- }
printf("%ld %ld rational\n",m,n);
@@ -164,9 +128,11 @@ int main(argc,argv)
}
}
+ {
- fgets(buf,BUFSIZ,stdin); /* clean off last line */
+ fgets(buf,BUFSIZ,stdin); /* clean off last line */
+ }
qsort(rows,m,sizeof(int), cmprow);
for (i=0; i< m; i++){