Annotation of coherent/d/usr/lib/libmp/spow.c, revision 1.1.1.1

1.1       root        1: #include "mprec.h"
                      2: 
                      3: 
                      4: /*
                      5:  *     Spow sets "b" to "a" raised to the "n" power.  Note that
                      6:  *     a = b is acceptable.
                      7:  */
                      8: 
                      9: void
                     10: spow(a, n, b)
                     11: register mint  *a, *b;
                     12: register unsigned n;
                     13: {
                     14:        mint    ac;
                     15: 
                     16:        minit(&ac);
                     17:        mcopy(a, &ac);
                     18:        mcopy(mone, b);
                     19:        if (n != 0) {
                     20:                for (; n != 1; n >>= 1, mult(&ac, &ac, &ac))
                     21:                        if (n % 2 != 0)
                     22:                                mult(&ac, b, b);
                     23:                mult(&ac, b, b);
                     24:        }
                     25:        mpfree(ac.val);
                     26: }

unix.superglobalmegacorp.com

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