diff -urN TiGERS_0.9.orig/NOTE.txt TiGERS_0.9/NOTE.txt --- TiGERS_0.9.orig/NOTE.txt Thu Jan 1 09:00:00 1970 +++ TiGERS_0.9/NOTE.txt Sat Jan 8 07:43:41 2000 @@ -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 Thu Jan 1 09:00:00 1970 +++ TiGERS_0.9/README.change Sat Jan 8 07:46:11 2000 @@ -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 Sat Jan 8 07:42:43 2000 +++ TiGERS_0.9/binomial.c Sat Jan 8 07:43:41 2000 @@ -12,7 +12,7 @@ #include #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;i1) fprintf(of,"^%d",exps[i]); + if (NT == 1) { + fprintf(of,"["); + for (i=0; i1) 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 Sat Jun 12 07:05:52 1999 +++ TiGERS_0.9/call.c Wed Dec 15 03:06:28 2004 @@ -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 Sat Jan 8 07:42:43 2000 +++ TiGERS_0.9/gset.c Sat Jan 8 07:43:41 2000 @@ -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/memo.txt TiGERS_0.9/memo.txt --- TiGERS_0.9.orig/memo.txt Thu Jan 1 09:00:00 1970 +++ TiGERS_0.9/memo.txt Sat Jan 8 07:43:41 2000 @@ -0,0 +1,33 @@ +Open XM 化は2とおりの方法があり. 1999, 6/26 +一つは, 出力をパーサで理解する方法。 +もうひとつはぱっちしてしまう方法. + +int NT = 1 ; + +yama2:S/Ti が作業ディレクトリ. + +print_monomial (binomial.c) をリスト形式に変更. +最終的には fprintf ではなく, リストを構成して返すように変更できると思う. +こちらの方がいいか. こちらは NT = 2 でやることにしよう. + +binomial_print + +gset_print (gset.c) Grobner basis をプリントする. + +vertex_print (tiger.c) vertex をプリントする. + +call.c が top level. main もあるよ. + +imatrix_read を, string より読むようにかえて, +次のコマンドを実行できるようにした。 +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 の経験は, 小さいソフトをいかに Open XM server 化するかの +--- よい経験になると思う. この経験をプログラム作法として記録するのは +--- 大事であろう. のこりは日本でやる. あとは, 級数解の構成プログラム. diff -urN TiGERS_0.9.orig/tigers.c TiGERS_0.9/tigers.c --- TiGERS_0.9.orig/tigers.c Sat Jan 8 07:42:43 2000 +++ TiGERS_0.9/tigers.c Sat Jan 8 07:43:41 2000 @@ -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 Sat Jan 8 07:42:43 2000 +++ TiGERS_0.9/toric.c Sat Jan 8 07:43:41 2000 @@ -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;