File: [local] / OpenXM / src / tigers / tigers.patch (download)
Revision 1.5, Sun Nov 1 10:28:22 2020 UTC (3 years, 10 months ago) by noro
Branch: MAIN
Changes since 1.4: +55 -17
lines
Modified various parts for building with Xcode-12.
|
diff -urN TiGERS_0.9.orig/Makefile TiGERS_0.9/Makefile
--- TiGERS_0.9.orig/Makefile 1999-06-12 07:05:52.000000000 +0900
+++ TiGERS_0.9/Makefile 2020-11-01 10:49:33.000000000 +0900
@@ -2,7 +2,7 @@
# specify compiler and compiler flags
# note to use profiling need -pg option for both compiling and linking
-CC = gcc
+#CC = gcc
CFLAGS = -O3
Lib_Dirs =
diff -urN TiGERS_0.9.orig/NOTE.txt TiGERS_0.9/NOTE.txt
--- TiGERS_0.9.orig/NOTE.txt 1970-01-01 09:00:00.000000000 +0900
+++ TiGERS_0.9/NOTE.txt 2020-11-01 10:49:33.000000000 +0900
@@ -0,0 +1 @@
+This is a working directory by NT. 1999, 6/26.
diff -urN TiGERS_0.9.orig/README.change TiGERS_0.9/README.change
--- TiGERS_0.9.orig/README.change 1970-01-01 09:00:00.000000000 +0900
+++ TiGERS_0.9/README.change 2020-11-01 10:49:33.000000000 +0900
@@ -0,0 +1 @@
+The original source code of TiGERS is in OpenXM_contib/TiGERS_0.9.
diff -urN TiGERS_0.9.orig/binomial.c TiGERS_0.9/binomial.c
--- TiGERS_0.9.orig/binomial.c 1999-06-12 07:05:51.000000000 +0900
+++ TiGERS_0.9/binomial.c 2020-11-01 10:49:33.000000000 +0900
@@ -12,7 +12,7 @@
#include<stdlib.h>
#include "utils.h"
#include "binomial.h"
-
+extern int NT;
/*
**-------------ring defs-----------------------------------------------------
@@ -98,12 +98,21 @@
*/
void print_monomial(FILE *of, int *exps){
int i,jk=0;
- for(i=0;i<ring_N;i++){
- if (exps[i]!=0){
- if (jk!=0) fprintf(of,"*");
- else jk=1;
- ring_putvar(of,i);
- if (exps[i]>1) fprintf(of,"^%d",exps[i]);
+ if (NT == 1) {
+ fprintf(of,"[");
+ for (i=0; i<ring_N; i++) {
+ fprintf(of,"%d",exps[i]);
+ if (i != ring_N-1) fprintf(of," , ");
+ }
+ fprintf(of,"]");
+ }else{
+ for(i=0;i<ring_N;i++){
+ if (exps[i]!=0){
+ if (jk!=0) fprintf(of,"*");
+ else jk=1;
+ ring_putvar(of,i);
+ if (exps[i]>1) fprintf(of,"^%d",exps[i]);
+ }
}
}
}
@@ -309,17 +318,33 @@
**
*/
void binomial_print(FILE *of, binomial b){
- if (b==0) fprintf(of,"(NULL)");
- else {
- if (b->ff==FACET) fprintf(of,"# ");
- else if (b->ff==NONFACET) fprintf(of,"! ");
- /*else if (b->ff==UNKNOWN) fprintf(of,"? ");*/
- print_monomial(of,b->exps1);
- if (b->bf==BINOMIAL){
- fprintf(of,"-");
- print_monomial(of,b->exps2);
- }
- }
+ if (NT == 1) {
+ if (b==0) fprintf(of,"[ ]");
+ else {
+ /* if (b->ff==FACET) fprintf(of,"# ");
+ else if (b->ff==NONFACET) fprintf(of,"! "); */
+ /*else if (b->ff==UNKNOWN) fprintf(of,"? ");*/
+ fprintf(of,"[");
+ print_monomial(of,b->exps1);
+ if (b->bf==BINOMIAL){
+ fprintf(of," , ");
+ print_monomial(of,b->exps2);
+ fprintf(of,"]");
+ }
+ }
+ }else{
+ if (b==0) fprintf(of,"(NULL)");
+ else {
+ if (b->ff==FACET) fprintf(of,"# ");
+ else if (b->ff==NONFACET) fprintf(of,"! ");
+ /*else if (b->ff==UNKNOWN) fprintf(of,"? ");*/
+ print_monomial(of,b->exps1);
+ if (b->bf==BINOMIAL){
+ fprintf(of,"-");
+ print_monomial(of,b->exps2);
+ }
+ }
+ }
}
/*
diff -urN TiGERS_0.9.orig/call.c TiGERS_0.9/call.c
--- TiGERS_0.9.orig/call.c 1999-06-12 07:05:52.000000000 +0900
+++ TiGERS_0.9/call.c 2020-11-01 10:49:33.000000000 +0900
@@ -15,6 +15,8 @@
#include "gset.h"
#include "matrices.h"
+int NT = 1;
+
/*
** write a description of program usage to stderr
*/
@@ -68,7 +70,7 @@
exit(-1);
}
-FILE *infile=stdin, *outfile=stdout;
+FILE *infile, *outfile;
extern int rsearch_cache;
extern int print_tree;
extern int print_init;
@@ -87,7 +89,7 @@
#define MATFOUND 1
#define GSETFOUND 2
-main(int argc, char **argv ){
+main2(int argc, char **argv ){
char *c,cc, *prog=argv[0], *ifname=0, *ofname=0;
int tmp,acnt,stat=0,counter;
gset G1=0,gset_toric_ideal();
@@ -100,6 +102,10 @@
print_tree=FALSE;
print_init=FALSE;
+ /* added by noro */
+ infile = stdin;
+ outfile = stdout;
+
/* parse command line */
while (--argc > 0 && (*++argv)[0] == '-'){
acnt=0;
@@ -205,6 +211,29 @@
}
}
+ if (NT == 1) {
+
+ fprintf(outfile,"[\n");
+ /* perform reverse search if desired*/
+ if (root_only==FALSE){
+ if (use_exsearch==FALSE){
+ /* should double check we are at root */
+ tt=clock();
+ counter=rsearch(G1);
+ tt=(clock()-tt)/CLOCKS_PER_SEC;
+ fprintf(outfile,"\n");
+ } else {
+ tt=clock();
+ counter=exsearch(G1);
+ tt=(clock()-tt)/CLOCKS_PER_SEC;
+ fprintf(outfile,"\n");
+ }
+ }
+
+ fprintf(outfile,"]\n");
+ goto epilogue ;
+ }
+ /* if NT != 1, then start the followings. */
/* output first GB if desired */
fprintf(outfile,"%% starting GB:\n");
fprintf(outfile,"R: %d\n",ring_N);
@@ -314,15 +343,119 @@
return 0;
}
}
+
+ epilogue: ;
/* clean up */
LP_free_space();
if (G1!=0) gset_free(G1);
}
+/************************ NT ***************************/
+static int findNextToken(char *is, int start)
+{
+ if (start == -1) goto endtext ;
+ while ( is[start] <= ' ') {
+ if (is[start] == '\0' ) goto endtext ;
+ start++;
+ }
+ while ( is[start] > ' ') {
+ if (is[start] == '\0') goto endtext ;
+ start++;
+ }
+ while ( is[start] <= ' ') {
+ if (is[start] == '\0' ) goto endtext ;
+ start++;
+ }
+ return(start);
+ endtext: ;
+ fprintf(stderr,"findNextToken: end of the text.\n");
+ return(-1);
+}
+int **imatrix_read_from_string(char *is,int *m, int *n) {
+ char c;
+ int i,j;
+ int **M;
+ int pt = 0;
+
+ /* 2 3 :
+ 1 1 1
+ 0 1 2
+ */
+ /* read in matrix dimensions and initialize matrix */
+ sscanf(is,"%d %d :",m,n);
+ M=new_imatrix(*m,*n);
+ pt = findNextToken(is,pt); /* n */
+ pt = findNextToken(is,pt); /* : */
+
+ /* read in matrix entrees */
+ for(i=0;i<*m;i++){
+ for(j=0;j<*n;j++){
+ pt = findNextToken(is,pt);
+ sscanf(&(is[pt]),"%d",&(IMref(M,i,j)));
+ }
+ }
+
+ return M;
+}
+
+tiger_executeString_M(char *is) {
+ char *c,cc, *prog="tigers", *ifname=0, *ofname=0;
+ int tmp,acnt,stat=0,counter;
+ gset G1=0,gset_toric_ideal();
+ int **M=0,Mn,Mm;
+ double tt;
+
+ /* initialize parameters */
+ root_only=FALSE;
+ rsearch_cache=TRUE;
+ print_tree=FALSE;
+ print_init=FALSE;
+
+ if ((M=imatrix_read_from_string(is,&Mm,&Mn))==0){
+ fprintf(stderr,"%s: imatrix_read() failed\n",prog);
+ exit(1);
+ }
+ if (ring_N==0) ring_set(Mn);
+ else if (ring_N!=Mn) {
+ fprintf(stderr,"%s: Matrix collum and ring dimensions must agree\n",prog);
+ exit(1);
+ }
+ stat=MATFOUND;
+ /* ensure we have root */
+ if (stat==MATFOUND){
+ G1=gset_toric_ideal(M,Mm,Mn);
+ }
+ fprintf(outfile,"[\n");
+ /* perform reverse search if desired*/
+ if (root_only==FALSE){
+ if (use_exsearch==FALSE){
+ /* should double check we are at root */
+ tt=clock();
+ counter=rsearch(G1);
+ tt=(clock()-tt)/CLOCKS_PER_SEC;
+ fprintf(outfile,"\n");
+ } else {
+ tt=clock();
+ counter=exsearch(G1);
+ tt=(clock()-tt)/CLOCKS_PER_SEC;
+ fprintf(outfile,"\n");
+ }
+ }
+ fprintf(outfile,"]\n");
+ LP_free_space();
+ if (G1!=0) gset_free(G1);
+}
+main(int argc, char *argv[]) { infile=stdin; outfile=stdout;
+ if (argc > 1) {
+ tiger_executeString_M(argv[1]);
+ }else{
+ tiger_executeString_M("2 4 : 1 1 1 1 0 1 2 3");
+ }
+}
diff -urN TiGERS_0.9.orig/gset.c TiGERS_0.9/gset.c
--- TiGERS_0.9.orig/gset.c 1999-06-12 07:05:51.000000000 +0900
+++ TiGERS_0.9/gset.c 2020-11-01 10:49:33.000000000 +0900
@@ -13,6 +13,7 @@
#include "gset.h"
#include "matrices.h"
#include "Rsimp.h"
+extern int NT;
/* uncomment the following to cause use sainity checks (not fully tested)*/
/*
@@ -81,12 +82,21 @@
void gset_print(FILE *of,gset g){
binomial b;
- fprintf(of,"{");
- for(b=g->bottom;b!=0;b=b->next){
- binomial_print(of,b);
- if (b->next!=0) fprintf(of,", ");
+ if (NT == 1) {
+ fprintf(of,"[");
+ for(b=g->bottom;b!=0;b=b->next){
+ binomial_print(of,b);
+ if (b->next!=0) fprintf(of," , ");
+ }
+ fprintf(of,"]");
+ }else{
+ fprintf(of,"{");
+ for(b=g->bottom;b!=0;b=b->next){
+ binomial_print(of,b);
+ if (b->next!=0) fprintf(of,", ");
+ }
+ fprintf(of,"}");
}
- fprintf(of,"}");
}
/*
diff -urN TiGERS_0.9.orig/gset.h TiGERS_0.9/gset.h
--- TiGERS_0.9.orig/gset.h 1999-06-12 07:05:52.000000000 +0900
+++ TiGERS_0.9/gset.h 2020-11-01 10:59:44.000000000 +0900
@@ -40,9 +40,17 @@
gset gset_toric_ideal(int **,int,int);
void gset_rgb(gset g, int (*comp)(monomial,monomial));
-
-
-
-
-
-
+void binomial_copy(binomial src,binomial dest);
+void vertex_print(gset g1);
+int rsearch(gset g1);
+int exsearch(gset g1);
+void LP_free_space();
+int ring_read(FILE *infile);
+void print_monomial(FILE *of, int *exps);
+int binomial_compair(binomial b1,binomial b2);
+void reducetrail(binomial b1, binomial b2);
+void binomial_bumpto(binomial b1, binomial b2);
+int monomial_rel_prime(monomial m1, monomial m2);
+int lp_isfacet(gset g,binomial b);
+void gset_facet_print(FILE *of,gset g);
+int ihermite(int **S,int **U,int m, int n);
diff -urN TiGERS_0.9.orig/memo.txt TiGERS_0.9/memo.txt
--- TiGERS_0.9.orig/memo.txt 1970-01-01 09:00:00.000000000 +0900
+++ TiGERS_0.9/memo.txt 2020-11-01 10:49:33.000000000 +0900
@@ -0,0 +1,33 @@
+Open XM $B2=$O#2$H$*$j$NJ}K!$,$"$j(B. 1999, 6/26
+$B0l$D$O(B, $B=PNO$r%Q!<%5$GM}2r$9$kJ}K!!#(B
+$B$b$&$R$H$D$O$Q$C$A$7$F$7$^$&J}K!(B.
+
+int NT = 1 ;
+
+yama2:S/Ti $B$,:n6H%G%#%l%/%H%j(B.
+
+print_monomial (binomial.c) $B$r%j%9%H7A<0$KJQ99(B.
+$B:G=*E*$K$O(B fprintf $B$G$O$J$/(B, $B%j%9%H$r9=@.$7$FJV$9$h$&$KJQ99$G$-$k$H;W$&(B.
+$B$3$A$i$NJ}$,$$$$$+(B. $B$3$A$i$O(B NT = 2 $B$G$d$k$3$H$K$7$h$&(B.
+
+binomial_print
+
+gset_print (gset.c) Grobner basis $B$r%W%j%s%H$9$k(B.
+
+vertex_print (tiger.c) vertex $B$r%W%j%s%H$9$k(B.
+
+call.c $B$,(B top level. main $B$b$"$k$h(B.
+
+imatrix_read $B$r(B, string $B$h$jFI$`$h$&$K$+$($F(B,
+$B<!$N%3%^%s%I$r<B9T$G$-$k$h$&$K$7$?!#(B
+main(int argc, char *argv[]) {
+ if (argc > 1) {
+ tiger_executeString_M(argv[1]);
+ }else{
+ tiger_executeString_M("2 4 : 1 1 1 1 0 1 2 3");
+ }
+}
+
+--- TiGER $B$N7P83$O(B, $B>.$5$$%=%U%H$r$$$+$K(B Open XM server $B2=$9$k$+$N(B
+--- $B$h$$7P83$K$J$k$H;W$&(B. $B$3$N7P83$r%W%m%0%i%`:nK!$H$7$F5-O?$9$k$N$O(B
+--- $BBg;v$G$"$m$&(B. $B$N$3$j$OF|K\$G$d$k(B. $B$"$H$O(B, $B5i?t2r$N9=@.%W%m%0%i%`(B.
diff -urN TiGERS_0.9.orig/tigers.c TiGERS_0.9/tigers.c
--- TiGERS_0.9.orig/tigers.c 1999-06-12 07:05:51.000000000 +0900
+++ TiGERS_0.9/tigers.c 2020-11-01 10:49:33.000000000 +0900
@@ -12,6 +12,7 @@
#include "utils.h"
#include "gset.h"
int rsearch_cache=TRUE;
+extern int NT;
/*
** Output initial ideals and numbers of facets at each stage.
@@ -32,27 +33,31 @@
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
void vertex_print(gset g1){
- stats_maxfacets=max(gset_nfacets(g1),stats_maxfacets);
- stats_maxelts=max(gset_nelts(g1),stats_maxelts);
- stats_maxdeg=max(gset_deg(g1),stats_maxdeg);
- if (stats_minfacets<0) stats_minfacets=gset_nfacets(g1);
- else stats_minfacets=min(stats_minfacets,gset_nfacets(g1));
- if (stats_minelts<0) stats_minelts=gset_nelts(g1);
- else stats_minelts=min(stats_minelts,gset_nelts(g1));
- if (stats_mindeg<0) stats_mindeg=gset_deg(g1);
- else stats_mindeg=min(stats_mindeg,gset_deg(g1));
- fprintf(outfile,"Vtx: %d (%d facets/%d binomials/degree %d)\n",
- gset_id(g1),gset_nfacets(g1),gset_nelts(g1),gset_deg(g1));
- if (print_init==TRUE){
- fprintf(outfile," Initial ideal:");gset_init_print(outfile,g1);
- fprintf(outfile,"\n Facet Binomials:");gset_facet_print(outfile,g1);
- }
- else gset_print(outfile,g1);
- if (print_tree==TRUE && rsearch_cache==TRUE && gset_cache_vtx(g1)!=0){
+ if (NT == 1) {
+ gset_print(outfile,g1); fprintf(outfile," ,\n");
+ }else{
+ stats_maxfacets=max(gset_nfacets(g1),stats_maxfacets);
+ stats_maxelts=max(gset_nelts(g1),stats_maxelts);
+ stats_maxdeg=max(gset_deg(g1),stats_maxdeg);
+ if (stats_minfacets<0) stats_minfacets=gset_nfacets(g1);
+ else stats_minfacets=min(stats_minfacets,gset_nfacets(g1));
+ if (stats_minelts<0) stats_minelts=gset_nelts(g1);
+ else stats_minelts=min(stats_minelts,gset_nelts(g1));
+ if (stats_mindeg<0) stats_mindeg=gset_deg(g1);
+ else stats_mindeg=min(stats_mindeg,gset_deg(g1));
+ fprintf(outfile,"Vtx: %d (%d facets/%d binomials/degree %d)\n",
+ gset_id(g1),gset_nfacets(g1),gset_nelts(g1),gset_deg(g1));
+ if (print_init==TRUE){
+ fprintf(outfile," Initial ideal:");gset_init_print(outfile,g1);
+ fprintf(outfile,"\n Facet Binomials:");gset_facet_print(outfile,g1);
+ }
+ else gset_print(outfile,g1);
+ if (print_tree==TRUE && rsearch_cache==TRUE && gset_cache_vtx(g1)!=0){
fprintf(outfile,"\n Reducing Edge: [%d,%d]",
gset_id(g1),gset_id(gset_cache_vtx(g1)));
- }
- fprintf(outfile,"\n");
+ }
+ fprintf(outfile,"\n");
+ }
}
diff -urN TiGERS_0.9.orig/toric.c TiGERS_0.9/toric.c
--- TiGERS_0.9.orig/toric.c 1999-06-12 07:05:52.000000000 +0900
+++ TiGERS_0.9/toric.c 2020-11-01 10:49:33.000000000 +0900
@@ -15,7 +15,7 @@
#include "gset.h"
#include "matrices.h"
#include "Rsimp.h"
-
+extern int NT;
@@ -34,7 +34,10 @@
int lold,jk;
/* progress report */
- fprintf(stderr,"taking colon of J with %c:\n",'a'+lv);
+ if (NT == 1) {
+ }else{
+ fprintf(stderr,"taking colon of J with %c:\n",'a'+lv);
+ }
/* set lex last variable to be lv */
lold=ring_lv;
diff -urN TiGERS_0.9.orig/utils.c TiGERS_0.9/utils.c
--- TiGERS_0.9.orig/utils.c 1999-06-12 07:05:52.000000000 +0900
+++ TiGERS_0.9/utils.c 2020-11-01 10:59:09.000000000 +0900
@@ -10,6 +10,7 @@
*/
#include<stdio.h>
#include<stdlib.h>
+#include<ctype.h>
int eatwhite(FILE *is){
int c;