rewrite fpDbl_addPC

dev
MITSUNARI Shigeo 9 years ago
parent 6f7ba77826
commit f6a68cdfab
  1. 17
      src/fp.cpp

@ -130,29 +130,14 @@ struct OpeFunc {
*/
static inline void fpDbl_addPC(Unit *z, const Unit *x, const Unit *y, const Unit *p)
{
#if 0
if (mpn_add_n(z, x, y, N * 2)) {
mpn_sub_n(z + N, z + N, p, N);
return;
}
Unit tmp[N];
if (mpn_sub_n(tmp, z + N, p, N) == 0) {
memcpy(z, tmp, sizeof(tmp));
memcpy(z + N, tmp, sizeof(tmp));
}
#else
Unit ret[N * 2 + 2]; // not N + 1
Unit pDbl[N * 2];
mpz_t mz, mx, my, mp;
set_zero(mz, ret, N * 2 + 2);
set_mpz_t(mx, x, N * 2);
set_mpz_t(my, y, N * 2);
set_pDbl(mp, pDbl, p);
mpz_add(mz, mx, my);
if (mpz_cmp(mz, mp) >= 0) {
mpz_sub(mz, mz, mp);
}
gmp::getArray(z, N * 2, mz);
#endif
}
static inline void fpDbl_subPC(Unit *z, const Unit *x, const Unit *y, const Unit *p)
{

Loading…
Cancel
Save