[BACK]Return to demo.k CVS log [TXT][DIR] Up to [local] / OpenXM / src / k097 / lib / restriction

Annotation of OpenXM/src/k097/lib/restriction/demo.k, Revision 1.9

1.9     ! takayama    1: /* $OpenXM: OpenXM/src/k097/lib/restriction/demo.k,v 1.8 2001/09/20 00:48:17 takayama Exp $  */
1.1       takayama    2:
                      3: load["restriction.k"];;
                      4: load("../ox/ox.k");;
                      5:
                      6: def demoSendAsirCommand(a) {
                      7:   a.executeString("load(\"bfct\");");
                      8:   a.executeString(" def myann(F) { B=ann(eval_str(F)); print(B); return(map(dp_ptod,B,[hoge,x,y,z,s,hh,ee,dx,dy,dz,ds,dhh])); }; ");
1.2       takayama    9:   a.executeString(" def myann0(F) { B=ann0(eval_str(F)); print(B); return(map(dp_ptod,B[1],[hoge,x,y,z,s,hh,ee,dx,dy,dz,ds,dhh])); }; ");
1.1       takayama   10:   a.executeString(" def mybfct(F) { return(rtostr(bfct(eval_str(F)))); }; ");
1.4       takayama   11:   a.executeString(" def mygeneric_bfct(F,VV,DD,WW) { print([F,VV,DD,WW]); return(generic_bfct(F,VV,DD,WW));}; ");
1.1       takayama   12: }
                     13:
1.7       takayama   14: if (Boundp("NoX")) {
                     15:   as = Asir.generate(false);
                     16: }else{
                     17:   as = Asir.generate();
1.9     ! takayama   18: }
        !            19:
        !            20: def demoReduction(v) {
        !            21:   if (v == true) {
        !            22:     sm1(" [(Verbose) 1] system_variable  [(DebugReductionRed) 1] system_variable Onverbose ");
        !            23:   }else{
        !            24:     sm1(" [(Verbose) 0] system_variable  [(DebugReductionRed) 0] system_variable Offverbose ");
        !            25:   }
1.7       takayama   26: }
                     27:
1.1       takayama   28: asssssir = as;
                     29: demoSendAsirCommand(as);
                     30: RingD("x,y,z,s");
                     31:
                     32: def asirBfunction(a,f) {
                     33:   local p,b;
                     34:   p = ToString(f);
                     35:   Println(p);
                     36:   b = a.rpc("mybfct",[p]);
                     37:   sm1(" b . /b set ");
                     38:   return(b);
                     39: }
                     40:
                     41: def asirAnnfsXYZ(a,f) {
                     42:   local p,b;
                     43:   RingD("x,y,z,s");  /* Fix!! See the definition of myann() */
                     44:   p = ToString(f);
                     45:   b = a.rpc("myann",[p]);
                     46:   return(b);
                     47: }
                     48:
1.3       takayama   49:
1.4       takayama   50: def asir_generic_bfct(a,ii,vv,dd,ww) {
1.3       takayama   51:    local ans;
1.4       takayama   52:    ans = a.rpc_str("mygeneric_bfct",[ii,vv,dd,ww]);
1.3       takayama   53:    return(ans);
                     54: }
1.4       takayama   55: /* a=startAsir();
                     56:    asir_generic_bfct(a,[Dx^2+Dy^2-1,Dx*Dy-4],[x,y],[Dx,Dy],[1,1]): */
                     57:
                     58: /* usage: misc/tmp/complex-ja.texi */
1.6       takayama   59: def ChangeRing(f) {
1.5       takayama   60:   local r;
                     61:   r = GetRing(f);
                     62:   if (Tag(r) == 14) {
                     63:     SetRing(r);
                     64:     return(true);
                     65:   }else{
                     66:     return(false);
1.4       takayama   67:   }
                     68: }
1.3       takayama   69:
                     70: def asir_BfRoots2(G) {
                     71:    local bb,ans,ss;
                     72:    sm1(" G flatten {dehomogenize} map /G set ");
1.6       takayama   73:    ChangeRing(G);
1.4       takayama   74:    ss = asir_generic_bfct(asssssir,G,[x,y],[Dx,Dy],[1,1]);
1.3       takayama   75:    bb = [ss];
                     76:    sm1(" bb 0 get findIntegralRoots { (universalNumber) dc } map /ans set ");
                     77:    return([ans, bb]);
                     78: }
                     79: def asir_BfRoots3(G) {
                     80:    local bb,ans,ss;
                     81:    sm1(" G flatten {dehomogenize} map /G set ");
1.6       takayama   82:    ChangeRing(G);
1.4       takayama   83:    ss = asir_generic_bfct(asssssir,G,[x,y,z],[Dx,Dy,Dz],[1,1,1]);
1.3       takayama   84:    bb = [ss];
                     85:    sm1(" bb 0 get findIntegralRoots { (universalNumber) dc } map /ans set ");
                     86:    return([ans, bb]);
                     87: }
                     88:
1.8       takayama   89: def asir_BfRoots4(G) {
                     90:    local bb,ans,ss;
                     91:    sm1(" G flatten {dehomogenize} map /G set ");
                     92:    ChangeRing(G);
                     93:    ss = asir_generic_bfct(asssssir,G,[x,y,z,vv],[Dx,Dy,Dz,Dvv],[0,0,0,1]);
                     94:    bb = [ss];
                     95:    sm1(" bb 0 get findIntegralRoots { (universalNumber) dc } map /ans set ");
                     96:    return([ans, bb]);
                     97: }
                     98:
1.1       takayama   99: def findMinSol(f) {
                    100:   sm1(" f (string) dc findIntegralRoots 0 get (universalNumber) dc /FunctionValue set ");
                    101: }
                    102:
                    103: def asirAnnXYZ(a,f) {
                    104:   local p,b,b0,k1;
                    105:   RingD("x,y,z,s");  /* Fix!! See the definition of myann() */
                    106:   p = ToString(f);
                    107:   b = a.rpc("myann",[p]);
                    108:   Print("Annhilating ideal with s is "); Println(b);
                    109:   b0 = asirBfunction(a,f);
                    110:   Print("bfunction is "); Println(b0);
                    111:   k1 = findMinSol(b0);
                    112:   Print("Minimal integral root is "); Println(k1);
                    113:   sm1(" b { [[(s). k1 (string) dc .]] replace } map /b set ");
                    114:   return(b);
                    115: }
                    116:
1.2       takayama  117:
1.1       takayama  118: def nonquasi2(p,q) {
                    119:   local s,ans,f;
1.7       takayama  120:
                    121:   sm1("0 set_timer "); sm1(" oxNoX ");
                    122:   asssssir.OnTimer();
                    123:
1.1       takayama  124:   f = x^p+y^q+x*y^(q-1);
                    125:   Print("f=");Println(f);
                    126:   s = ToString(f);
                    127:   sm1(" Onverbose ");
                    128:   ans = asirAnnfsXYZ(asssssir,f);
                    129:   sm1(" ans 0 get (ring) dc ring_def ");
                    130:   sm1("[ ans { [[(s). (-1).]] replace } map ] /II set ");
                    131:   Println("Step 1: Annhilating ideal (II)"); Println(II);
                    132:   sm1(" II 0 get { [(x) (y) (Dx) (Dy) ] laplace0 } map /II set ");
                    133:   Sweyl("x,y",[["x",-1,"y",-1,"Dx",1,"Dy",1]]);
                    134:   pp = Map(II,"Spoly");
                    135:   Res = Sminimal(pp);
                    136:   Res0 = Res[0];
                    137:   Println("Step2: (-1,1)-minimal resolution (Res0) "); sm1_pmat(Res0);
1.3       takayama  138: /*  R = BfRoots1(Res0[0],"x,y"); */
                    139:   R = asir_BfRoots2(Res0[0]);
1.1       takayama  140:   Println("Step3: computing the cohomology of the truncated complex.");
                    141:   Print("Roots and b-function are "); Println(R);
                    142:   R0 = R[0];
                    143:   Ans=Srestall(Res0, ["x", "y"],  ["x", "y"], R0[Length(R0)-1]);
1.7       takayama  144:
                    145:   Println("Timing data: sm1 "); sm1(" 1 set_timer ");
                    146:   Print("     ox_asir [CPU,GC]:  ");Println(asssssir.OffTimer());
                    147:
1.1       takayama  148:   Print("Answer is "); Println(Ans[0]);
1.2       takayama  149:   return(Ans);
                    150: }
                    151:
                    152: def asirAnn0XYZ(a,f) {
                    153:   local p,b,b0;
                    154:   RingD("x,y,z,s");  /* Fix!! See the definition of myann() */
                    155:   p = ToString(f);
                    156:   b = a.rpc("myann0",[p]);
                    157:   Print("Annhilating ideal of f^r is "); Println(b);
                    158:   return(b);
                    159: }
                    160:
                    161: def DeRham2WithAsir(f) {
                    162:   local s;
1.7       takayama  163:
                    164:   sm1("0 set_timer "); sm1(" oxNoX ");
                    165:   asssssir.OnTimer();
                    166:
1.2       takayama  167:   s = ToString(f);
                    168:   II = asirAnn0XYZ(asssssir,f);
                    169:   Print("Step 1: Annhilating ideal (II)"); Println(II);
                    170:   sm1(" II  { [(x) (y) (Dx) (Dy) ] laplace0 } map /II set ");
                    171:   Sweyl("x,y",[["x",-1,"y",-1,"Dx",1,"Dy",1]]);
                    172:   pp = Map(II,"Spoly");
                    173:   Res = Sminimal(pp);
                    174:   Res0 = Res[0];
                    175:   Print("Step2: (-1,1)-minimal resolution (Res0) "); sm1_pmat(Res0);
1.3       takayama  176:   /* R = BfRoots1(Res0[0],"x,y"); */
                    177:   R = asir_BfRoots2(Res0[0]);
1.2       takayama  178:   Println("Step3: computing the cohomology of the truncated complex.");
                    179:   Print("Roots and b-function are "); Println(R);
                    180:   R0 = R[0];
                    181:   Ans=Srestall(Res0, ["x", "y"],  ["x", "y"],R0[Length(R0)-1] );
1.7       takayama  182:
                    183:   Println("Timing data: sm1 "); sm1(" 1 set_timer ");
                    184:   Print("     ox_asir [CPU,GC]:  ");Println(asssssir.OffTimer());
                    185:
1.2       takayama  186:   Print("Answer is ");Println(Ans[0]);
                    187:   return(Ans);
                    188: }
                    189: def DeRham3WithAsir(f) {
                    190:   local s;
1.7       takayama  191:
                    192:   sm1("0 set_timer "); sm1(" oxNoX ");
                    193:   asssssir.OnTimer();
                    194:
1.2       takayama  195:   s = ToString(f);
                    196:   II = asirAnn0XYZ(asssssir,f);
                    197:   Print("Step 1: Annhilating ideal (II)"); Println(II);
                    198:   sm1(" II  { [(x) (y) (z) (Dx) (Dy) (Dz)] laplace0 } map /II set ");
                    199:   Sweyl("x,y,z",[["x",-1,"y",-1,"z",-1,"Dx",1,"Dy",1,"Dz",1]]);
                    200:   pp = Map(II,"Spoly");
                    201:   Res = Sminimal(pp);
                    202:   Res0 = Res[0];
                    203:   Print("Step2: (-1,1)-minimal resolution (Res0) "); sm1_pmat(Res0);
1.4       takayama  204:   /* R = BfRoots1(Res0[0],"x,y,z");  */
1.3       takayama  205:   R = asir_BfRoots3(Res0[0]);
1.2       takayama  206:   Println("Step3: computing the cohomology of the truncated complex.");
                    207:   Print("Roots and b-function are "); Println(R);
                    208:   R0 = R[0];
                    209:   Ans=Srestall(Res0, ["x", "y", "z"],  ["x", "y", "z"],R0[Length(R0)-1] );
1.7       takayama  210:
                    211:   Println("Timing data: sm1 "); sm1(" 1 set_timer ");
                    212:   Print("     ox_asir [CPU,GC]:  ");Println(asssssir.OffTimer());
                    213:
1.2       takayama  214:   Print("Answer is ");Println(Ans[0]);
1.1       takayama  215:   return(Ans);
                    216: }
1.7       takayama  217:
                    218: /*  test data
                    219:
                    220:    NoX=true;
                    221:    nonquasi2(4,5);
                    222:    nonquasi2(4,6);
                    223:    nonquasi2(4,7);
                    224:    nonquasi2(4,8);
                    225:    nonquasi2(4,9);
                    226:    nonquasi2(4,10);
                    227:
                    228:    nonquasi2(5,6);
                    229:    nonquasi2(6,7);
                    230:    nonquasi2(7,8);
                    231:    nonquasi2(8,9);
                    232:    nonquasi2(9,10);
                    233: */
                    234:
                    235:    P2 = [
                    236:      "x^3-y^2",
                    237:      "y^2-x^3-x-1",
                    238:      "y^2-x^5-x-1",
                    239:      "y^2-x^7-x-1",
                    240:      "y^2-x^9-x-1",
                    241:      "y^2-x^11-x-1"
                    242:    ];
                    243:
                    244:    P3 = [
                    245:      "x^3-y^2*z^2",
                    246:      "x^2*z+y^3+y^2*z+z^3",
                    247:      "y*z^2+x^3+x^2*y^2+y^6",
                    248:      "x*z^2+x^2*y+x*y^3+y^5"
                    249:    ];
                    250:
                    251:
1.8       takayama  252: def diff_tmp(ff,xx) {
                    253:   local g;
                    254:   g = xx*ff;
                    255:   return( Replace(g,[[xx,Poly("0")],[h,Poly("1")]]));
                    256: }
                    257:
                    258: def Localize3WithAsir(I,f) {
                    259:   local s;
1.7       takayama  260:
1.8       takayama  261:   sm1("0 set_timer "); sm1(" oxNoX ");
                    262:   asssssir.OnTimer();
                    263:
                    264:   RingD("x,y,z,vv");
                    265:   /* BUG: use of RingD("x,y,z,v") causes an expected error.
                    266:     [x2,x3,x4,x4] in mygeneric_bfct.  (should be [x2,x3,x4,x5]).
                    267:   */
                    268:   f = ReParse(f);
                    269:   I = ReParse(I);
                    270:   /* Test data. */
                    271:   /*
                    272:   f = x^3-y^2*z^2;
                    273:   I = [f^2*Dx-3*x^2, f^2*Dy-2*y*z^2, f^2*Dz-2*y^2*z];
                    274:
                    275:   f = x^3-y^2;
                    276:   I = [f^2*Dx-diff_tmp(f,Dx), f^2*Dy-diff_tmp(f,Dy), Dz];
                    277:   */
                    278:
                    279:   r1 = Dx-vv^2*diff_tmp(f,Dx)*Dvv;
                    280:   r2 = Dy-vv^2*diff_tmp(f,Dy)*Dvv;
                    281:   r3 = Dz-vv^2*diff_tmp(f,Dz)*Dvv;
                    282:   II = ReParse(I);
                    283:   sm1(" II { [[(Dx). r1] [(Dy). r2] [(Dz). r3]] replace } map dehomogenize /II set ");
                    284:
                    285:   Print("Step 1: phi(J)"); Println(II);
                    286:   II = Join(II,[vv*f-1]);
                    287:   Print("Step 2: <phi(J),vf-1>"); Println(II);
                    288:
                    289:   Println("Step3: computing the integral.");
                    290:   sm1(" II  { [(x) (y) (z) (vv) (Dx) (Dy) (Dz) (Dvv)] laplace0 } map /JJ set ");
                    291:   Sweyl("x,y,z,vv",[["vv",-1,"Dvv",1]]);
                    292:   pp = Map(JJ,"Spoly");
                    293:   R = asir_BfRoots4(pp);
                    294:   Print("Roots and b-function are "); Println(R);
                    295:
                    296:   R0 = R[0];
                    297:   k1 = R0[Length(R0)-1];
                    298:   sm1(" [(parse) (intw.sm1) pushfile] extension /intw.verbose 1 def ");
                    299:   sm1(" [II [(vv) (x) (y) (z)] [(vv) -1 (Dvv) 1] k1 (integer) dc] integral-k1 /Ans set ");
                    300:
                    301:   Println("Timing data: sm1 "); sm1(" 1 set_timer ");
                    302:   Print("     ox_asir [CPU,GC]:  ");Println(asssssir.OffTimer());
                    303:
                    304:   Print("Answer is ");Println(Ans);
                    305:   return(Ans);
                    306: }
                    307:
                    308:
                    309: def Ltest2() {
                    310:   RingD("x,y,z");
                    311:   f = x^3-y^2;
                    312:   I = [f^2*Dx-diff_tmp(f,Dx), f^2*Dy-diff_tmp(f,Dy), Dz];
                    313:   return( Localize3WithAsir(I,f) );
                    314: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>