X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/b817bfc642225b8c3c0b6a7e42d1fb949b61a606..298182ad446aaced14dea7ed0e7c968946787288:/mp.h diff --git a/mp.h b/mp.h index 8319173..74b6473 100644 --- a/mp.h +++ b/mp.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: mp.h,v 1.19 2004/04/08 01:36:15 mdw Exp $ + * $Id$ * * Simple multiprecision arithmetic * @@ -363,7 +363,7 @@ extern void mp_shrink(mp */*m*/); #define MP_SHRINK(m) do { \ mp *_mm = (m); \ MPX_SHRINK(_mm->v, _mm->vl); \ - if (!MP_LEN(_mm)) \ + if (MP_ZEROP(_mm)) \ _mm->f &= ~MP_NEG; \ } while (0) @@ -795,11 +795,11 @@ extern int mp_cmp(const mp */*a*/, const mp */*b*/); /* --- Other handy macros --- */ -#define MP_ISNEG(x) ((x)->f & MP_NEG) -#define MP_ISZERO(x) (!MP_LEN(x)) -#define MP_ISPOS(x) (!MP_ISNEG(x) && !MP_ISZERO(x)) -#define MP_ISODD(x) (!MP_ISZERO(x) && ((x)->v[0] & 1u)) -#define MP_ISEVEN(x) (!MP_ISODD(x)) +#define MP_NEGP(x) ((x)->f & MP_NEG) +#define MP_ZEROP(x) (!MP_LEN(x)) +#define MP_POSP(x) (!MP_NEGP(x) && !MP_ZEROP(x)) +#define MP_ODDP(x) (!MP_ZEROP(x) && ((x)->v[0] & 1u)) +#define MP_EVENP(x) (!MP_ODDP(x)) /*----- Arithmetic operations ---------------------------------------------*/ @@ -866,6 +866,17 @@ extern mp *mp_sqr(mp */*d*/, mp */*a*/); extern void mp_div(mp **/*qq*/, mp **/*rr*/, mp */*a*/, mp */*b*/); +/* --- @mp_exp@ --- * + * + * Arguments: @mp *d@ = fake destination + * @mp *a@ = base + * @mp *e@ = exponent + * + * Returns: Result, %$a^e$%. + */ + +extern mp *mp_exp(mp */*d*/, mp */*a*/, mp */*e*/); + /* --- @mp_odd@ --- * * * Arguments: @mp *d@ = pointer to destination integer @@ -957,6 +968,9 @@ extern int mp_jacobi(mp */*a*/, mp */*n*/); * work if %$p$% is composite: you must factor the modulus, take * a square root mod each factor, and recombine the results * using the Chinese Remainder Theorem. + * + * We guarantee that the square root returned is the smallest + * one (i.e., the `positive' square root). */ extern mp *mp_modsqrt(mp */*d*/, mp */*a*/, mp */*p*/);