X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/d3409d5ecf2492cff862616de72a580d1a8e8dc0..0e89568975a5817dbb5a2752403d9b8d82046445:/mp.h?ds=sidebyside diff --git a/mp.h b/mp.h index 72aa675..dce8128 100644 --- a/mp.h +++ b/mp.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: mp.h,v 1.2 1999/11/17 18:02:16 mdw Exp $ + * $Id: mp.h,v 1.5 1999/11/22 20:50:37 mdw Exp $ * * Simple multiprecision arithmetic * @@ -30,6 +30,15 @@ /*----- Revision history --------------------------------------------------* * * $Log: mp.h,v $ + * Revision 1.5 1999/11/22 20:50:37 mdw + * Add support for computing Jacobi symbols. + * + * Revision 1.4 1999/11/21 22:13:02 mdw + * Add mp version of MPX_BITS. + * + * Revision 1.3 1999/11/19 13:19:14 mdw + * Fix const annotation. + * * Revision 1.2 1999/11/17 18:02:16 mdw * New multiprecision integer arithmetic suite. * @@ -396,7 +405,7 @@ extern void mp_minimize(mp */*m*/); extern void mp_scan(mpscan */*sc*/, const mp */*m*/); #define MP_SCAN(sc, m) do { \ - mp *_mm = (m); \ + const mp *_mm = (m); \ mpscan *_sc = (sc); \ MPSCAN_INITX(_sc, _mm->v, _mm->vl); \ } while (0) @@ -421,7 +430,19 @@ extern void mp_scan(mpscan */*sc*/, const mp */*m*/); * integer. */ -extern size_t mp_octets(const mp *m); +extern size_t mp_octets(const mp */*m*/); + +/* --- @mp_bits@ --- * + * + * Arguments: @const mp *m@ = a multiprecision integer + * + * Returns: The number of bits required to represent @m@. + * + * Use: Calculates the external storage required for a multiprecision + * integer. + */ + +extern unsigned long mp_bits(const mp */*m*/); /* --- @mp_loadl@ --- * * @@ -621,6 +642,21 @@ extern void mp_div(mp **/*qq*/, mp **/*rr*/, extern void mp_gcd(mp **/*gcd*/, mp **/*xx*/, mp **/*yy*/, mp */*a*/, mp */*b*/); +/* --- @mp_jacobi@ --- * + * + * Arguments: @mp *a@ = an integer less than @n@ + * @mp *n@ = an odd integer + * + * Returns: @-1@, @0@ or @1@ -- the Jacobi symbol %$J(a, n)$%. + * + * Use: Computes the Jacobi symbol. If @n@ is prime, this is the + * Legendre symbol and is equal to 1 if and only if @a@ is a + * quadratic residue mod @n@. The result is zero if and only if + * @a@ and @n@ have a common factor greater than one. + */ + +int mp_jacobi(mp */*a*/, mp */*n*/); + /*----- Test harness support ----------------------------------------------*/ #include