X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/0f00dc4c8eb47e67bc0f148c2dd109f73a451e0a..318c3c31be343fdba362cb60f33aab3e88798d8a:/math/mp.h diff --git a/math/mp.h b/math/mp.h index cfaeed5e..0434c282 100644 --- a/math/mp.h +++ b/math/mp.h @@ -37,6 +37,7 @@ #include #include +#include #include #ifndef CATACOMB_MPW_H @@ -196,7 +197,8 @@ extern void mp_destroy(mp */*m*/); extern mp *mp_copy(mp */*m*/); -#define MP_COPY(m) ((m)->ref++, (m)) +#define MP_COPY(m) MUFFLE_WARNINGS_EXPR(GCC_WARNING("-Wunused-value"), \ + ((m)->ref++, (m))) /* --- @mp_drop@ --- * * @@ -890,6 +892,19 @@ extern mp *mp_exp(mp */*d*/, mp */*a*/, mp */*e*/); extern mp *mp_odd(mp */*d*/, mp */*m*/, size_t */*s*/); +/* --- @mp_leastcongruent@ --- * + * + * Arguments: @mp *d@ = pointer to destination + * @mp *b@ = lower bound + * @mp *r@ = representative + * @mp *m@ = modulus + * + * Returns: The smallest integer %$x \equiv r \pmod{m}$% such that + * %$x \ge b$%. + */ + +extern mp *mp_leastcongruent(mp */*d*/, mp */*b*/, mp */*r*/, mp */*m*/); + /*----- More advanced algorithms ------------------------------------------*/ /* --- @mp_sqrt@ --- * @@ -961,11 +976,11 @@ extern mp *mp_modinv(mp */*d*/, mp */*x*/, mp */*p*/); * * %$\jacobi{a}{-1} = 1$% if @a@ is negative, or 1 if * positive; * * %$\jacobi{a}{0} = 0$%; - * * %$\jacobi{a}{2}$ is 0 if @a@ is even, 1 if @a@ is + * * %$\jacobi{a}{2}$ is 0 if @a@ is even, 1 if @a@ is * congruent to 1 or 7 (mod 8), or %$-1$% otherwise. * * If %$n$% is positive and odd, then this is the Jacobi - * symbol. (The Kronecker symbol is a consistant domain + * symbol. (The Kronecker symbol is a consistent domain * extension; the Jacobi symbol was implemented first, and the * name stuck.) */