File:  [MW Coherent from dump] / coherent / d / usr / lib / libmp / spow.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:38 2019 UTC (7 years, 2 months ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent

#include "mprec.h"


/*
 *	Spow sets "b" to "a" raised to the "n" power.  Note that
 *	a = b is acceptable.
 */

void
spow(a, n, b)
register mint	*a, *b;
register unsigned n;
{
	mint	ac;

	minit(&ac);
	mcopy(a, &ac);
	mcopy(mone, b);
	if (n != 0) {
		for (; n != 1; n >>= 1, mult(&ac, &ac, &ac))
			if (n % 2 != 0)
				mult(&ac, b, b);
		mult(&ac, b, b);
	}
	mpfree(ac.val);
}

unix.superglobalmegacorp.com

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