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

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

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.8     ! noro       48:  * $OpenXM: OpenXM_contrib2/asir2000/lib/bfct,v 1.7 2000/12/14 01:38:37 noro Exp $
1.2       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:        }
                     76:        dp_nelim(2);
1.4       noro       77:        G0 = dp_weyl_gr_main(B,append(W,DW),0,0,6);
1.1       noro       78:        G1 = [];
                     79:        for ( T = G0; T != []; T = cdr(T) ) {
                     80:                E = car(T); VL = vars(E);
                     81:                if ( !member(y1,VL) && !member(y2,VL) )
                     82:                        G1 = cons(E,G1);
                     83:        }
                     84:        G2 = map(subst,G1,dt,1);
                     85:        G3 = map(b_subst,G2,t);
                     86:        G4 = map(subst,G3,t,-1-s);
                     87:        return G4;
                     88: }
                     89:
1.7       noro       90: def indicial1(F,V)
1.6       noro       91: {
                     92:        W = append([y1,t],V);
                     93:        N = length(V);
                     94:        B = [t-y1*F];
                     95:        for ( I = N-1, DV = []; I >= 0; I-- )
                     96:                DV = cons(strtov("d"+rtostr(V[I])),DV);
                     97:        DW = append([dy1,dt],DV);
                     98:        for ( I = 0; I < N; I++ ) {
                     99:                B = cons(DV[I]+y1*diff(F,V[I])*dt,B);
                    100:        }
                    101:        dp_nelim(1);
1.7       noro      102:        /* we use homogenization (heuristically determined) */
                    103:        G0 = dp_weyl_gr_main(B,append(W,DW),1,0,6);
1.6       noro      104:        G1 = map(subst,G0,y1,1);
                    105:        Mat = newmat(2,2,[[-1,1],[0,1]]);
                    106:        G2 = map(psi,G1,t,dt);
                    107:        G3 = map(subst,G2,t,-s-1);
                    108:        return G3;
                    109: }
                    110:
                    111: def psi(F,T,DT)
                    112: {
                    113:        D = dp_ptod(F,[T,DT]);
                    114:        Wmax = weight(D);
                    115:        D1 = dp_rest(D);
                    116:        for ( ; D1; D1 = dp_rest(D1) )
                    117:                if ( weight(D1) > Wmax )
                    118:                        Wmax = weight(D1);
                    119:        for ( D1 = D, Dmax = 0; D1; D1 = dp_rest(D1) )
                    120:                if ( weight(D1) == Wmax )
                    121:                        Dmax += dp_hm(D1);
                    122:        if ( Wmax >= 0 )
                    123:                Dmax = dp_weyl_mul(<<Wmax,0>>,Dmax);
                    124:        else
                    125:                Dmax = dp_weyl_mul(<<0,-Wmax>>,Dmax);
                    126:        Rmax = dp_dtop(Dmax,[T,DT]);
                    127:        R = b_subst(subst(Rmax,DT,1),T);
                    128:        return R;
                    129: }
                    130:
                    131: def weight(D)
                    132: {
                    133:        V = dp_etov(D);
                    134:        return V[1]-V[0];
                    135: }
                    136:
                    137: def compare_first(A,B)
                    138: {
                    139:        A0 = car(A);
                    140:        B0 = car(B);
                    141:        if ( A0 > B0 )
                    142:                return 1;
                    143:        else if ( A0 < B0 )
                    144:                return -1;
                    145:        else
                    146:                return 0;
                    147: }
                    148:
1.1       noro      149: /* b-function of F ? */
                    150:
                    151: def bfct(F)
                    152: {
                    153:        V = vars(F);
                    154:        N = length(V);
1.6       noro      155:        D = newvect(N);
1.7       noro      156:
1.6       noro      157:        for ( I = 0; I < N; I++ )
                    158:                D[I] = [deg(F,V[I]),V[I]];
                    159:        qsort(D,compare_first);
                    160:        for ( V = [], I = 0; I < N; I++ )
                    161:                V = cons(D[I][1],V);
1.1       noro      162:        for ( I = N-1, DV = []; I >= 0; I-- )
                    163:                DV = cons(strtov("d"+rtostr(V[I])),DV);
1.6       noro      164:        V1 = cons(s,V); DV1 = cons(ds,DV);
1.7       noro      165:
                    166:        G0 = indicial1(F,reverse(V));
                    167:        G1 = dp_weyl_gr_main(G0,append(V1,DV1),0,1,0);
                    168:        Minipoly = weyl_minipoly(G1,append(V1,DV1),0,s);
1.6       noro      169:        return Minipoly;
                    170: }
                    171:
                    172: def weyl_minipolym(G,V,O,M,V0)
                    173: {
                    174:        N = length(V);
                    175:        Len = length(G);
                    176:        dp_ord(O);
                    177:        setmod(M);
                    178:        PS = newvect(Len);
                    179:        PS0 = newvect(Len);
                    180:
                    181:        for ( I = 0, T = G; T != []; T = cdr(T), I++ )
                    182:                PS0[I] = dp_ptod(car(T),V);
                    183:        for ( I = 0, T = G; T != []; T = cdr(T), I++ )
                    184:                PS[I] = dp_mod(dp_ptod(car(T),V),M,[]);
                    185:
                    186:        for ( I = Len - 1, GI = []; I >= 0; I-- )
                    187:                GI = cons(I,GI);
                    188:
                    189:        U = dp_mod(dp_ptod(V0,V),M,[]);
                    190:
                    191:        T = dp_mod(<<0>>,M,[]);
                    192:        TT = dp_mod(dp_ptod(1,V),M,[]);
                    193:        G = H = [[TT,T]];
                    194:
                    195:        for ( I = 1; ; I++ ) {
                    196:                T = dp_mod(<<I>>,M,[]);
                    197:
                    198:                TT = dp_weyl_nf_mod(GI,dp_weyl_mul_mod(TT,U,M),PS,1,M);
                    199:                H = cons([TT,T],H);
                    200:                L = dp_lnf_mod([TT,T],G,M);
                    201:                if ( !L[0] )
                    202:                        return dp_dtop(L[1],[V0]);
                    203:                else
                    204:                        G = insert(G,L);
                    205:        }
                    206: }
                    207:
                    208: def weyl_minipoly(G0,V0,O0,V)
                    209: {
                    210:        for ( I = 0; ; I++ ) {
                    211:                Prime = lprime(I);
                    212:                MP = weyl_minipolym(G0,V0,O0,Prime,V);
                    213:                for ( D = deg(MP,V), TL = [], J = 0; J <= D; J++ )
                    214:                        TL = cons(V^J,TL);
                    215:                dp_ord(O0);
                    216:                NF = weyl_gennf(G0,TL,V0,O0)[0];
                    217:
                    218:                LHS = weyl_nf_tab(-car(TL),NF,V0);
                    219:                B = weyl_hen_ttob(cdr(TL),NF,LHS,V0,Prime);
                    220:                if ( B ) {
                    221:                        R = ptozp(B[1]*car(TL)+B[0]);
                    222:                        return R;
                    223:                }
                    224:        }
                    225: }
                    226:
                    227: def weyl_gennf(G,TL,V,O)
                    228: {
                    229:        N = length(V); Len = length(G); dp_ord(O); PS = newvect(Len);
                    230:        for ( I = 0, T = G, HL = []; T != []; T = cdr(T), I++ ) {
                    231:                PS[I] = dp_ptod(car(T),V); HL = cons(dp_ht(PS[I]),HL);
                    232:        }
                    233:        for ( I = 0, DTL = []; TL != []; TL = cdr(TL) )
                    234:                DTL = cons(dp_ptod(car(TL),V),DTL);
                    235:        for ( I = Len - 1, GI = []; I >= 0; I-- )
                    236:                GI = cons(I,GI);
                    237:        T = car(DTL); DTL = cdr(DTL);
                    238:        H = [weyl_nf(GI,T,T,PS)];
1.1       noro      239:
1.6       noro      240:        T0 = time()[0];
                    241:        while ( DTL != [] ) {
                    242:                T = car(DTL); DTL = cdr(DTL);
                    243:                if ( dp_gr_print() )
                    244:                        print(".",2);
                    245:                if ( L = search_redble(T,H) ) {
                    246:                        DD = dp_subd(T,L[1]);
                    247:                        NF = weyl_nf(GI,dp_weyl_mul(L[0],dp_subd(T,L[1])),dp_hc(L[1])*T,PS);
                    248:                } else
                    249:                        NF = weyl_nf(GI,T,T,PS);
                    250:                NF = remove_cont(NF);
                    251:                H = cons(NF,H);
                    252:        }
                    253:        print("");
                    254:        TNF = time()[0]-T0;
                    255:        if ( dp_gr_print() )
                    256:                print("gennf(TAB="+rtostr(TTAB)+" NF="+rtostr(TNF)+")");
                    257:        return [H,PS,GI];
                    258: }
1.1       noro      259:
1.6       noro      260: def weyl_nf(B,G,M,PS)
                    261: {
                    262:        for ( D = 0; G; ) {
                    263:                for ( U = 0, L = B; L != []; L = cdr(L) ) {
                    264:                        if ( dp_redble(G,R=PS[car(L)]) > 0 ) {
                    265:                                GCD = igcd(dp_hc(G),dp_hc(R));
                    266:                                CG = idiv(dp_hc(R),GCD); CR = idiv(dp_hc(G),GCD);
                    267:                                U = CG*G-dp_weyl_mul(CR*dp_subd(G,R),R);
                    268:                                if ( !U )
                    269:                                        return [D,M];
                    270:                                D *= CG; M *= CG;
                    271:                                break;
                    272:                        }
                    273:                }
                    274:                if ( U )
                    275:                        G = U;
                    276:                else {
                    277:                        D += dp_hm(G); G = dp_rest(G);
                    278:                }
                    279:        }
                    280:        return [D,M];
                    281: }
                    282:
                    283: def weyl_nf_mod(B,G,PS,Mod)
                    284: {
                    285:        for ( D = 0; G; ) {
                    286:                for ( U = 0, L = B; L != []; L = cdr(L) ) {
                    287:                        if ( dp_redble(G,R=PS[car(L)]) > 0 ) {
                    288:                                CR = dp_hc(G)/dp_hc(R);
                    289:                                U = G-dp_weyl_mul_mod(CR*dp_mod(dp_subd(G,R),Mod,[]),R,Mod);
                    290:                                if ( !U )
                    291:                                        return D;
1.1       noro      292:                                break;
1.6       noro      293:                        }
                    294:                }
                    295:                if ( U )
                    296:                        G = U;
                    297:                else {
                    298:                        D += dp_hm(G); G = dp_rest(G);
1.1       noro      299:                }
                    300:        }
1.6       noro      301:        return D;
                    302: }
                    303:
                    304: def weyl_hen_ttob(T,NF,LHS,V,MOD)
                    305: {
                    306:        T0 = time()[0]; M = etom(weyl_leq_nf(T,NF,LHS,V)); TE = time()[0] - T0;
                    307:        T0 = time()[0]; U = henleq(M,MOD); TH = time()[0] - T0;
                    308:        if ( dp_gr_print() ) {
                    309:                print("(etom="+rtostr(TE)+" hen="+rtostr(TH)+")");
                    310:        }
                    311:        return U ? vtop(T,U,LHS) : 0;
                    312: }
                    313:
                    314: def weyl_leq_nf(TL,NF,LHS,V)
                    315: {
                    316:        TLen = length(NF);
                    317:        T = newvect(TLen); M = newvect(TLen);
                    318:        for ( I = 0; I < TLen; I++ ) {
                    319:                T[I] = dp_ht(NF[I][1]);
                    320:                M[I] = dp_hc(NF[I][1]);
                    321:        }
                    322:        Len = length(TL); INDEX = newvect(Len); COEF = newvect(Len);
                    323:        for ( L = TL, J = 0; L != []; L = cdr(L), J++ ) {
                    324:                D = dp_ptod(car(L),V);
                    325:                for ( I = 0; I < TLen; I++ )
                    326:                        if ( D == T[I] )
                    327:                                break;
                    328:                INDEX[J] = I; COEF[J] = strtov("u"+rtostr(J));
                    329:        }
                    330:        if ( !LHS ) {
                    331:                COEF[0] = 1; NM = 0; DN = 1;
                    332:        } else {
                    333:                NM = LHS[0]; DN = LHS[1];
                    334:        }
                    335:        for ( J = 0, S = -NM; J < Len; J++ ) {
                    336:                DNJ = M[INDEX[J]];
                    337:                GCD = igcd(DN,DNJ); CS = DNJ/GCD; CJ = DN/GCD;
                    338:                S = CS*S + CJ*NF[INDEX[J]][0]*COEF[J];
                    339:                DN *= CS;
                    340:        }
                    341:        for ( D = S, E = []; D; D = dp_rest(D) )
                    342:                E = cons(dp_hc(D),E);
                    343:        BOUND = LHS ? 0 : 1;
                    344:        for ( I = Len - 1, W = []; I >= BOUND; I-- )
                    345:                        W = cons(COEF[I],W);
                    346:        return [E,W];
                    347: }
                    348:
                    349: def weyl_nf_tab(A,NF,V)
                    350: {
                    351:        TLen = length(NF);
                    352:        T = newvect(TLen); M = newvect(TLen);
                    353:        for ( I = 0; I < TLen; I++ ) {
                    354:                T[I] = dp_ht(NF[I][1]);
                    355:                M[I] = dp_hc(NF[I][1]);
                    356:        }
                    357:        A = dp_ptod(A,V);
                    358:        for ( Z = A, Len = 0; Z; Z = dp_rest(Z), Len++ );
                    359:        INDEX = newvect(Len); COEF = newvect(Len);
                    360:        for ( Z = A, J = 0; Z; Z = dp_rest(Z), J++ ) {
                    361:                D = dp_ht(Z);
                    362:                for ( I = 0; I < TLen; I++ )
                    363:                        if ( D == T[I] )
                    364:                                break;
                    365:                INDEX[J] = I; COEF[J] = dp_hc(Z);
                    366:        }
                    367:        for ( J = 0, S = 0, DN = 1; J < Len; J++ ) {
                    368:                DNJ = M[INDEX[J]];
                    369:                GCD = igcd(DN,DNJ); CS = DNJ/GCD; CJ = DN/GCD;
                    370:                S = CS*S + CJ*NF[INDEX[J]][0]*COEF[J];
                    371:                DN *= CS;
                    372:        }
                    373:        return [S,DN];
1.1       noro      374: }
                    375:
                    376: def remove_zero(L)
                    377: {
                    378:        for ( R = []; L != []; L = cdr(L) )
                    379:                if ( car(L) )
                    380:                        R = cons(car(L),R);
                    381:        return R;
                    382: }
                    383:
                    384: def z_subst(F,V)
                    385: {
                    386:        for ( ; V != []; V = cdr(V) )
                    387:                F = subst(F,car(V),0);
                    388:        return F;
                    389: }
                    390:
                    391: def flatmf(L) {
                    392:     for ( S = []; L != []; L = cdr(L) )
                    393:                if ( type(F=car(car(L))) != NUM )
                    394:                        S = append(S,[F]);
                    395:        return S;
                    396: }
                    397:
                    398: def member(A,L) {
                    399:     for ( ; L != []; L = cdr(L) )
                    400:                if ( A == car(L) )
                    401:                        return 1;
                    402:        return 0;
                    403: }
                    404:
                    405: def intersection(A,B)
                    406: {
                    407:        for ( L = []; A != []; A = cdr(A) )
                    408:        if ( member(car(A),B) )
                    409:                L = cons(car(A),L);
                    410:        return L;
                    411: }
                    412:
                    413: def b_subst(F,V)
                    414: {
                    415:        D = deg(F,V);
                    416:        C = newvect(D+1);
                    417:        for ( I = D; I >= 0; I-- )
                    418:                C[I] = coef(F,I,V);
                    419:        for ( I = 0, R = 0; I <= D; I++ )
                    420:                if ( C[I] )
                    421:                        R += C[I]*v_factorial(V,I);
                    422:        return R;
                    423: }
                    424:
                    425: def v_factorial(V,N)
                    426: {
                    427:        for ( J = N-1, R = 1; J >= 0; J-- )
                    428:                R *= V-J;
                    429:        return R;
                    430: }
                    431: end$
                    432:

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