[Gmp-commit] /home/hgfiles/gmp: tests/devel/try mpn_bdiv_q_1 support.
mercurial at gmplib.org
mercurial at gmplib.org
Fri Jan 21 11:19:02 CET 2011
details: /home/hgfiles/gmp/rev/1b01932cee5c
changeset: 13752:1b01932cee5c
user: Marco Bodrato <bodrato at mail.dm.unipi.it>
date: Fri Jan 21 11:03:51 2011 +0100
description:
tests/devel/try mpn_bdiv_q_1 support.
diffstat:
ChangeLog | 4 ++++
tests/devel/try.c | 45 +++++++++++++++++++++++++++++++++++++++++----
2 files changed, 45 insertions(+), 4 deletions(-)
diffs (101 lines):
diff -r 37ac1001d611 -r 1b01932cee5c ChangeLog
--- a/ChangeLog Thu Jan 20 11:33:06 2011 +0100
+++ b/ChangeLog Fri Jan 21 11:03:51 2011 +0100
@@ -1,3 +1,7 @@
+2011-01-21 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+ * tests/devel/try.c: Initial support for mpn_bdiv_q_1.
+
2011-01-20 Torbjorn Granlund <tege at gmplib.org>
* mpn/powerpc64/mode64/aorsmul_1.asm: Trim away 0.5 c/l for submul_1
diff -r 37ac1001d611 -r 1b01932cee5c tests/devel/try.c
--- a/tests/devel/try.c Thu Jan 20 11:33:06 2011 +0100
+++ b/tests/devel/try.c Fri Jan 21 11:03:51 2011 +0100
@@ -3,8 +3,8 @@
THIS IS A TEST PROGRAM USED ONLY FOR DEVELOPMENT. IT'S ALMOST CERTAIN TO
BE SUBJECT TO INCOMPATIBLE CHANGES IN FUTURE VERSIONS OF GMP.
-Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 Free Software
-Foundation, Inc.
+Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2011
+Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -439,6 +439,36 @@
validate_fail ();
}
+void
+validate_bdiv_q_1
+ (void)
+{
+ mp_srcptr src = s[0].p;
+ mp_srcptr dst = fun.d[0].p;
+ int error = 0;
+
+ ASSERT (size >= 1);
+
+ {
+ mp_ptr tp = refmpn_malloc_limbs (size + 1);
+
+ refmpn_mul_1 (tp, dst, size, divisor);
+ /* Set ignored low bits */
+ tp[0] |= (src[0] & LOW_ZEROS_MASK (divisor));
+ if (! refmpn_equal_anynail (tp, src, size))
+ {
+ printf ("Bdiv wrong: res * divisor != src (mod B^size)\n");
+ mpn_trace ("res ", dst, size);
+ mpn_trace ("src ", src, size);
+ error = 1;
+ }
+ free (tp);
+ }
+
+ if (error)
+ validate_fail ();
+}
+
void
validate_modexact_1c_odd (void)
@@ -581,8 +611,8 @@
TYPE_DIVREM_1C, TYPE_PREINV_DIVREM_1, TYPE_DIVREM_2, TYPE_PREINV_MOD_1,
TYPE_MOD_34LSUB1, TYPE_UDIV_QRNND, TYPE_UDIV_QRNND_R,
- TYPE_DIVEXACT_1, TYPE_DIVEXACT_BY3, TYPE_DIVEXACT_BY3C, TYPE_MODEXACT_1_ODD,
- TYPE_MODEXACT_1C_ODD,
+ TYPE_DIVEXACT_1, TYPE_BDIV_Q_1, TYPE_DIVEXACT_BY3, TYPE_DIVEXACT_BY3C,
+ TYPE_MODEXACT_1_ODD, TYPE_MODEXACT_1C_ODD,
TYPE_INVERT, TYPE_BINVERT,
@@ -964,6 +994,11 @@
VALIDATE (validate_divexact_1);
REFERENCE (refmpn_divmod_1);
+ p = ¶m[TYPE_BDIV_Q_1];
+ p->dst[0] = 1;
+ p->src[0] = 1;
+ p->divisor = DIVISOR_LIMB;
+ VALIDATE (validate_bdiv_q_1);
p = ¶m[TYPE_DIVEXACT_BY3];
p->retval = 1;
@@ -1508,6 +1543,7 @@
#endif
{ TRY(mpn_divexact_1), TYPE_DIVEXACT_1 },
+ { TRY(mpn_bdiv_q_1), TYPE_BDIV_Q_1 },
{ TRY_FUNFUN(mpn_divexact_by3), TYPE_DIVEXACT_BY3 },
{ TRY(mpn_divexact_by3c), TYPE_DIVEXACT_BY3C },
@@ -2134,6 +2170,7 @@
case TYPE_DIVMOD_1:
case TYPE_DIVEXACT_1:
+ case TYPE_BDIV_Q_1:
e->retval = CALLING_CONVENTIONS (function)
(e->d[0].p, e->s[0].p, size, divisor);
break;
More information about the gmp-commit
mailing list