[flint] 07/24: Use precomputed inverse in large base mod operation in both versions of n_is_strong_probabprime.

felix salfelder felix-guest at moszumanska.debian.org
Wed Jun 25 11:16:11 UTC 2014


This is an automated email from the git hooks/post-receive script.

felix-guest pushed a commit to branch master
in repository flint.

commit d77e98c5fc345eb241e8d628c699fd62b24955d7
Author: William Hart <goodwillhart at googlemail.com>
Date:   Tue Jun 17 15:25:45 2014 +0100

    Use precomputed inverse in large base mod operation in both versions of
    n_is_strong_probabprime.
---
 ulong_extras/is_strong_probabprime2_preinv.c | 6 ++++--
 ulong_extras/is_strong_probabprime_precomp.c | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/ulong_extras/is_strong_probabprime2_preinv.c b/ulong_extras/is_strong_probabprime2_preinv.c
index 442480a..4ba08ba 100644
--- a/ulong_extras/is_strong_probabprime2_preinv.c
+++ b/ulong_extras/is_strong_probabprime2_preinv.c
@@ -37,8 +37,10 @@ n_is_strong_probabprime2_preinv(mp_limb_t n, mp_limb_t ninv, mp_limb_t a,
     mp_limb_t y;
 
     /* Map large base to range 2 ... n-1 */
-    if (a >= n)  a %= n;
-    if ((a <= 1) || (a == n-1))  return 1;
+    if (a >= n)  
+       a = n_mod2_preinv(a, n, ninv);
+
+    if ((a <= 1) || (a == n - 1))  return 1;
 
     y = n_powmod2_ui_preinv(a, t, n, ninv);
 
diff --git a/ulong_extras/is_strong_probabprime_precomp.c b/ulong_extras/is_strong_probabprime_precomp.c
index c3f86e1..56c5a93 100644
--- a/ulong_extras/is_strong_probabprime_precomp.c
+++ b/ulong_extras/is_strong_probabprime_precomp.c
@@ -36,8 +36,10 @@ n_is_strong_probabprime_precomp(mp_limb_t n, double npre, mp_limb_t a,
     mp_limb_t t = d;
     mp_limb_t y;
 
-    /* Map large base to range 2 ... n-1 */
-    if (a >= n)  a %= n;
+    /* Map large base to range 2 ... n - 1 */
+    if (a >= n)  
+       a = n_mod2_precomp(a, n, npre);
+
     if ((a <= 1) || (a == n-1))  return 1;
 
     y = n_powmod_ui_precomp(a, t, n, npre);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/flint.git



More information about the debian-science-commits mailing list