[Gmp-commit] /home/hgfiles/gmp: Test split only if split is possible.

mercurial at gmplib.org mercurial at gmplib.org
Sat Dec 12 08:26:51 CET 2009


details:   /home/hgfiles/gmp/rev/f70ffd31618c
changeset: 13040:f70ffd31618c
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sat Dec 12 08:26:45 2009 +0100
description:
Test split only if split is possible.

diffstat:

 tests/mpn/t-mulmod_bnm1.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (16 lines):

diff -r 8155c651b234 -r f70ffd31618c tests/mpn/t-mulmod_bnm1.c
--- a/tests/mpn/t-mulmod_bnm1.c	Sat Dec 12 00:05:18 2009 +0100
+++ b/tests/mpn/t-mulmod_bnm1.c	Sat Dec 12 08:26:45 2009 +0100
@@ -151,8 +151,10 @@
       mpn_random2 (ap, an);
       mpn_random2 (bp, bn);
 
-      /* Sometime trigger the an = -1 or bn = -1 or an*bn == -1 Mod(B^{n/2}+1) */
-      if ((test & 0x1f) == 1 && n > 1) {
+      /* Sometime trigger the borderline conditions
+	 A = -1,0,+1 or B = -1,0,+1 or A*B == -1,0,1 Mod(B^{n/2}+1).
+	 This only makes sense if there is at least a split, i.e. n is even. */
+      if ((test & 0x1f) == 1 && (n & 1) == 0) {
 	mp_size_t x;
 	MPN_COPY (ap, ap + (n >> 1), an - (n >> 1));
 	MPN_ZERO (ap + an - (n >> 1) , n - an);


More information about the gmp-commit mailing list