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

mercurial at gmplib.org mercurial at gmplib.org
Thu Aug 18 13:28:55 CEST 2011


details:   /var/hg/gmp/rev/8e56bc9668fe
changeset: 14233:8e56bc9668fe
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Wed Aug 17 09:37:45 2011 +0200
description:
Update URLs, canonicalise spellng of "i.e.".

details:   /var/hg/gmp/rev/398d12664904
changeset: 14234:398d12664904
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Wed Aug 17 09:43:09 2011 +0200
description:
Fix typo in copy condition.  Delay an allocation.

details:   /var/hg/gmp/rev/113f517b9bfe
changeset: 14235:113f517b9bfe
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Thu Aug 18 13:28:29 2011 +0200
description:
(__gmp_doprnt_mpf): For DOPRNT_CONV_FIXED, ask for one more digit.

details:   /var/hg/gmp/rev/617c3cd439d2
changeset: 14236:617c3cd439d2
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Thu Aug 18 13:28:48 2011 +0200
description:
*** empty log message ***

diffstat:

 ChangeLog        |   9 +++++++++
 doc/gmp.texi     |  37 ++++++++++++++++++-------------------
 mpf/sub.c        |  12 ++++++------
 printf/doprntf.c |   6 ++++--
 4 files changed, 37 insertions(+), 27 deletions(-)

diffs (227 lines):

diff -r 4f8667001b95 -r 617c3cd439d2 ChangeLog
--- a/ChangeLog	Fri Aug 12 18:32:14 2011 +0200
+++ b/ChangeLog	Thu Aug 18 13:28:48 2011 +0200
@@ -1,3 +1,12 @@
+2011-08-18  Torbjorn Granlund  <tege at gmplib.org>
+
+	* printf/doprntf.c (__gmp_doprnt_mpf): For DOPRNT_CONV_FIXED, ask for
+	one more digit.
+
+2011-08-17  Torbjorn Granlund  <tege at gmplib.org>
+
+	* mpf/sub.c: Fix typo in copy condition.  Delay an allocation.
+
 2011-08-12  Torbjorn Granlund  <tege at gmplib.org>
 
 	* gmp-impl.h (LIMBS_PER_DIGIT_IN_BASE): Fix typo.
diff -r 4f8667001b95 -r 617c3cd439d2 doc/gmp.texi
--- a/doc/gmp.texi	Fri Aug 12 18:32:14 2011 +0200
+++ b/doc/gmp.texi	Thu Aug 18 13:28:48 2011 +0200
@@ -2651,7 +2651,7 @@
 
 Recent versions of Valgrind are getting support for MMX and SSE/SSE2
 instructions, for past versions GMP will need to be configured not to use
-those, ie.@: for an x86 without them (for instance plain @samp{i486}).
+those, i.e.@: for an x86 without them (for instance plain @samp{i486}).
 
 GMP's assembly code sometimes promotes a read of the limbs to some larger size,
 for efficiency.  GMP will do this even at the start and end of a multilimb
@@ -3142,7 +3142,7 @@
 @end deftypefun
 
 @deftypefun double mpz_get_d (mpz_t @var{op})
-Convert @var{op} to a @code{double}, truncating if necessary (ie.@: rounding
+Convert @var{op} to a @code{double}, truncating if necessary (i.e.@: rounding
 towards zero).
 
 If the exponent from the conversion is too big, the result is system
@@ -3151,7 +3151,7 @@
 @end deftypefun
 
 @deftypefun double mpz_get_d_2exp (signed long int *@var{exp}, mpz_t @var{op})
-Convert @var{op} to a @code{double}, truncating if necessary (ie.@: rounding
+Convert @var{op} to a @code{double}, truncating if necessary (i.e.@: rounding
 towards zero), and returning the exponent separately.
 
 The return value is in the range @math{0.5 at le{}@GMPabs{@var{d}}<1} and the
@@ -4247,7 +4247,7 @@
 @cindex Conversion functions
 
 @deftypefun double mpq_get_d (mpq_t @var{op})
-Convert @var{op} to a @code{double}, truncating if necessary (ie.@: rounding
+Convert @var{op} to a @code{double}, truncating if necessary (i.e.@: rounding
 towards zero).
 
 If the exponent from the conversion is too big or too small to fit a
@@ -4735,7 +4735,7 @@
 @cindex Conversion functions
 
 @deftypefun double mpf_get_d (mpf_t @var{op})
-Convert @var{op} to a @code{double}, truncating if necessary (ie.@: rounding
+Convert @var{op} to a @code{double}, truncating if necessary (i.e.@: rounding
 towards zero).
 
 If the exponent in @var{op} is too big or too small to fit a @code{double}
@@ -4745,7 +4745,7 @@
 @end deftypefun
 
 @deftypefun double mpf_get_d_2exp (signed long int *@var{exp}, mpf_t @var{op})
-Convert @var{op} to a @code{double}, truncating if necessary (ie.@: rounding
+Convert @var{op} to a @code{double}, truncating if necessary (i.e.@: rounding
 towards zero), and with an exponent returned separately.
 
 The return value is in the range @math{0.5 at le{}@GMPabs{@var{d}}<1} and the
@@ -5683,7 +5683,7 @@
 Initialize @var{state} for a linear congruential algorithm as per
 @code{gmp_randinit_lc_2exp}.  @var{a}, @var{c} and @var{m2exp} are selected
 from a table, chosen so that @var{size} bits (or more) of each @math{X} will
-be used, ie.@: @math{@var{m2exp}/2 @ge{} @var{size}}.
+be used, i.e.@: @math{@var{m2exp}/2 @ge{} @var{size}}.
 
 If successful the return value is non-zero.  If @var{size} is bigger than the
 table data provides then the return value is zero.  The maximum @var{size}
@@ -5756,7 +5756,7 @@
 @section Random State Miscellaneous
 
 @deftypefun {unsigned long} gmp_urandomb_ui (gmp_randstate_t @var{state}, unsigned long @var{n})
-Return a uniformly distributed random number of @var{n} bits, ie.@: in the
+Return a uniformly distributed random number of @var{n} bits, i.e.@: in the
 range 0 to @m{2^n-1,2^@var{n}-1} inclusive.  @var{n} must be less than or
 equal to the number of bits in an @code{unsigned long}.
 @end deftypefun
@@ -7077,7 +7077,7 @@
 ALP @spaceuref{http://www-sop.inria.fr/saga/logiciels/ALP/} @* Linear algebra and
 polynomials using templates.
 @item
-Arithmos @spaceuref{http://www.win.ua.ac.be/~cant/arithmos/} @* Rationals
+Arithmos @spaceuref{http://cant.ua.ac.be/old/arithmos/} @* Rationals
 with infinities and square roots.
 @item
 CLN @spaceuref{http://www.ginac.de/CLN/} @* High level classes for arithmetic.
@@ -7257,8 +7257,7 @@
 @item
 Regina @spaceuref{http://regina.sourceforge.net/} @* Topological calculator.
 @item
-Yacas @spaceuref{http://www.xs4all.nl/~apinkus/yacas.html} @* Yet another
-computer algebra system.
+Yacas @spaceuref{yacas.sourceforge.net} @* Yet another computer algebra system.
 @end itemize
 
 @end table
@@ -7460,7 +7459,7 @@
 @end example
 @end ifnottex
 
-Let @math{b} be the power of 2 where the split occurs, ie.@: if @ms{x,0} is
+Let @math{b} be the power of 2 where the split occurs, i.e.@: if @ms{x,0} is
 @math{k} limbs (@ms{y,0} the same) then
 @m{b=2\GMPraise{$k*$@code{mp\_bits\_per\_limb}}, b=2^(k*mp_bits_per_limb)}.
 With that @m{x=x_1b+x_0,x=x1*b+x0} and @m{y=y_1b+y_0,y=y1*b+y0}, and the
@@ -7639,7 +7638,7 @@
 @end display
 
 Let @math{b} equal the power of 2 which is the size of the @ms{x,0}, @ms{x,1},
- at ms{y,0} and @ms{y,1} pieces, ie.@: if they're @math{k} limbs each then
+ at ms{y,0} and @ms{y,1} pieces, i.e.@: if they're @math{k} limbs each then
 @m{b=2\GMPraise{$k*$@code{mp\_bits\_per\_limb}}, b=2^(k*mp_bits_per_limb)}.
 With this @math{x=X(b)} and @math{y=Y(b)}.
 
@@ -8742,7 +8741,7 @@
 
 A square root must still be taken for any value that passes these tests, to
 verify it's really a square and not one of the small fraction of non-squares
-that get through (ie.@: a pseudo-square to all the tested bases).
+that get through (i.e.@: a pseudo-square to all the tested bases).
 
 Clearly more residue tests could be done, @code{mpz_perfect_square_p} only
 uses a compact and efficient set.  Big inputs would probably benefit from more
@@ -8844,7 +8843,7 @@
 
 Another possible improvement for the sub-quadratic part would be to arrange
 for radix powers that balanced the sizes of quotient and remainder produced,
-ie.@: the highest power would be an @m{b^{nk},b^(n*k)} approximately equal to
+i.e.@: the highest power would be an @m{b^{nk},b^(n*k)} approximately equal to
 @m{\sqrt{t},sqrt(t)}, not restricted to a @math{2^i} factor.  That ought to
 smooth out a graph of times against sizes, but may or may not be a net
 speedup.
@@ -10313,7 +10312,7 @@
 @item
 Richard Crandall and Carl Pomerance, ``Prime Numbers: A Computational
 Perspective'', 2nd edition, Springer-Verlag, 2005.
- at texlinebreak{} @uref{http://math.dartmouth.edu/~carlp/}
+ at texlinebreak{} @uref{http://www.math.dartmouth.edu/~carlp/}
 
 @item
 Henri Cohen, ``A Course in Computational Algebraic Number Theory'', Graduate
@@ -10346,8 +10345,8 @@
 @item
 Yves Bertot, Nicolas Magaud and Paul Zimmermann, ``A Proof of GMP Square
 Root'', Journal of Automated Reasoning, volume 29, 2002, pp.@: 225-252.  Also
-available online as INRIA Research Report 4475, June 2001,
- at uref{http://www.inria.fr/rrrt/rr-4475.html}
+available online as INRIA Research Report 4475, June 2002,
+ at uref{http://hal.inria.fr/docs/00/07/21/13/PDF/RR-4475.pdf}
 
 @item
 Christoph Burnikel and Joachim Ziegler, ``Fast Recursive Division'',
@@ -10437,7 +10436,7 @@
 
 @item
 Paul Zimmermann, ``Karatsuba Square Root'', INRIA Research Report 3805,
-November 1999, @uref{http://www.inria.fr/rrrt/rr-3805.html}
+November 1999, @uref{http://hal.inria.fr/inria-00072854/PDF/RR-3805.pdf}
 
 @item
 Paul Zimmermann, ``A Proof of GMP Fast Division and Square Root
diff -r 4f8667001b95 -r 617c3cd439d2 mpf/sub.c
--- a/mpf/sub.c	Fri Aug 12 18:32:14 2011 +0200
+++ b/mpf/sub.c	Thu Aug 18 13:28:48 2011 +0200
@@ -1,6 +1,6 @@
 /* mpf_sub -- Subtract two floats.
 
-Copyright 1993, 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
+Copyright 1993, 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 2011 Free
 Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
@@ -273,19 +273,19 @@
       vsize = prec - ediff;
     }
 
-  /* Allocate temp space for the result.  Allocate
-     just vsize + ediff later???  */
-  tp = TMP_ALLOC_LIMBS (prec);
-
   if (ediff >= prec)
     {
       /* V completely cancelled.  */
-      if (tp != up)
+      if (rp != up)
 	MPN_COPY (rp, up, usize);
       rsize = usize;
     }
   else
     {
+      /* Allocate temp space for the result.  Allocate
+	 just vsize + ediff later???  */
+      tp = TMP_ALLOC_LIMBS (prec);
+
       /* Locate the least significant non-zero limb in (the needed
 	 parts of) U and V, to simplify the code below.  */
       for (;;)
diff -r 4f8667001b95 -r 617c3cd439d2 printf/doprntf.c
--- a/printf/doprntf.c	Fri Aug 12 18:32:14 2011 +0200
+++ b/printf/doprntf.c	Thu Aug 18 13:28:48 2011 +0200
@@ -90,8 +90,10 @@
 	   overestimate the integer part, and add prec.  If f<1 then
 	   underestimate the zeros between the radix point and the first
 	   digit and subtract that from prec.  In either case add 2 so the
-	   round to nearest can be applied accurately.  */
-	ndigits = prec + 2
+	   round to nearest can be applied accurately.  Finally, we add 1 to
+	   handle the case of 1-eps where EXP(f) = 0 but mpf_get_str returns
+	   exp as 1.  */
+	ndigits = prec + 2 + 1
 	  + EXP(f) * (mp_bases[ABS(p->base)].chars_per_limb + (EXP(f)>=0));
 	ndigits = MAX (ndigits, 1);
 	break;


More information about the gmp-commit mailing list