[Gmp-commit] /var/hg/gmp: 2 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Fri Sep 11 06:02:09 UTC 2015


details:   /var/hg/gmp/rev/8bc59c1dd566
changeset: 16823:8bc59c1dd566
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Fri Sep 11 07:59:12 2015 +0200
description:
mpf_cmp_z, with test.

details:   /var/hg/gmp/rev/e9d16353c722
changeset: 16824:e9d16353c722
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Fri Sep 11 08:01:43 2015 +0200
description:
Retune

diffstat:

 ChangeLog                   |   8 +++++++
 Makefile.am                 |   4 +-
 gmp-h.in                    |   3 ++
 mpf/Makefile.am             |   2 +-
 mpf/cmp_z.c                 |  46 +++++++++++++++++++++++++++++++++++++++++++++
 mpn/x86_64/bd2/gmp-mparam.h |  11 ++++++---
 tests/mpf/t-cmp_si.c        |  33 +++++++++++++++++++++++++++++--
 7 files changed, 97 insertions(+), 10 deletions(-)

diffs (205 lines):

diff -r 7dc94e85dc54 -r e9d16353c722 ChangeLog
--- a/ChangeLog	Tue Sep 08 18:23:08 2015 +0200
+++ b/ChangeLog	Fri Sep 11 08:01:43 2015 +0200
@@ -1,3 +1,11 @@
+2015-09-11 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+	* mpf/cmp_z.c: New file implementing mpf_cmp_z.
+	* mpf/Makefile.am (libmpf_la_SOURCES): Add it.
+	* Makefile.am (MPF_OBJECTS): Add generate object to libs.
+	* gmp-h.in: Declare new function.
+	* tests/mpf/t-cmp_si.c: Test also the new function.
+
 2015-09-06  Torbjörn Granlund  <torbjorng at google.com>
 
 	* Wrap remaining limb allocations in __GMP_ALLOCATE_FUNC_LIMBS.
diff -r 7dc94e85dc54 -r e9d16353c722 Makefile.am
--- a/Makefile.am	Tue Sep 08 18:23:08 2015 +0200
+++ b/Makefile.am	Fri Sep 11 08:01:43 2015 +0200
@@ -1,7 +1,7 @@
 ## Process this file with automake to generate Makefile.in
 
 
-# Copyright 1991, 1993, 1994, 1996, 1997, 1999-2004, 2006-2009, 2011-2014 Free
+# Copyright 1991, 1993, 1994, 1996, 1997, 1999-2004, 2006-2009, 2011-2015 Free
 # Software Foundation, Inc.
 #
 #  This file is part of the GNU MP Library.
@@ -147,7 +147,7 @@
   mpf/get_str$U.lo mpf/dump$U.lo mpf/size$U.lo mpf/eq$U.lo mpf/reldiff$U.lo \
   mpf/sqrt$U.lo mpf/random2$U.lo mpf/inp_str$U.lo mpf/out_str$U.lo	    \
   mpf/add$U.lo mpf/add_ui$U.lo mpf/sub$U.lo mpf/sub_ui$U.lo mpf/ui_sub$U.lo \
-  mpf/mul$U.lo mpf/mul_ui$U.lo mpf/div$U.lo mpf/div_ui$U.lo		    \
+  mpf/mul$U.lo mpf/mul_ui$U.lo mpf/div$U.lo mpf/div_ui$U.lo mpf/cmp_z$U.lo  \
   mpf/cmp$U.lo mpf/cmp_d$U.lo mpf/cmp_ui$U.lo mpf/cmp_si$U.lo		    \
   mpf/mul_2exp$U.lo mpf/div_2exp$U.lo mpf/abs$U.lo mpf/neg$U.lo		    \
   mpf/set_q$U.lo mpf/get_d$U.lo mpf/get_d_2exp$U.lo mpf/set_dfl_prec$U.lo   \
diff -r 7dc94e85dc54 -r e9d16353c722 gmp-h.in
--- a/gmp-h.in	Tue Sep 08 18:23:08 2015 +0200
+++ b/gmp-h.in	Fri Sep 11 08:01:43 2015 +0200
@@ -1268,6 +1268,9 @@
 #define mpf_cmp __gmpf_cmp
 __GMP_DECLSPEC int mpf_cmp (mpf_srcptr, mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
 
+#define mpf_cmp_z __gmpf_cmp_z
+__GMP_DECLSPEC int mpf_cmp_z (mpf_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
+
 #define mpf_cmp_d __gmpf_cmp_d
 __GMP_DECLSPEC int mpf_cmp_d (mpf_srcptr, double) __GMP_ATTRIBUTE_PURE;
 
diff -r 7dc94e85dc54 -r e9d16353c722 mpf/Makefile.am
--- a/mpf/Makefile.am	Tue Sep 08 18:23:08 2015 +0200
+++ b/mpf/Makefile.am	Fri Sep 11 08:01:43 2015 +0200
@@ -37,7 +37,7 @@
   set_q.c iset.c iset_ui.c iset_si.c iset_str.c iset_d.c clear.c clears.c \
   get_str.c dump.c size.c eq.c reldiff.c sqrt.c random2.c inp_str.c out_str.c \
   add.c add_ui.c sub.c sub_ui.c ui_sub.c mul.c mul_ui.c div.c div_ui.c \
-  cmp.c cmp_d.c cmp_si.c cmp_ui.c mul_2exp.c div_2exp.c abs.c neg.c get_d.c \
+  cmp.c cmp_d.c cmp_z.c cmp_si.c cmp_ui.c mul_2exp.c div_2exp.c abs.c neg.c get_d.c \
   get_d_2exp.c set_dfl_prec.c set_prc.c set_prc_raw.c get_dfl_prec.c get_prc.c \
   ui_div.c sqrt_ui.c \
   pow_ui.c urandomb.c swap.c get_si.c get_ui.c int_p.c \
diff -r 7dc94e85dc54 -r e9d16353c722 mpf/cmp_z.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpf/cmp_z.c	Fri Sep 11 08:01:43 2015 +0200
@@ -0,0 +1,46 @@
+/* mpf_cmp_z -- Compare a float with an integer.
+
+Copyright 2015 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP Library is free software; you can redistribute it and/or modify
+it under the terms of either:
+
+  * the GNU Lesser General Public License as published by the Free
+    Software Foundation; either version 3 of the License, or (at your
+    option) any later version.
+
+or
+
+  * the GNU General Public License as published by the Free Software
+    Foundation; either version 2 of the License, or (at your option) any
+    later version.
+
+or both in parallel, as here.
+
+The GNU MP Library is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received copies of the GNU General Public License and the
+GNU Lesser General Public License along with the GNU MP Library.  If not,
+see https://www.gnu.org/licenses/.  */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+
+int
+mpf_cmp_z (mpf_srcptr u, mpz_srcptr v) __GMP_NOTHROW
+{
+  mpf_t vf;
+  mp_size_t size;
+
+  SIZ (vf) = size = SIZ (v);
+  EXP (vf) = size = ABS (size);
+  /* PREC (vf) = size; */ 
+  PTR (vf) = PTR (v);
+
+  return mpf_cmp (u, vf);
+}
diff -r 7dc94e85dc54 -r e9d16353c722 mpn/x86_64/bd2/gmp-mparam.h
--- a/mpn/x86_64/bd2/gmp-mparam.h	Tue Sep 08 18:23:08 2015 +0200
+++ b/mpn/x86_64/bd2/gmp-mparam.h	Fri Sep 11 08:01:43 2015 +0200
@@ -197,14 +197,17 @@
 
 #define MULLO_BASECASE_THRESHOLD             0  /* always */
 #define MULLO_DC_THRESHOLD                  37
-#define MULLO_MUL_N_THRESHOLD             8397
+#define MULLO_MUL_N_THRESHOLD             8648
+#define SQRLO_BASECASE_THRESHOLD             8
+#define SQRLO_DC_THRESHOLD                  56
+#define SQRLO_SQR_THRESHOLD               6440
 
 #define DC_DIV_QR_THRESHOLD                 42
 #define DC_DIVAPPR_Q_THRESHOLD             173
 #define DC_BDIV_QR_THRESHOLD                42
 #define DC_BDIV_Q_THRESHOLD                 77
 
-#define INV_MULMOD_BNM1_THRESHOLD           30
+#define INV_MULMOD_BNM1_THRESHOLD           34
 #define INV_NEWTON_THRESHOLD               202
 #define INV_APPR_THRESHOLD                 172
 
@@ -233,5 +236,5 @@
 #define SET_STR_DC_THRESHOLD               204
 #define SET_STR_PRECOMPUTE_THRESHOLD      1160
 
-#define FAC_DSC_THRESHOLD                  166
-#define FAC_ODD_THRESHOLD                   24
+#define FAC_DSC_THRESHOLD                  173
+#define FAC_ODD_THRESHOLD                    0  /* always */
diff -r 7dc94e85dc54 -r e9d16353c722 tests/mpf/t-cmp_si.c
--- a/tests/mpf/t-cmp_si.c	Tue Sep 08 18:23:08 2015 +0200
+++ b/tests/mpf/t-cmp_si.c	Fri Sep 11 08:01:43 2015 +0200
@@ -1,6 +1,6 @@
-/* Test mpf_cmp_si.
+/* Test mpf_cmp_si and mpf_cmp_z.
 
-Copyright 2000, 2001, 2004 Free Software Foundation, Inc.
+Copyright 2000, 2001, 2004, 2015 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library test suite.
 
@@ -46,6 +46,14 @@
     { 10, "-1",  "0", -1 },
     { 10, "-1", "-1", 0 },
 
+    { 10, "1.5", "2", -1 },
+    { 10, "1.5", "1",  1 },
+    { 10, "0.5", "1", -1 },
+
+    { 10, "-1.5", "-2",  1 },
+    { 10, "-1.5", "-1", -1 },
+    { 10, "-0.5", "-1",  1 },
+
     { 16,         "0", "-0x80000000",  1 },
     { 16,  "80000000", "-0x80000000",  1 },
     { 16,  "80000001", "-0x80000000",  1 },
@@ -57,8 +65,15 @@
     { 16,  "8000000000000000", "-0x8000000000000000",  1 },
     { 16,  "8000000000000001", "-0x8000000000000000",  1 },
     { 16, "-8000000000000000", "-0x8000000000000000",  0 },
-    { 16, "-8000000000000001", "-0x8000000000000000", -1 },
+    { 16, "-8000000000000000.1", "-0x8000000000000000", -1 },
     { 16, "-FF008000000000000001", "-0x8000000000000000", -1 },
+
+    { 16,                 "0", "-0x876543210FEDCBA9876543210000000",  1 },
+    { 16,  "876543210FEDCBA9876543210000000", "-0x876543210FEDCBA9876543210000000",  1 },
+    { 16,  "876543210FEDCBA9876543210000001", "-0x876543210FEDCBA9876543210000000",  1 },
+    { 16, "-876543210FEDCBA9876543210000000", "-0x876543210FEDCBA9876543210000000",  0 },
+    { 16, "-876543210FEDCBA9876543210000000.1", "-0x876543210FEDCBA9876543210000000", -1 },
+    { 16, "-FF00876543210FEDCBA9876543210000000", "-0x876543210FEDCBA9876543210000000", -1 },
   };
 
   mpf_t  a;
@@ -89,6 +104,18 @@
               abort();
             }
         }
+
+      got = mpf_cmp_z (a, bz);
+      if (SGN (got) != data[i].want)
+      	{
+      	  printf ("mpf_cmp_z wrong on data[%d]\n", i);
+      	  printf ("  a="); mpf_out_str (stdout, 10, 0, a);
+      	  printf (" (%s)\n", data[i].a);
+      	  printf ("  b=%ld (%s)\n", b, data[i].b);
+      	  printf ("  got=%d\n", got);
+      	  printf ("  want=%d\n", data[i].want);
+      	  abort();
+      	}
     }
 
   mpf_clear (a);


More information about the gmp-commit mailing list