Annotation of researchv10no/libmp/pow.c, revision 1.1

1.1     ! root        1: #include "mp.h"
        !             2: static
        !             3: mpow(a,b,c,d) mint *a,*b,*c,*d;
        !             4: {      int i,j,n;
        !             5:        mint x,y;
        !             6:        x.len=y.len=0;
        !             7:        xfree(d);
        !             8:        d->len=1;
        !             9:        d->val=xalloc(1,"mpow");
        !            10:        *d->val=1;
        !            11:        for(j=0;j<b->len;j++)
        !            12:        {       n=b->val[b->len-j-1];
        !            13:                for(i=0;i<15;i++)
        !            14:                {       mult(d,d,&x);
        !            15:                        mdiv(&x,c,&y,d);
        !            16:                        if((n=n<<1)&0100000)
        !            17:                        {       mult(a,d,&x);
        !            18:                                mdiv(&x,c,&y,d);
        !            19:                        }
        !            20:                }
        !            21:        }
        !            22:        xfree(&x);
        !            23:        xfree(&y);
        !            24:        return;
        !            25: }
        !            26: rpow(a,n,b) mint *a,*b;
        !            27: {      mint x,y;
        !            28:        int i;
        !            29:        x.len=1;
        !            30:        x.val=xalloc(1,"rpow");
        !            31:        *x.val=n;
        !            32:        y.len=n*a->len+4;
        !            33:        y.val=xalloc(y.len,"rpow2");
        !            34:        for(i=0;i<y.len;i++) y.val[i]=0;
        !            35:        y.val[y.len-1]=010000;
        !            36:        xfree(b);
        !            37:        mpow(a,&x,&y,b);
        !            38:        xfree(&x);
        !            39:        xfree(&y);
        !            40:        return;
        !            41: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.