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

mercurial at gmplib.org mercurial at gmplib.org
Sun May 20 11:24:54 UTC 2018


details:   /var/hg/gmp/rev/06cb5eecb46c
changeset: 17627:06cb5eecb46c
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Wed May 16 22:24:06 2018 +0200
description:
Copyright years

details:   /var/hg/gmp/rev/43659273c9cf
changeset: 17628:43659273c9cf
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun May 20 13:19:28 2018 +0200
description:
mini-gmp.c (mpz_get_d): Convert a fixed number of bits

details:   /var/hg/gmp/rev/8e0a2e94ae5a
changeset: 17629:8e0a2e94ae5a
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun May 20 13:24:44 2018 +0200
description:
mini-gmp/mini-mpq.c (mpq_mul): Use mpq_nan_init (new function)

diffstat:

 ChangeLog                     |   4 ++++
 Makefile.am                   |   4 ++--
 acinclude.m4                  |   2 +-
 bootstrap.c                   |   1 +
 gen-bases.c                   |   2 +-
 gen-trialdivtab.c             |   2 +-
 gmp-impl.h                    |   2 +-
 longlong.h                    |   2 +-
 mini-gmp/ChangeLog            |   7 +++++++
 mini-gmp/mini-gmp.c           |  32 +++++++++++++++++++++++++++++---
 mini-gmp/mini-mpq.c           |   9 ++++++++-
 mini-gmp/tests/Makefile       |   2 +-
 mini-gmp/tests/testutils.c    |   2 +-
 mpn/generic/div_q.c           |   2 +-
 mpn/generic/divis.c           |   3 ++-
 mpn/powerpc32/powerpc-defs.m4 |   2 +-
 mpq/clear.c                   |   3 ++-
 mpq/clears.c                  |   2 +-
 mpq/div.c                     |   3 ++-
 mpq/get_d.c                   |   5 +----
 mpq/init.c                    |   3 ++-
 mpq/inp_str.c                 |   2 +-
 mpq/md_2exp.c                 |   2 +-
 mpq/set_d.c                   |   3 ++-
 mpq/set_f.c                   |   2 +-
 mpq/set_si.c                  |   2 +-
 mpq/set_str.c                 |   2 +-
 mpq/set_ui.c                  |   2 +-
 mpq/set_z.c                   |   2 +-
 mpz/2fac_ui.c                 |   2 +-
 printf/obprintf.c             |   2 +-
 printf/obprntffuns.c          |   2 +-
 printf/obvprintf.c            |   2 +-
 printf/repl-vsnprintf.c       |   2 +-
 printf/snprntffuns.c          |   2 +-
 tests/mpn/t-div.c             |   3 ++-
 tune/speed.c                  |   2 +-
 37 files changed, 88 insertions(+), 40 deletions(-)

diffs (truncated from 508 to 300 lines):

diff -r 41e50c4fdc46 -r 8e0a2e94ae5a ChangeLog
--- a/ChangeLog	Wed May 16 08:36:03 2018 +0200
+++ b/ChangeLog	Sun May 20 13:24:44 2018 +0200
@@ -1,3 +1,7 @@
+2018-05-20 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+	* bootstrap.c: Define DONT_USE_FLOAT_H before including mini-gmp.
+
 2018-05-14 Marco Bodrato <bodrato at mail.dm.unipi.it>
 
 	* mpn/generic/dcpi1_bdiv_q.c (mpn_dcpi1_bdiv_q_n): Decl. static.
diff -r 41e50c4fdc46 -r 8e0a2e94ae5a Makefile.am
--- a/Makefile.am	Wed May 16 08:36:03 2018 +0200
+++ b/Makefile.am	Sun May 20 13:24:44 2018 +0200
@@ -1,8 +1,8 @@
 ## Process this file with automake to generate Makefile.in
 
 
-# Copyright 1991, 1993, 1994, 1996, 1997, 1999-2004, 2006-2009, 2011-2016 Free
-# Software Foundation, Inc.
+# Copyright 1991, 1993, 1994, 1996, 1997, 1999-2004, 2006-2009, 2011-2016,
+# 2018 Free Software Foundation, Inc.
 #
 #  This file is part of the GNU MP Library.
 #
diff -r 41e50c4fdc46 -r 8e0a2e94ae5a acinclude.m4
--- a/acinclude.m4	Wed May 16 08:36:03 2018 +0200
+++ b/acinclude.m4	Sun May 20 13:24:44 2018 +0200
@@ -1,7 +1,7 @@
 dnl  GMP specific autoconf macros
 
 
-dnl  Copyright 2000-2006, 2009, 2011, 2013-2015 Free Software Foundation, Inc.
+dnl  Copyright 2000-2006, 2009, 2011, 2013-2018 Free Software Foundation, Inc.
 dnl
 dnl  This file is part of the GNU MP Library.
 dnl
diff -r 41e50c4fdc46 -r 8e0a2e94ae5a bootstrap.c
--- a/bootstrap.c	Wed May 16 08:36:03 2018 +0200
+++ b/bootstrap.c	Sun May 20 13:24:44 2018 +0200
@@ -29,6 +29,7 @@
 see https://www.gnu.org/licenses/.  */
 
 
+#define DONT_USE_FLOAT_H 1
 #include "mini-gmp/mini-gmp.c"
 
 #define MIN(l,o) ((l) < (o) ? (l) : (o))
diff -r 41e50c4fdc46 -r 8e0a2e94ae5a gen-bases.c
--- a/gen-bases.c	Wed May 16 08:36:03 2018 +0200
+++ b/gen-bases.c	Sun May 20 13:24:44 2018 +0200
@@ -1,7 +1,7 @@
 /* Generate mp_bases data.
 
 Copyright 1991, 1993, 1994, 1996, 2000, 2002, 2004, 2011, 2012,
-2015-2017 Free Software Foundation, Inc.
+2015-2018 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
diff -r 41e50c4fdc46 -r 8e0a2e94ae5a gen-trialdivtab.c
--- a/gen-trialdivtab.c	Wed May 16 08:36:03 2018 +0200
+++ b/gen-trialdivtab.c	Sun May 20 13:24:44 2018 +0200
@@ -2,7 +2,7 @@
 
    Contributed to the GNU project by Torbjorn Granlund.
 
-Copyright 2009, 2012, 2013, 2016 Free Software Foundation, Inc.
+Copyright 2009, 2012, 2013, 2016, 2018 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
diff -r 41e50c4fdc46 -r 8e0a2e94ae5a gmp-impl.h
--- a/gmp-impl.h	Wed May 16 08:36:03 2018 +0200
+++ b/gmp-impl.h	Sun May 20 13:24:44 2018 +0200
@@ -3,7 +3,7 @@
    THE CONTENTS OF THIS FILE ARE FOR INTERNAL USE AND ARE ALMOST CERTAIN TO
    BE SUBJECT TO INCOMPATIBLE CHANGES IN FUTURE GNU MP RELEASES.
 
-Copyright 1991-2017 Free Software Foundation, Inc.
+Copyright 1991-2018 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
diff -r 41e50c4fdc46 -r 8e0a2e94ae5a longlong.h
--- a/longlong.h	Wed May 16 08:36:03 2018 +0200
+++ b/longlong.h	Sun May 20 13:24:44 2018 +0200
@@ -1,6 +1,6 @@
 /* longlong.h -- definitions for mixed size 32/64 bit arithmetic.
 
-Copyright 1991-1994, 1996, 1997, 1999-2005, 2007-2009, 2011-2017 Free Software
+Copyright 1991-1994, 1996, 1997, 1999-2005, 2007-2009, 2011-2018 Free Software
 Foundation, Inc.
 
 This file is part of the GNU MP Library.
diff -r 41e50c4fdc46 -r 8e0a2e94ae5a mini-gmp/ChangeLog
--- a/mini-gmp/ChangeLog	Wed May 16 08:36:03 2018 +0200
+++ b/mini-gmp/ChangeLog	Sun May 20 13:24:44 2018 +0200
@@ -1,3 +1,10 @@
+2018-05-20 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+	* mini-gmp.c (mpz_get_d): Convert a fixed number of
+	bits (GMP_DBL_MANT_BITS) to avoid rounding.
+
+	* mini-mpq.c (mpq_mul): Use mpq_nan_init.
+
 2018-04-26 Marco Bodrato <bodrato at mail.dm.unipi.it>
 
 	* mini-mpq.c: New file, mini-implementation of mpq_t.
diff -r 41e50c4fdc46 -r 8e0a2e94ae5a mini-gmp/mini-gmp.c
--- a/mini-gmp/mini-gmp.c	Wed May 16 08:36:03 2018 +0200
+++ b/mini-gmp/mini-gmp.c	Sun May 20 13:24:44 2018 +0200
@@ -50,6 +50,10 @@
 
 #include "mini-gmp.h"
 
+#if !defined(DONT_USE_FLOAT_H)
+#include <float.h>
+#endif
+
 
 /* Macros */
 #define GMP_LIMB_BITS (sizeof(mp_limb_t) * CHAR_BIT)
@@ -71,6 +75,12 @@
 
 #define GMP_CMP(a,b) (((a) > (b)) - ((a) < (b)))
 
+#if defined(DBL_MANT_DIG) && FLT_RADIX == 2
+#define GMP_DBL_MANT_BITS DBL_MANT_DIG
+#else
+#define GMP_DBL_MANT_BITS (53)
+#endif
+
 /* Return non-zero if xp,xsize and yp,ysize overlap.
    If xp+xsize<=yp there's no overlap, or if yp+ysize<=xp there's no
    overlap.  If both these are false, there's an overlap. */
@@ -1689,6 +1699,8 @@
 double
 mpz_get_d (const mpz_t u)
 {
+  int m;
+  mp_limb_t l;
   mp_size_t un;
   double x;
   double B = 2.0 * (double) GMP_LIMB_HIGHBIT;
@@ -1698,9 +1710,23 @@
   if (un == 0)
     return 0.0;
 
-  x = u->_mp_d[--un];
-  while (un > 0)
-    x = B*x + u->_mp_d[--un];
+  l = u->_mp_d[--un];
+  gmp_clz (m, l);
+  m = m + GMP_DBL_MANT_BITS - GMP_LIMB_BITS;
+  if (m < 0)
+    l &= GMP_LIMB_MAX << -m;
+
+  for (x = l; --un >= 0;)
+    {
+      x = B*x;
+      if (m > 0) {
+	l = u->_mp_d[un];
+	m -= GMP_LIMB_BITS;
+	if (m < 0)
+	  l &= GMP_LIMB_MAX << -m;
+	x += l;
+      }
+    }
 
   if (u->_mp_size < 0)
     x = -x;
diff -r 41e50c4fdc46 -r 8e0a2e94ae5a mini-gmp/mini-mpq.c
--- a/mini-gmp/mini-mpq.c	Wed May 16 08:36:03 2018 +0200
+++ b/mini-gmp/mini-mpq.c	Sun May 20 13:24:44 2018 +0200
@@ -82,6 +82,13 @@
 			      d->_mp_d, d->_mp_size);
 }
 
+static void
+mpq_nan_init (mpq_t x)
+{
+  mpz_init (mpq_numref (x));
+  mpz_init (mpq_denref (x));
+}
+
 void
 mpq_init (mpq_t x)
 {
@@ -343,7 +350,7 @@
 mpq_mul (mpq_t r, const mpq_t a, const mpq_t b)
 {
   mpq_t t;
-  mpq_init (t);
+  mpq_nan_init (t);
 
   if (a != b) {
     mpz_t g;
diff -r 41e50c4fdc46 -r 8e0a2e94ae5a mini-gmp/tests/Makefile
--- a/mini-gmp/tests/Makefile	Wed May 16 08:36:03 2018 +0200
+++ b/mini-gmp/tests/Makefile	Sun May 20 13:24:44 2018 +0200
@@ -1,6 +1,6 @@
 # Note: Requires GNU make
 
-# Copyright 2011, 2012, 2014, 2016 Free Software Foundation, Inc.
+# Copyright 2011, 2012, 2014, 2016, 2018 Free Software Foundation, Inc.
 #
 # This file is part of the GNU MP Library test suite.
 #
diff -r 41e50c4fdc46 -r 8e0a2e94ae5a mini-gmp/tests/testutils.c
--- a/mini-gmp/tests/testutils.c	Wed May 16 08:36:03 2018 +0200
+++ b/mini-gmp/tests/testutils.c	Sun May 20 13:24:44 2018 +0200
@@ -1,6 +1,6 @@
 /*
 
-Copyright 2013-2015, Free Software Foundation, Inc.
+Copyright 2013-2015, 2018 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library test suite.
 
diff -r 41e50c4fdc46 -r 8e0a2e94ae5a mpn/generic/div_q.c
--- a/mpn/generic/div_q.c	Wed May 16 08:36:03 2018 +0200
+++ b/mpn/generic/div_q.c	Sun May 20 13:24:44 2018 +0200
@@ -6,7 +6,7 @@
    SAFE TO REACH IT THROUGH DOCUMENTED INTERFACES.  IN FACT, IT IS ALMOST
    GUARANTEED THAT IT WILL CHANGE OR DISAPPEAR IN A FUTURE GMP RELEASE.
 
-Copyright 2009, 2010, 2015 Free Software Foundation, Inc.
+Copyright 2009, 2010, 2015, 2018 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
diff -r 41e50c4fdc46 -r 8e0a2e94ae5a mpn/generic/divis.c
--- a/mpn/generic/divis.c	Wed May 16 08:36:03 2018 +0200
+++ b/mpn/generic/divis.c	Sun May 20 13:24:44 2018 +0200
@@ -4,7 +4,8 @@
    CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
    FUTURE GNU MP RELEASES.
 
-Copyright 2001, 2002, 2005, 2009, 2014, 2017 Free Software Foundation, Inc.
+Copyright 2001, 2002, 2005, 2009, 2014, 2017, 2018 Free Software
+Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
diff -r 41e50c4fdc46 -r 8e0a2e94ae5a mpn/powerpc32/powerpc-defs.m4
--- a/mpn/powerpc32/powerpc-defs.m4	Wed May 16 08:36:03 2018 +0200
+++ b/mpn/powerpc32/powerpc-defs.m4	Sun May 20 13:24:44 2018 +0200
@@ -2,7 +2,7 @@
 
 dnl  m4 macros for PowerPC assembler (32 and 64 bit).
 
-dnl  Copyright 2000, 2002, 2003, 2017 Free Software Foundation, Inc.
+dnl  Copyright 2000, 2002, 2003, 2017, 2018 Free Software Foundation, Inc.
 
 dnl  This file is part of the GNU MP Library.
 dnl
diff -r 41e50c4fdc46 -r 8e0a2e94ae5a mpq/clear.c
--- a/mpq/clear.c	Wed May 16 08:36:03 2018 +0200
+++ b/mpq/clear.c	Sun May 20 13:24:44 2018 +0200
@@ -1,6 +1,7 @@
 /* mpq_clear -- free the space occupied by an mpq_t.
 
-Copyright 1991, 1994, 1995, 2000, 2001, 2015 Free Software Foundation, Inc.
+Copyright 1991, 1994, 1995, 2000, 2001, 2015, 2018 Free Software
+Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
diff -r 41e50c4fdc46 -r 8e0a2e94ae5a mpq/clears.c
--- a/mpq/clears.c	Wed May 16 08:36:03 2018 +0200
+++ b/mpq/clears.c	Sun May 20 13:24:44 2018 +0200
@@ -1,6 +1,6 @@
 /* mpq_clears() -- Clear multiple mpq_t variables.
 
-Copyright 2009, 2014, 2015 Free Software Foundation, Inc.
+Copyright 2009, 2014, 2015, 2018 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
diff -r 41e50c4fdc46 -r 8e0a2e94ae5a mpq/div.c
--- a/mpq/div.c	Wed May 16 08:36:03 2018 +0200
+++ b/mpq/div.c	Sun May 20 13:24:44 2018 +0200
@@ -1,6 +1,7 @@
 /* mpq_div -- divide two rational numbers.
 
-Copyright 1991, 1994-1996, 2000, 2001, 2015 Free Software Foundation, Inc.
+Copyright 1991, 1994-1996, 2000, 2001, 2015, 2018 Free Software
+Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
diff -r 41e50c4fdc46 -r 8e0a2e94ae5a mpq/get_d.c
--- a/mpq/get_d.c	Wed May 16 08:36:03 2018 +0200
+++ b/mpq/get_d.c	Sun May 20 13:24:44 2018 +0200
@@ -1,6 +1,6 @@
 /* double mpq_get_d (mpq_t src) -- mpq to double, rounding towards zero.
 
-Copyright 1995, 1996, 2001-2005, 2018 Free Software Foundation, Inc.
+Copyright 1995, 1996, 2001-2005, 2018, 2019 Free Software Foundation, Inc.


More information about the gmp-commit mailing list