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

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

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

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