[BACK]Return to bfct CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / lib

Annotation of OpenXM_contrib2/asir2000/lib/bfct, Revision 1.11

1.2       noro        1: /*
                      2:  * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
                      3:  * All rights reserved.
                      4:  *
                      5:  * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited,
                      6:  * non-exclusive and royalty-free license to use, copy, modify and
                      7:  * redistribute, solely for non-commercial and non-profit purposes, the
                      8:  * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and
                      9:  * conditions of this Agreement. For the avoidance of doubt, you acquire
                     10:  * only a limited right to use the SOFTWARE hereunder, and FLL or any
                     11:  * third party developer retains all rights, including but not limited to
                     12:  * copyrights, in and to the SOFTWARE.
                     13:  *
                     14:  * (1) FLL does not grant you a license in any way for commercial
                     15:  * purposes. You may use the SOFTWARE only for non-commercial and
                     16:  * non-profit purposes only, such as academic, research and internal
                     17:  * business use.
                     18:  * (2) The SOFTWARE is protected by the Copyright Law of Japan and
                     19:  * international copyright treaties. If you make copies of the SOFTWARE,
                     20:  * with or without modification, as permitted hereunder, you shall affix
                     21:  * to all such copies of the SOFTWARE the above copyright notice.
                     22:  * (3) An explicit reference to this SOFTWARE and its copyright owner
                     23:  * shall be made on your publication or presentation in any form of the
                     24:  * results obtained by use of the SOFTWARE.
                     25:  * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
1.3       noro       26:  * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
1.2       noro       27:  * for such modification or the source code of the modified part of the
                     28:  * SOFTWARE.
                     29:  *
                     30:  * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL
                     31:  * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND
                     32:  * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS
                     33:  * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES'
                     34:  * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY
                     35:  * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY.
                     36:  * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT,
                     37:  * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
                     38:  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
                     39:  * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES
                     40:  * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES
                     41:  * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY
                     42:  * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
                     43:  * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART
                     44:  * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
                     45:  * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
                     46:  * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
                     47:  *
1.11    ! noro       48:  * $OpenXM: OpenXM_contrib2/asir2000/lib/bfct,v 1.10 2000/12/15 01:34:31 noro Exp $
1.10      noro       49:  */
1.1       noro       50: /* requires 'primdec' */
                     51:
1.6       noro       52: /* annihilating ideal of F^s */
1.1       noro       53:
                     54: def ann(F)
                     55: {
                     56:        V = vars(F);
                     57:        N = length(V);
1.8       noro       58:        D = newvect(N);
                     59:
                     60:        for ( I = 0; I < N; I++ )
                     61:                D[I] = [deg(F,V[I]),V[I]];
                     62:        qsort(D,compare_first);
                     63:        for ( V = [], I = N-1; I >= 0; I-- )
                     64:                V = cons(D[I][1],V);
                     65:
1.1       noro       66:        for ( I = N-1, DV = []; I >= 0; I-- )
                     67:                DV = cons(strtov("d"+rtostr(V[I])),DV);
1.8       noro       68:
                     69:        W = append([y1,y2,t],V);
1.1       noro       70:        DW = append([dy1,dy2,dt],DV);
1.8       noro       71:
                     72:        B = [1-y1*y2,t-y1*F];
1.1       noro       73:        for ( I = 0; I < N; I++ ) {
                     74:                B = cons(DV[I]+y1*diff(F,V[I])*dt,B);
                     75:        }
1.10      noro       76:
                     77:        /* homogenized (heuristics) */
1.1       noro       78:        dp_nelim(2);
1.10      noro       79:        G0 = dp_weyl_gr_main(B,append(W,DW),1,0,6);
1.1       noro       80:        G1 = [];
                     81:        for ( T = G0; T != []; T = cdr(T) ) {
                     82:                E = car(T); VL = vars(E);
                     83:                if ( !member(y1,VL) && !member(y2,VL) )
                     84:                        G1 = cons(E,G1);
                     85:        }
                     86:        G2 = map(subst,G1,dt,1);
                     87:        G3 = map(b_subst,G2,t);
                     88:        G4 = map(subst,G3,t,-1-s);
                     89:        return G4;
                     90: }
                     91:
1.10      noro       92: /*
                     93:  * compute J_f|s=r, where r = the minimal integral root of global b_f(s)
                     94:  * ann0(F) returns [MinRoot,Ideal]
                     95:  */
                     96:
                     97: def ann0(F)
                     98: {
                     99:        V = vars(F);
                    100:        N = length(V);
                    101:        D = newvect(N);
                    102:
                    103:        for ( I = 0; I < N; I++ )
                    104:                D[I] = [deg(F,V[I]),V[I]];
                    105:        qsort(D,compare_first);
                    106:        for ( V = [], I = 0; I < N; I++ )
                    107:                V = cons(D[I][1],V);
                    108:
                    109:        for ( I = N-1, DV = []; I >= 0; I-- )
                    110:                DV = cons(strtov("d"+rtostr(V[I])),DV);
                    111:
                    112:        /* XXX : heuristics */
                    113:        W = append([y1,y2,t],reverse(V));
                    114:        DW = append([dy1,dy2,dt],reverse(DV));
                    115:        WDW = append(W,DW);
                    116:
                    117:        B = [1-y1*y2,t-y1*F];
                    118:        for ( I = 0; I < N; I++ ) {
                    119:                B = cons(DV[I]+y1*diff(F,V[I])*dt,B);
                    120:        }
                    121:
                    122:        /* homogenized (heuristics) */
                    123:        dp_nelim(2);
                    124:        G0 = dp_weyl_gr_main(B,WDW,1,0,6);
                    125:        G1 = [];
                    126:        for ( T = G0; T != []; T = cdr(T) ) {
                    127:                E = car(T); VL = vars(E);
                    128:                if ( !member(y1,VL) && !member(y2,VL) )
                    129:                        G1 = cons(E,G1);
                    130:        }
                    131:        G2 = map(subst,G1,dt,1);
                    132:        G3 = map(b_subst,G2,t);
                    133:        G4 = map(subst,G3,t,-1-s);
                    134:
                    135:        /* G4 = J_f(s) */
                    136:
                    137:        V1 = cons(s,V); DV1 = cons(ds,DV); V1DV1 = append(V1,DV1);
                    138:        G5 = dp_weyl_gr_main(cons(F,G4),V1DV1,0,1,0);
                    139:        Bf = weyl_minipoly(G5,V1DV1,0,s);
                    140:
                    141:        FList = cdr(fctr(Bf));
                    142:        for ( T = FList, Min = 0; T != []; T = cdr(T) ) {
                    143:                LF = car(car(T));
                    144:                Root = -coef(LF,0)/coef(LF,1);
                    145:                if ( dn(Root) == 1 && Root < Min )
                    146:                        Min = Root;
                    147:        }
                    148:        return [Min,map(subst,G4,s,Min)];
                    149: }
                    150:
1.7       noro      151: def indicial1(F,V)
1.6       noro      152: {
                    153:        W = append([y1,t],V);
                    154:        N = length(V);
                    155:        B = [t-y1*F];
                    156:        for ( I = N-1, DV = []; I >= 0; I-- )
                    157:                DV = cons(strtov("d"+rtostr(V[I])),DV);
                    158:        DW = append([dy1,dt],DV);
                    159:        for ( I = 0; I < N; I++ ) {
                    160:                B = cons(DV[I]+y1*diff(F,V[I])*dt,B);
                    161:        }
                    162:        dp_nelim(1);
1.10      noro      163:
                    164:        /* homogenized (heuristics) */
1.7       noro      165:        G0 = dp_weyl_gr_main(B,append(W,DW),1,0,6);
1.6       noro      166:        G1 = map(subst,G0,y1,1);
                    167:        Mat = newmat(2,2,[[-1,1],[0,1]]);
                    168:        G2 = map(psi,G1,t,dt);
                    169:        G3 = map(subst,G2,t,-s-1);
                    170:        return G3;
                    171: }
                    172:
                    173: def psi(F,T,DT)
                    174: {
                    175:        D = dp_ptod(F,[T,DT]);
                    176:        Wmax = weight(D);
                    177:        D1 = dp_rest(D);
                    178:        for ( ; D1; D1 = dp_rest(D1) )
                    179:                if ( weight(D1) > Wmax )
                    180:                        Wmax = weight(D1);
                    181:        for ( D1 = D, Dmax = 0; D1; D1 = dp_rest(D1) )
                    182:                if ( weight(D1) == Wmax )
                    183:                        Dmax += dp_hm(D1);
                    184:        if ( Wmax >= 0 )
                    185:                Dmax = dp_weyl_mul(<<Wmax,0>>,Dmax);
                    186:        else
                    187:                Dmax = dp_weyl_mul(<<0,-Wmax>>,Dmax);
                    188:        Rmax = dp_dtop(Dmax,[T,DT]);
                    189:        R = b_subst(subst(Rmax,DT,1),T);
                    190:        return R;
                    191: }
                    192:
                    193: def weight(D)
                    194: {
                    195:        V = dp_etov(D);
                    196:        return V[1]-V[0];
                    197: }
                    198:
                    199: def compare_first(A,B)
                    200: {
                    201:        A0 = car(A);
                    202:        B0 = car(B);
                    203:        if ( A0 > B0 )
                    204:                return 1;
                    205:        else if ( A0 < B0 )
                    206:                return -1;
                    207:        else
                    208:                return 0;
                    209: }
                    210:
1.1       noro      211: /* b-function of F ? */
                    212:
                    213: def bfct(F)
                    214: {
                    215:        V = vars(F);
                    216:        N = length(V);
1.6       noro      217:        D = newvect(N);
1.7       noro      218:
1.6       noro      219:        for ( I = 0; I < N; I++ )
                    220:                D[I] = [deg(F,V[I]),V[I]];
                    221:        qsort(D,compare_first);
                    222:        for ( V = [], I = 0; I < N; I++ )
                    223:                V = cons(D[I][1],V);
1.1       noro      224:        for ( I = N-1, DV = []; I >= 0; I-- )
                    225:                DV = cons(strtov("d"+rtostr(V[I])),DV);
1.6       noro      226:        V1 = cons(s,V); DV1 = cons(ds,DV);
1.7       noro      227:
                    228:        G0 = indicial1(F,reverse(V));
                    229:        G1 = dp_weyl_gr_main(G0,append(V1,DV1),0,1,0);
                    230:        Minipoly = weyl_minipoly(G1,append(V1,DV1),0,s);
1.6       noro      231:        return Minipoly;
                    232: }
                    233:
                    234: def weyl_minipolym(G,V,O,M,V0)
                    235: {
                    236:        N = length(V);
                    237:        Len = length(G);
                    238:        dp_ord(O);
                    239:        setmod(M);
                    240:        PS = newvect(Len);
                    241:        PS0 = newvect(Len);
                    242:
                    243:        for ( I = 0, T = G; T != []; T = cdr(T), I++ )
                    244:                PS0[I] = dp_ptod(car(T),V);
                    245:        for ( I = 0, T = G; T != []; T = cdr(T), I++ )
                    246:                PS[I] = dp_mod(dp_ptod(car(T),V),M,[]);
                    247:
                    248:        for ( I = Len - 1, GI = []; I >= 0; I-- )
                    249:                GI = cons(I,GI);
                    250:
                    251:        U = dp_mod(dp_ptod(V0,V),M,[]);
                    252:
                    253:        T = dp_mod(<<0>>,M,[]);
                    254:        TT = dp_mod(dp_ptod(1,V),M,[]);
                    255:        G = H = [[TT,T]];
                    256:
                    257:        for ( I = 1; ; I++ ) {
                    258:                T = dp_mod(<<I>>,M,[]);
                    259:
                    260:                TT = dp_weyl_nf_mod(GI,dp_weyl_mul_mod(TT,U,M),PS,1,M);
                    261:                H = cons([TT,T],H);
                    262:                L = dp_lnf_mod([TT,T],G,M);
                    263:                if ( !L[0] )
                    264:                        return dp_dtop(L[1],[V0]);
                    265:                else
                    266:                        G = insert(G,L);
                    267:        }
                    268: }
                    269:
                    270: def weyl_minipoly(G0,V0,O0,V)
                    271: {
1.11    ! noro      272:        HM = hmlist(G0,V0,O0);
1.6       noro      273:        for ( I = 0; ; I++ ) {
                    274:                Prime = lprime(I);
1.11    ! noro      275:                if ( !valid_modulus(HM,Prime) )
        !           276:                        continue;
1.6       noro      277:                MP = weyl_minipolym(G0,V0,O0,Prime,V);
                    278:                for ( D = deg(MP,V), TL = [], J = 0; J <= D; J++ )
                    279:                        TL = cons(V^J,TL);
                    280:                dp_ord(O0);
                    281:                NF = weyl_gennf(G0,TL,V0,O0)[0];
                    282:
                    283:                LHS = weyl_nf_tab(-car(TL),NF,V0);
                    284:                B = weyl_hen_ttob(cdr(TL),NF,LHS,V0,Prime);
                    285:                if ( B ) {
                    286:                        R = ptozp(B[1]*car(TL)+B[0]);
                    287:                        return R;
                    288:                }
                    289:        }
                    290: }
                    291:
                    292: def weyl_gennf(G,TL,V,O)
                    293: {
                    294:        N = length(V); Len = length(G); dp_ord(O); PS = newvect(Len);
                    295:        for ( I = 0, T = G, HL = []; T != []; T = cdr(T), I++ ) {
                    296:                PS[I] = dp_ptod(car(T),V); HL = cons(dp_ht(PS[I]),HL);
                    297:        }
                    298:        for ( I = 0, DTL = []; TL != []; TL = cdr(TL) )
                    299:                DTL = cons(dp_ptod(car(TL),V),DTL);
                    300:        for ( I = Len - 1, GI = []; I >= 0; I-- )
                    301:                GI = cons(I,GI);
                    302:        T = car(DTL); DTL = cdr(DTL);
                    303:        H = [weyl_nf(GI,T,T,PS)];
1.1       noro      304:
1.6       noro      305:        T0 = time()[0];
                    306:        while ( DTL != [] ) {
                    307:                T = car(DTL); DTL = cdr(DTL);
                    308:                if ( dp_gr_print() )
                    309:                        print(".",2);
                    310:                if ( L = search_redble(T,H) ) {
                    311:                        DD = dp_subd(T,L[1]);
                    312:                        NF = weyl_nf(GI,dp_weyl_mul(L[0],dp_subd(T,L[1])),dp_hc(L[1])*T,PS);
                    313:                } else
                    314:                        NF = weyl_nf(GI,T,T,PS);
                    315:                NF = remove_cont(NF);
                    316:                H = cons(NF,H);
                    317:        }
1.10      noro      318:        print("");
1.6       noro      319:        TNF = time()[0]-T0;
                    320:        if ( dp_gr_print() )
                    321:                print("gennf(TAB="+rtostr(TTAB)+" NF="+rtostr(TNF)+")");
                    322:        return [H,PS,GI];
                    323: }
1.1       noro      324:
1.6       noro      325: def weyl_nf(B,G,M,PS)
                    326: {
                    327:        for ( D = 0; G; ) {
                    328:                for ( U = 0, L = B; L != []; L = cdr(L) ) {
                    329:                        if ( dp_redble(G,R=PS[car(L)]) > 0 ) {
                    330:                                GCD = igcd(dp_hc(G),dp_hc(R));
                    331:                                CG = idiv(dp_hc(R),GCD); CR = idiv(dp_hc(G),GCD);
                    332:                                U = CG*G-dp_weyl_mul(CR*dp_subd(G,R),R);
                    333:                                if ( !U )
                    334:                                        return [D,M];
                    335:                                D *= CG; M *= CG;
                    336:                                break;
                    337:                        }
                    338:                }
                    339:                if ( U )
                    340:                        G = U;
                    341:                else {
                    342:                        D += dp_hm(G); G = dp_rest(G);
                    343:                }
                    344:        }
                    345:        return [D,M];
                    346: }
                    347:
                    348: def weyl_nf_mod(B,G,PS,Mod)
                    349: {
                    350:        for ( D = 0; G; ) {
                    351:                for ( U = 0, L = B; L != []; L = cdr(L) ) {
                    352:                        if ( dp_redble(G,R=PS[car(L)]) > 0 ) {
                    353:                                CR = dp_hc(G)/dp_hc(R);
                    354:                                U = G-dp_weyl_mul_mod(CR*dp_mod(dp_subd(G,R),Mod,[]),R,Mod);
                    355:                                if ( !U )
                    356:                                        return D;
1.1       noro      357:                                break;
1.6       noro      358:                        }
                    359:                }
                    360:                if ( U )
                    361:                        G = U;
                    362:                else {
                    363:                        D += dp_hm(G); G = dp_rest(G);
1.1       noro      364:                }
                    365:        }
1.6       noro      366:        return D;
                    367: }
                    368:
                    369: def weyl_hen_ttob(T,NF,LHS,V,MOD)
                    370: {
                    371:        T0 = time()[0]; M = etom(weyl_leq_nf(T,NF,LHS,V)); TE = time()[0] - T0;
                    372:        T0 = time()[0]; U = henleq(M,MOD); TH = time()[0] - T0;
                    373:        if ( dp_gr_print() ) {
                    374:                print("(etom="+rtostr(TE)+" hen="+rtostr(TH)+")");
                    375:        }
                    376:        return U ? vtop(T,U,LHS) : 0;
                    377: }
                    378:
                    379: def weyl_leq_nf(TL,NF,LHS,V)
                    380: {
                    381:        TLen = length(NF);
                    382:        T = newvect(TLen); M = newvect(TLen);
                    383:        for ( I = 0; I < TLen; I++ ) {
                    384:                T[I] = dp_ht(NF[I][1]);
                    385:                M[I] = dp_hc(NF[I][1]);
                    386:        }
                    387:        Len = length(TL); INDEX = newvect(Len); COEF = newvect(Len);
                    388:        for ( L = TL, J = 0; L != []; L = cdr(L), J++ ) {
                    389:                D = dp_ptod(car(L),V);
                    390:                for ( I = 0; I < TLen; I++ )
                    391:                        if ( D == T[I] )
                    392:                                break;
                    393:                INDEX[J] = I; COEF[J] = strtov("u"+rtostr(J));
                    394:        }
                    395:        if ( !LHS ) {
                    396:                COEF[0] = 1; NM = 0; DN = 1;
                    397:        } else {
                    398:                NM = LHS[0]; DN = LHS[1];
                    399:        }
                    400:        for ( J = 0, S = -NM; J < Len; J++ ) {
                    401:                DNJ = M[INDEX[J]];
                    402:                GCD = igcd(DN,DNJ); CS = DNJ/GCD; CJ = DN/GCD;
                    403:                S = CS*S + CJ*NF[INDEX[J]][0]*COEF[J];
                    404:                DN *= CS;
                    405:        }
                    406:        for ( D = S, E = []; D; D = dp_rest(D) )
                    407:                E = cons(dp_hc(D),E);
                    408:        BOUND = LHS ? 0 : 1;
                    409:        for ( I = Len - 1, W = []; I >= BOUND; I-- )
                    410:                        W = cons(COEF[I],W);
                    411:        return [E,W];
                    412: }
                    413:
                    414: def weyl_nf_tab(A,NF,V)
                    415: {
                    416:        TLen = length(NF);
                    417:        T = newvect(TLen); M = newvect(TLen);
                    418:        for ( I = 0; I < TLen; I++ ) {
                    419:                T[I] = dp_ht(NF[I][1]);
                    420:                M[I] = dp_hc(NF[I][1]);
                    421:        }
                    422:        A = dp_ptod(A,V);
                    423:        for ( Z = A, Len = 0; Z; Z = dp_rest(Z), Len++ );
                    424:        INDEX = newvect(Len); COEF = newvect(Len);
                    425:        for ( Z = A, J = 0; Z; Z = dp_rest(Z), J++ ) {
                    426:                D = dp_ht(Z);
                    427:                for ( I = 0; I < TLen; I++ )
                    428:                        if ( D == T[I] )
                    429:                                break;
                    430:                INDEX[J] = I; COEF[J] = dp_hc(Z);
                    431:        }
                    432:        for ( J = 0, S = 0, DN = 1; J < Len; J++ ) {
                    433:                DNJ = M[INDEX[J]];
                    434:                GCD = igcd(DN,DNJ); CS = DNJ/GCD; CJ = DN/GCD;
                    435:                S = CS*S + CJ*NF[INDEX[J]][0]*COEF[J];
                    436:                DN *= CS;
                    437:        }
                    438:        return [S,DN];
1.1       noro      439: }
                    440:
                    441: def remove_zero(L)
                    442: {
                    443:        for ( R = []; L != []; L = cdr(L) )
                    444:                if ( car(L) )
                    445:                        R = cons(car(L),R);
                    446:        return R;
                    447: }
                    448:
                    449: def z_subst(F,V)
                    450: {
                    451:        for ( ; V != []; V = cdr(V) )
                    452:                F = subst(F,car(V),0);
                    453:        return F;
                    454: }
                    455:
                    456: def flatmf(L) {
                    457:     for ( S = []; L != []; L = cdr(L) )
                    458:                if ( type(F=car(car(L))) != NUM )
                    459:                        S = append(S,[F]);
                    460:        return S;
                    461: }
                    462:
                    463: def member(A,L) {
                    464:     for ( ; L != []; L = cdr(L) )
                    465:                if ( A == car(L) )
                    466:                        return 1;
                    467:        return 0;
                    468: }
                    469:
                    470: def intersection(A,B)
                    471: {
                    472:        for ( L = []; A != []; A = cdr(A) )
                    473:        if ( member(car(A),B) )
                    474:                L = cons(car(A),L);
                    475:        return L;
                    476: }
                    477:
                    478: def b_subst(F,V)
                    479: {
                    480:        D = deg(F,V);
                    481:        C = newvect(D+1);
                    482:        for ( I = D; I >= 0; I-- )
                    483:                C[I] = coef(F,I,V);
                    484:        for ( I = 0, R = 0; I <= D; I++ )
                    485:                if ( C[I] )
                    486:                        R += C[I]*v_factorial(V,I);
                    487:        return R;
                    488: }
                    489:
                    490: def v_factorial(V,N)
                    491: {
                    492:        for ( J = N-1, R = 1; J >= 0; J-- )
                    493:                R *= V-J;
                    494:        return R;
                    495: }
                    496: end$
                    497:

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