use mpn_tdiv_qr

dev
MITSUNARI Shigeo 9 years ago
parent f6a68cdfab
commit 09db288495
  1. 16
      src/fp.cpp

@ -172,22 +172,14 @@ struct OpeFunc {
// y[N] <- x[N + 1] mod p[N] // y[N] <- x[N + 1] mod p[N]
static inline void fpN1_modPC(Unit *y, const Unit *x, const Unit *p) static inline void fpN1_modPC(Unit *y, const Unit *x, const Unit *p)
{ {
mpz_t mx, my, mp; Unit q[2]; // not used
set_mpz_t(mx, x, N + 1); mpn_tdiv_qr(q, y, 0, x, N + 1, p, N);
set_mpz_t(my, y);
set_mpz_t(mp, p);
mpz_mod(my, mx, mp);
clearArray(y, my->_mp_size, N);
} }
// y[N] <- x[N * 2] mod p[N] // y[N] <- x[N * 2] mod p[N]
static inline void fpDbl_modPC(Unit *y, const Unit *x, const Unit *p) static inline void fpDbl_modPC(Unit *y, const Unit *x, const Unit *p)
{ {
mpz_t mx, my, mp; Unit q[N + 1]; // not used
set_mpz_t(mx, x, N * 2); mpn_tdiv_qr(q, y, 0, x, N * 2, p, N);
set_mpz_t(my, y);
set_mpz_t(mp, p);
mpz_mod(my, mx, mp);
clearArray(y, my->_mp_size, N);
} }
static inline void fp_invOpC(Unit *y, const Unit *x, const Op& op) static inline void fp_invOpC(Unit *y, const Unit *x, const Op& op)
{ {

Loading…
Cancel
Save