Annotation of OpenXM/src/k097/debug/Old/toric0.k.19970310, Revision 1.1
1.1 ! maekawa 1:
! 2: /* SSWork/yacc/ip-k/ex3.ccc, 1996, 8/12. This is original. ---> */
! 3: /* debug/toric0.k */
! 4:
! 5: /* load("debug/db.ccc");
! 6: load("help.ccc"); */
! 7:
! 8: def ringd() {
! 9: R = RingD("s,t,a,b,c,d,b1,b2",
! 10: [["s",1,"t",1],["a",100,"b",10,"c",1,"d",150]]);
! 11: /* 定義をやりなおすと別の ring になるよ。
! 12: これは要注意。 */
! 13: SetRingVariables();
! 14: myinput = [ a - s, b - s*t , c - s*t^2, d - s*t^4 ];
! 15: }
! 16: Println("Type in ringd(); to define the ring.");
! 17: Println("Type in toric(myinput) to get the toric ideal.");
! 18:
! 19: sm1(" /mydegree {2 1 roll degree} def ");
! 20: def expvec(f) {
! 21: local vars,n,i,ans;
! 22: vars = [a,b,c,d,Da,Db,Dc,Dd]; /* change here. */
! 23: if (f == Poly("0")) return([ ] );
! 24: sm1(f," /ff.tmp set ", vars ,
! 25: " { ff.tmp mydegree (universalNumber) dc } map /FunctionValue set ");
! 26: }
! 27:
! 28: def in_w(f) {
! 29: local w,top,ans,wtop;
! 30: weight = [-100,-10,-1,0,100,10,1,0]; /* change here. */
! 31: if (f == Poly("0")) return( Poly("0") );
! 32: top = sm1(f, " init ");
! 33: w = expvec(top) * weight ;
! 34: wtop = w;
! 35: ans = top;
! 36: f = f-top;
! 37: while(true) {
! 38: if ( f == Poly("0")) sm1("exit");
! 39: top = sm1(f, " init ");
! 40: w = expvec(top) * weight ;
! 41: if (w < wtop) sm1(" exit ");
! 42: ans = ans + top;
! 43: f = f-top;
! 44: /* Println(ans); */
! 45: }
! 46: return(ans);
! 47: }
! 48:
! 49: def toric(input) {
! 50: local ans ,ans2;
! 51: ans = Replace(Groebner(input),[[h,Poly("1")]]);
! 52: ans2 = sm1( ans, " [(s) (t)] eliminatev ");
! 53: return(ans2);
! 54: }
! 55:
! 56:
! 57:
! 58: def ringd1() {
! 59: local weight,ans;
! 60: weight = ["a",100,"b",10,"c",1,"d",150];
! 61: R = RingD("s,t,a,b,c,d,b1,b2",
! 62: [["s",1,"t",1],weight]);
! 63: SetRingVariables();
! 64: Print("Weight="); Println(weight);
! 65: myinput = [ a - s, b - s*t , c - s*t^2, d - s*t^4 ];
! 66: ans = toric(myinput);
! 67: Println(ans);
! 68: return(ans);
! 69: }
! 70:
! 71: def void ringd2() {
! 72: local weight;
! 73: weight = ["a",1,"b",15,"c",1,"d",4];
! 74: R = RingD("s,t,a,b,c,d,b1,b2",
! 75: [["s",1,"t",1],weight]);
! 76: SetRingVariables();
! 77: Print("Weight="); Println(weight);
! 78: myinput = [ a - s, b - s*t , c - s*t^2, d - s*t^4 ];
! 79: Println(toric(myinput));
! 80: }
! 81:
! 82: /* This is used to find a bug */
! 83: def void ringd3() {
! 84: local weight;
! 85: weight = ["a",1,"b",15,"c",1,"d",4];
! 86: R = RingD("s,t,a,b,c,d,b1,b2",
! 87: [["s",1,"t",1],weight]);
! 88: SetRingVariables();
! 89: /* Print("Weight="); Println(weight);
! 90: myinput = [ a - s, b - s*t , c - s*t^2, d - s*t^4 ]; */
! 91: /* Println(toric(myinput)); */
! 92: }
! 93:
! 94: def MinimalBase(base) {
! 95: sm1( base, " minimalBase /FunctionValue set ");
! 96: }
! 97: HelpAdd(["MinimalBase",
! 98: ["MinimalBase[base] prunes redundant elements in the Grobner basis <<base>>."
! 99: ]]);
! 100:
! 101:
! 102: def IndexedVariables(name,size) {
! 103: local result,i,result2;
! 104: result = [ ];
! 105: for (i=0; i<size-1; i++) {
! 106: result = Append(result,Indexed(name,i));
! 107: result = Append(result,",");
! 108: }
! 109: if (size-1 >= 0) {
! 110: result = Append(result,Indexed(name,size-1));
! 111: }
! 112: result2 = Join(["{"],result);
! 113: result2 = Join(result2,["}"]);
! 114: return(AddString(result2));
! 115: }
! 116: HelpAdd(["IndexedVariables",
! 117: ["IndexedVariables(name,size) returns the string ",
! 118: " {name[0],name[1],...,name[size-1]} which can be used as inputs to ",
! 119: " the function RingD (string name, integer size).",
! 120: " Ex. R = RingD(IndexedVariables(\"a\",3)); ",
! 121: " h = Poly(\"h\");",
! 122: " a = NewArray(3);",
! 123: " for (i=0; i<3; i++) {a[i] = Poly(Indexed(\"a\",i));} ;"]]);
! 124:
! 125:
! 126: def IndexedRingD(vList, size, weightMatrix) {
! 127: local myring,tmp,k00_i,argsize,vListD;
! 128: /* You cannot use these local varialbes as a name of global ring
! 129: variables. Change these names to names that start with k00_ */
! 130: argsize = Length(Arglist);
! 131: if (argsize == 1) {
! 132: Println("Error (IndexedRingD): ");
! 133: return(null);
! 134: }
! 135: if (argsize == 2) {
! 136: vListD = AddString(["D",vList]);
! 137: myring = RingD(IndexedVariables(vList,size));
! 138: SetRingVariables();
! 139: tmp = NewArray(size);
! 140: for (k00_i=0; k00_i<size; k00_i++) {tmp[k00_i]=Poly(Indexed(vList,k00_i));}
! 141: sm1(vList, " (literal) dc ", tmp, " def ");
! 142: tmp = NewArray(size);
! 143: for (k00_i=0; k00_i<size; k00_i++) {tmp[k00_i]=Poly(Indexed(vListD,k00_i));}
! 144: sm1(vListD, " (literal) dc ", tmp, " def ");
! 145: Print("Set the global variables ");
! 146: sm1("[(parse) ",vList," ] extension pop print ");
! 147: sm1("[(parse) ",vListD," ] extension pop print "); Ln();
! 148: return( myring );
! 149: }
! 150: if (argsize == 3) {
! 151: vListD = AddString(["D",vList]);
! 152: myring = RingD(IndexedVariables(vList,size),weightMatrix);
! 153: SetRingVariables();
! 154: tmp = NewArray(size);
! 155: for (k00_i=0;k00_i<size; k00_i++) {tmp[k00_i]=Poly(Indexed(vList,k00_i));}
! 156: sm1(vList, " (literal) dc ", tmp, " def ");
! 157: tmp = NewArray(size);
! 158: for (k00_i=0;k00_i<size; k00_i++) {tmp[k00_i]=Poly(Indexed(vListD,k00_i));}
! 159: sm1(vListD, " (literal) dc ", tmp, " def ");
! 160: Print("Set the global variables ");
! 161: sm1("[(parse) ",vList," ] extension pop print ");
! 162: sm1("[(parse) ",vListD," ] extension pop print "); Ln();
! 163: return( myring );
! 164: }
! 165: return(-1);
! 166: }
! 167:
! 168:
! 169:
! 170: def void foo() {
! 171: Println("IndexedVariables:");
! 172: Println(IndexedVariables("xyz",5));
! 173: }
! 174:
! 175:
! 176:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>