mpn_sec_div tests

Niels Möller nisse at lysator.liu.se
Sat Feb 8 14:16:11 UTC 2014


I tried to improve the mpn_sec_div_* tests, by adding the following to
the t-div test:

--- a/tests/mpn/t-div.c	Thu Feb 06 08:14:38 2014 +0100
+++ b/tests/mpn/t-div.c	Sat Feb 08 14:57:23 2014 +0100
@@ -308,8 +308,15 @@ main (int argc, char **argv)
 	    MPN_COPY (qp, junkp, nn - dn + 1);
 	  qp[nn - dn] = mpn_sec_div_qr (qp, rp, nn, dup, dn, scratch);
 	  ASSERT_ALWAYS (ran == scratch[itch]);
-	  check_one (qp, rp, np, nn, dup, dn, "mpn_sec_div_qr", 0);
-
+	  check_one (qp, rp, np, nn, dup, dn, "mpn_sec_div_qr (unnorm)", 0);
+#if 1
+	  MPN_COPY (rp, np, nn);
+	  if (nn >= dn)
+	    MPN_COPY (qp, junkp, nn - dn + 1);
+	  qp[nn - dn] = mpn_sec_div_qr (qp, rp, nn, dnp, dn, scratch);
+	  ASSERT_ALWAYS (ran == scratch[itch]);
+	  check_one (qp, rp, np, nn, dnp, dn, "mpn_sec_div_qr (norm)", 0);
+#endif
 	  /* Test mpn_sec_div_r */
 	  itch = mpn_sec_div_r_itch (nn, dn);
 	  if (itch + 1 > alloc)

But I then get the following failure, from the mpn_sec_div_r test just
after this change,

*******************************************************************************
mpn_sec_div_r failed test -300: q too small
N=    19e6b016cd8e4b6a ffffffffffffffff ffffffffffffffff
ffffffffffffffff ... ffffffffffffffff ffffffffffffffff ffffffffffffffff
ffffffffffffffff
D=    0000000000000001
Q=    0000000000000000 33cd602d9b1c96d5 98653fa4c9c6d254
cf3580b66c725b56 ... c56d5d8653fa4c9c 752544f3580b66c7 15b576194fe93271
d49513cd602d9b1c
R=    0000000000000000
N-Q*D=0000000000000000 19e6b016cd8e4b6a cc329fd264e3692a
679ac05b36392dab ... 3a92a279ac05b363 8adabb0ca7f49938 ea4a89e6b016cd8e
2b6aec329fd264e3
nn = 3136, dn = 1, qn = 3136

I'm a bit puzzled. I can't spot any error in the test code (which is a
copy of the test just above, but using dnp (normalized divisor) rather
than dup. So maybe the mpn_sec_div_qr call overwrites something in this
case?

I'll try to debug this fairly soon.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.



More information about the gmp-devel mailing list