source:
patches/mpfr-3.1.3-fixes-1.patch@
e979069
Last change on this file since e979069 was e184030, checked in by , 9 years ago | |
---|---|
|
|
File size: 80.6 KB |
-
mpfr-3.1.
Submitted By: William Harrington (kb0iic at cross-lfs dot org) Date: 2015-08-18 Initial Package Version: 3.1.3 Origin: Upstream Upstream Status: Applied Description: Contains all upstream patches of mpfr current to patch level 4. diff -Naurd mpfr-3.1.3-a/PATCHES mpfr-3.1.3-b/PATCHES
old new 1 lngamma-and-doc -
mpfr-3.1.
diff -Naurd mpfr-3.1.3-a/VERSION mpfr-3.1.3-b/VERSION
old new 1 3.1.3 1 3.1.3-p1 -
doc/mpfr.texi
diff -Naurd mpfr-3.1.3-a/doc/mpfr.texi mpfr-3.1.3-b/doc/mpfr.texi
old new 810 810 When the input point is in the closure of the domain of the mathematical 811 811 function and an input argument is +0 (resp.@: @minus{}0), one considers 812 812 the limit when the corresponding argument approaches 0 from above 813 (resp.@: below). If the limit is not defined (e.g., @code{mpfr_log} on 814 @minus{}0), the behavior is specified in the description of the MPFR function. 813 (resp.@: below), if possible. If the limit is not defined (e.g., 814 @code{mpfr_sqrt} and @code{mpfr_log} on @minus{}0), the behavior is 815 specified in the description of the MPFR function, but must be consistent 816 with the rule from the above paragraph (e.g., @code{mpfr_log} on @pom{}0 817 gives @minus{}Inf). 815 818 816 819 When the result is equal to 0, its sign is determined by considering the 817 820 limit as if the input point were not in the domain: If one approaches 0 818 821 from above (resp.@: below), the result is +0 (resp.@: @minus{}0); 819 for example, @code{mpfr_sin} on +0 gives +0. 822 for example, @code{mpfr_sin} on @minus{}0 gives @minus{}0 and 823 @code{mpfr_acos} on 1 gives +0 (in all rounding modes). 820 824 In the other cases, the sign is specified in the description of the MPFR 821 825 function; for example @code{mpfr_max} on @minus{}0 and +0 gives +0. 822 826 … … 832 836 @c that advantages in practice), like for any bug fix. 833 837 Example: @code{mpfr_hypot} on (NaN,0) gives NaN, but @code{mpfr_hypot} 834 838 on (NaN,+Inf) gives +Inf (as specified in @ref{Special Functions}), 835 since for any finite input @var{x}, @code{mpfr_hypot} on (@var{x},+Inf)836 gives +Inf.839 since for any finite or infinite input @var{x}, @code{mpfr_hypot} on 840 (@var{x},+Inf) gives +Inf. 837 841 838 842 @node Exceptions, Memory Handling, Floating-Point Values on Special Numbers, MPFR Basics 839 843 @comment node-name, next, previous, up … … 1581 1585 @deftypefunx int mpfr_add_z (mpfr_t @var{rop}, mpfr_t @var{op1}, mpz_t @var{op2}, mpfr_rnd_t @var{rnd}) 1582 1586 @deftypefunx int mpfr_add_q (mpfr_t @var{rop}, mpfr_t @var{op1}, mpq_t @var{op2}, mpfr_rnd_t @var{rnd}) 1583 1587 Set @var{rop} to @math{@var{op1} + @var{op2}} rounded in the direction 1584 @var{rnd}. For types having no signed zero, it is considered unsigned 1588 @var{rnd}. The IEEE-754 rules are used, in particular for signed zeros. 1589 But for types having no signed zeros, 0 is considered unsigned 1585 1590 (i.e., (+0) + 0 = (+0) and (@minus{}0) + 0 = (@minus{}0)). 1586 1591 The @code{mpfr_add_d} function assumes that the radix of the @code{double} type 1587 1592 is a power of 2, with a precision at most that declared by the C implementation … … 1599 1604 @deftypefunx int mpfr_sub_z (mpfr_t @var{rop}, mpfr_t @var{op1}, mpz_t @var{op2}, mpfr_rnd_t @var{rnd}) 1600 1605 @deftypefunx int mpfr_sub_q (mpfr_t @var{rop}, mpfr_t @var{op1}, mpq_t @var{op2}, mpfr_rnd_t @var{rnd}) 1601 1606 Set @var{rop} to @math{@var{op1} - @var{op2}} rounded in the direction 1602 @var{rnd}. For types having no signed zero, it is considered unsigned 1607 @var{rnd}. The IEEE-754 rules are used, in particular for signed zeros. 1608 But for types having no signed zeros, 0 is considered unsigned 1603 1609 (i.e., (+0) @minus{} 0 = (+0), (@minus{}0) @minus{} 0 = (@minus{}0), 1604 1610 0 @minus{} (+0) = (@minus{}0) and 0 @minus{} (@minus{}0) = (+0)). 1605 1611 The same restrictions than for @code{mpfr_add_d} apply to @code{mpfr_d_sub} … … 1615 1621 Set @var{rop} to @math{@var{op1} @GMPtimes{} @var{op2}} rounded in the 1616 1622 direction @var{rnd}. 1617 1623 When a result is zero, its sign is the product of the signs of the operands 1618 (for types having no signed zero , itis considered positive).1624 (for types having no signed zeros, 0 is considered positive). 1619 1625 The same restrictions than for @code{mpfr_add_d} apply to @code{mpfr_mul_d}. 1620 1626 @end deftypefun 1621 1627 … … 1635 1641 @deftypefunx int mpfr_div_q (mpfr_t @var{rop}, mpfr_t @var{op1}, mpq_t @var{op2}, mpfr_rnd_t @var{rnd}) 1636 1642 Set @var{rop} to @math{@var{op1}/@var{op2}} rounded in the direction @var{rnd}. 1637 1643 When a result is zero, its sign is the product of the signs of the operands 1638 (for types having no signed zero , itis considered positive).1644 (for types having no signed zeros, 0 is considered positive). 1639 1645 The same restrictions than for @code{mpfr_add_d} apply to @code{mpfr_d_div} 1640 1646 and @code{mpfr_div_d}. 1641 1647 @end deftypefun … … 1643 1649 @deftypefun int mpfr_sqrt (mpfr_t @var{rop}, mpfr_t @var{op}, mpfr_rnd_t @var{rnd}) 1644 1650 @deftypefunx int mpfr_sqrt_ui (mpfr_t @var{rop}, unsigned long int @var{op}, mpfr_rnd_t @var{rnd}) 1645 1651 Set @var{rop} to @m{\sqrt{@var{op}}, the square root of @var{op}} 1646 rounded in the direction @var{rnd} (set @var{rop} to @minus{}0 if @var{op} is1647 @ minus{}0, to be consistent with the IEEE 754 standard).1652 rounded in the direction @var{rnd}. Set @var{rop} to @minus{}0 if 1653 @var{op} is @minus{}0, to be consistent with the IEEE 754 standard. 1648 1654 Set @var{rop} to NaN if @var{op} is negative. 1649 1655 @end deftypefun 1650 1656 1651 1657 @deftypefun int mpfr_rec_sqrt (mpfr_t @var{rop}, mpfr_t @var{op}, mpfr_rnd_t @var{rnd}) 1652 1658 Set @var{rop} to @m{1/\sqrt{@var{op}}, the reciprocal square root of @var{op}} 1653 rounded in the direction @var{rnd}. Set @var{rop} to +Inf if @var{op} is 1654 @pom{}0, +0 if @var{op} is +Inf, and NaN if @var{op} is negative. 1659 rounded in the direction @var{rnd}. Set @var{rop} to +Inf if @var{op} is 1660 @pom{}0, +0 if @var{op} is +Inf, and NaN if @var{op} is negative. Warning! 1661 Therefore the result on @minus{}0 is different from the one of the rSqrt 1662 function recommended by the IEEE 754-2008 standard (Section 9.2.1), which 1663 is @minus{}Inf instead of +Inf. 1655 1664 @end deftypefun 1656 1665 1657 1666 @deftypefun int mpfr_cbrt (mpfr_t @var{rop}, mpfr_t @var{op}, mpfr_rnd_t @var{rnd}) … … 1832 1841 @m{\log_2 @var{op}, log2(@var{op})} or 1833 1842 @m{\log_{10} @var{op}, log10(@var{op})}, respectively, 1834 1843 rounded in the direction @var{rnd}. 1835 Set @var{rop} to @minus{}Inf if @var{op} is @minus{}0 1844 Set @var{rop} to +0 if @var{op} is 1 (in all rounding modes), 1845 for consistency with the ISO C99 and IEEE 754-2008 standards. 1846 Set @var{rop} to @minus{}Inf if @var{op} is @pom{}0 1836 1847 (i.e., the sign of the zero has no influence on the result). 1837 1848 @end deftypefun 1838 1849 … … 2003 2014 @deftypefun int mpfr_lngamma (mpfr_t @var{rop}, mpfr_t @var{op}, mpfr_rnd_t @var{rnd}) 2004 2015 Set @var{rop} to the value of the logarithm of the Gamma function on @var{op}, 2005 2016 rounded in the direction @var{rnd}. 2006 When @math{@minus{}2@var{k}@minus{}1 @le{} @var{op} @le{} @minus{}2@var{k}}, 2007 @var{k} being a non-negative integer, @var{rop} is set to NaN. 2017 When @var{op} is 1 or 2, set @var{rop} to +0 (in all rounding modes). 2018 When @var{op} is an infinity or a nonpositive integer, set @var{rop} to +Inf, 2019 following the general rules on special values. 2020 When @math{@minus{}2@var{k}@minus{}1 < @var{op} < @minus{}2@var{k}}, 2021 @var{k} being a nonnegative integer, set @var{rop} to NaN@. 2008 2022 See also @code{mpfr_lgamma}. 2009 2023 @end deftypefun 2010 2024 … … 2012 2026 Set @var{rop} to the value of the logarithm of the absolute value of the 2013 2027 Gamma function on @var{op}, rounded in the direction @var{rnd}. The sign 2014 2028 (1 or @minus{}1) of Gamma(@var{op}) is returned in the object pointed to 2015 by @var{signp}. When @var{op} is an infinity or a non-positive integer, set 2016 @var{rop} to +Inf. When @var{op} is NaN, @minus{}Inf or a negative integer, 2017 *@var{signp} is undefined, and when @var{op} is @pom{}0, *@var{signp} is 2018 the sign of the zero. 2029 by @var{signp}. 2030 When @var{op} is 1 or 2, set @var{rop} to +0 (in all rounding modes). 2031 When @var{op} is an infinity or a nonpositive integer, set @var{rop} to +Inf. 2032 When @var{op} is NaN, @minus{}Inf or a negative integer, *@var{signp} is 2033 undefined, and when @var{op} is @pom{}0, *@var{signp} is the sign of the zero. 2019 2034 @end deftypefun 2020 2035 2021 2036 @deftypefun int mpfr_digamma (mpfr_t @var{rop}, mpfr_t @var{op}, mpfr_rnd_t @var{rnd}) … … 2064 2079 @deftypefunx int mpfr_fms (mpfr_t @var{rop}, mpfr_t @var{op1}, mpfr_t @var{op2}, mpfr_t @var{op3}, mpfr_rnd_t @var{rnd}) 2065 2080 Set @var{rop} to @math{(@var{op1} @GMPtimes{} @var{op2}) + @var{op3}} 2066 2081 (resp.@: @math{(@var{op1} @GMPtimes{} @var{op2}) - @var{op3}}) 2067 rounded in the direction @var{rnd}. 2082 rounded in the direction @var{rnd}. Concerning special values (signed zeros, 2083 infinities, NaN), these functions behave like a multiplication followed by a 2084 separate addition or subtraction. That is, the fused operation matters only 2085 for rounding. 2068 2086 @end deftypefun 2069 2087 2070 2088 @deftypefun int mpfr_agm (mpfr_t @var{rop}, mpfr_t @var{op1}, mpfr_t @var{op2}, mpfr_rnd_t @var{rnd}) … … 2089 2107 i.e., $\sqrt{x^2+y^2}$, 2090 2108 @end tex 2091 2109 rounded in the direction @var{rnd}. 2092 Special values are handled as described in Section F.9.4.3 of2093 the ISO C99 and IEEE 754-2008standards:2110 Special values are handled as described in the ISO C99 (Section F.9.4.3) 2111 and IEEE 754-2008 (Section 9.2.1) standards: 2094 2112 If @var{x} or @var{y} is an infinity, then +Inf is returned in @var{rop}, 2095 2113 even if the other number is NaN. 2096 2114 @end deftypefun -
doc/mpfr.info
diff -Naurd mpfr-3.1.3-a/doc/mpfr.info mpfr-3.1.3-b/doc/mpfr.info
old new 1 This is mpfr.info, produced by makeinfo version 5.2from mpfr.texi.1 This is mpfr.info, produced by makeinfo version 6.0 from mpfr.texi. 2 2 3 3 This manual documents how to install and use the Multiple Precision 4 4 Floating-Point Reliable Library, version 3.1.3. … … 55 55 MPFR Copying Conditions 56 56 *********************** 57 57 58 The GNU MPFR library (or MPFR for short) is "free"; this means that58 The GNU MPFR library (or MPFR for short) is âfreeâ; this means that 59 59 everyone is free to use it and free to redistribute it on a free basis. 60 60 The library is not in the public domain; it is copyrighted and there are 61 61 restrictions on its distribution, but these restrictions are designed to … … 418 418 4.2 Nomenclature and Types 419 419 ========================== 420 420 421 A "floating-point number", or "float"for short, is an arbitrary421 A âfloating-point numberâ, or âfloatâ for short, is an arbitrary 422 422 precision significand (also called mantissa) with a limited precision 423 423 exponent. The C data type for such objects is âmpfr_tâ (internally 424 424 defined as a one-element array of a structure, and âmpfr_ptrâ is the C … … 432 432 to the other functions supported by MPFR. Unless documented otherwise, 433 433 the sign bit of a NaN is unspecified. 434 434 435 The "precision"is the number of bits used to represent the significand435 The âprecisionâ is the number of bits used to represent the significand 436 436 of a floating-point number; the corresponding C data type is 437 437 âmpfr_prec_tâ. The precision can be any integer between âMPFR_PREC_MINâ 438 438 and âMPFR_PREC_MAXâ. In the current implementation, âMPFR_PREC_MINâ is … … 446 446 may abort, crash or have undefined behavior (depending on your C 447 447 implementation). 448 448 449 The "rounding mode"specifies the way to round the result of a449 The ârounding modeâ specifies the way to round the result of a 450 450 floating-point operation, in case the exact result can not be 451 451 represented exactly in the destination significand; the corresponding C 452 452 data type is âmpfr_rnd_tâ. … … 499 499 representable numbers, it is rounded to the one with the least 500 500 significant bit set to zero. For example, the number 2.5, which is 501 501 represented by (10.1) in binary, is rounded to (10.0)=2 with a precision 502 of two bits, and not to (11.0)=3. This rule avoids the "drift"502 of two bits, and not to (11.0)=3. This rule avoids the âdriftâ 503 503 phenomenon mentioned by Knuth in volume 2 of The Art of Computer 504 504 Programming (Section 4.2.2). 505 505 506 506 Most MPFR functions take as first argument the destination variable, 507 507 as second and following arguments the input variables, as last argument 508 508 a rounding mode, and have a return value of type âintâ, called the 509 "ternary value". The value stored in the destination variable is509 âternary valueâ. The value stored in the destination variable is 510 510 correctly rounded, i.e., MPFR behaves as if it computed the result with 511 511 an infinite precision, then rounded it to the precision of this 512 512 variable. The input variables are regarded as exact (in particular, … … 572 572 When the input point is in the closure of the domain of the 573 573 mathematical function and an input argument is +0 (resp. â0), one 574 574 considers the limit when the corresponding argument approaches 0 from 575 above (resp. below). If the limit is not defined (e.g., âmpfr_logâ on 576 â0), the behavior is specified in the description of the MPFR function. 575 above (resp. below), if possible. If the limit is not defined (e.g., 576 âmpfr_sqrtâ and âmpfr_logâ on â0), the behavior is specified in the 577 description of the MPFR function, but must be consistent with the rule 578 from the above paragraph (e.g., âmpfr_logâ on ±0 gives âInf). 577 579 578 580 When the result is equal to 0, its sign is determined by considering 579 581 the limit as if the input point were not in the domain: If one 580 582 approaches 0 from above (resp. below), the result is +0 (resp. â0); for 581 example, âmpfr_sinâ on +0 gives +0. In the other cases, the sign is 582 specified in the description of the MPFR function; for example 583 âmpfr_maxâ on â0 and +0 gives +0. 583 example, âmpfr_sinâ on â0 gives â0 and âmpfr_acosâ on 1 gives +0 (in all 584 rounding modes). In the other cases, the sign is specified in the 585 description of the MPFR function; for example âmpfr_maxâ on â0 and +0 586 gives +0. 584 587 585 588 When the input point is not in the closure of the domain of the 586 589 function, the result is NaN. Example: âmpfr_sqrtâ on â17 gives NaN. … … 590 593 numbers; such a case is always explicitly specified in *note MPFR 591 594 Interface::. Example: âmpfr_hypotâ on (NaN,0) gives NaN, but 592 595 âmpfr_hypotâ on (NaN,+Inf) gives +Inf (as specified in *note Special 593 Functions::), since for any finite input X, âmpfr_hypotâ on (X,+Inf)594 gives +Inf.596 Functions::), since for any finite or infinite input X, âmpfr_hypotâ on 597 (X,+Inf) gives +Inf. 595 598 596 599 597 600 File: mpfr.info, Node: Exceptions, Next: Memory Handling, Prev: Floating-Point Values on Special Numbers, Up: MPFR Basics … … 1253 1256 mpfr_rnd_t RND) 1254 1257 -- Function: int mpfr_add_q (mpfr_t ROP, mpfr_t OP1, mpq_t OP2, 1255 1258 mpfr_rnd_t RND) 1256 Set ROP to OP1 + OP2 rounded in the direction RND. For types 1257 having no signed zero, it is considered unsigned (i.e., (+0) + 0 = 1259 Set ROP to OP1 + OP2 rounded in the direction RND. The IEEE-754 1260 rules are used, in particular for signed zeros. But for types 1261 having no signed zeros, 0 is considered unsigned (i.e., (+0) + 0 = 1258 1262 (+0) and (â0) + 0 = (â0)). The âmpfr_add_dâ function assumes that 1259 1263 the radix of the âdoubleâ type is a power of 2, with a precision at 1260 1264 most that declared by the C implementation (macro … … 1280 1284 mpfr_rnd_t RND) 1281 1285 -- Function: int mpfr_sub_q (mpfr_t ROP, mpfr_t OP1, mpq_t OP2, 1282 1286 mpfr_rnd_t RND) 1283 Set ROP to OP1 - OP2 rounded in the direction RND. For types 1284 having no signed zero, it is considered unsigned (i.e., (+0) â 0 = 1287 Set ROP to OP1 - OP2 rounded in the direction RND. The IEEE-754 1288 rules are used, in particular for signed zeros. But for types 1289 having no signed zeros, 0 is considered unsigned (i.e., (+0) â 0 = 1285 1290 (+0), (â0) â 0 = (â0), 0 â (+0) = (â0) and 0 â (â0) = (+0)). The 1286 1291 same restrictions than for âmpfr_add_dâ apply to âmpfr_d_subâ and 1287 1292 âmpfr_sub_dâ. … … 1300 1305 mpfr_rnd_t RND) 1301 1306 Set ROP to OP1 times OP2 rounded in the direction RND. When a 1302 1307 result is zero, its sign is the product of the signs of the 1303 operands (for types having no signed zero , itis considered1308 operands (for types having no signed zeros, 0 is considered 1304 1309 positive). The same restrictions than for âmpfr_add_dâ apply to 1305 1310 âmpfr_mul_dâ. 1306 1311 … … 1327 1332 mpfr_rnd_t RND) 1328 1333 Set ROP to OP1/OP2 rounded in the direction RND. When a result is 1329 1334 zero, its sign is the product of the signs of the operands (for 1330 types having no signed zero , itis considered positive). The same1335 types having no signed zeros, 0 is considered positive). The same 1331 1336 restrictions than for âmpfr_add_dâ apply to âmpfr_d_divâ and 1332 1337 âmpfr_div_dâ. 1333 1338 1334 1339 -- Function: int mpfr_sqrt (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 1335 1340 -- Function: int mpfr_sqrt_ui (mpfr_t ROP, unsigned long int OP, 1336 1341 mpfr_rnd_t RND) 1337 Set ROP to the square root of OP rounded in the direction RND (set1338 ROP to â0 if OP is â0, to be consistent with the IEEE 754 1339 standard).Set ROP to NaN if OP is negative.1342 Set ROP to the square root of OP rounded in the direction RND. Set 1343 ROP to â0 if OP is â0, to be consistent with the IEEE 754 standard. 1344 Set ROP to NaN if OP is negative. 1340 1345 1341 1346 -- Function: int mpfr_rec_sqrt (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 1342 1347 Set ROP to the reciprocal square root of OP rounded in the 1343 1348 direction RND. Set ROP to +Inf if OP is ±0, +0 if OP is +Inf, and 1344 NaN if OP is negative. 1349 NaN if OP is negative. Warning! Therefore the result on â0 is 1350 different from the one of the rSqrt function recommended by the 1351 IEEE 754-2008 standard (Section 9.2.1), which is âInf instead of 1352 +Inf. 1345 1353 1346 1354 -- Function: int mpfr_cbrt (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 1347 1355 -- Function: int mpfr_root (mpfr_t ROP, mpfr_t OP, unsigned long int K, … … 1515 1523 -- Function: int mpfr_log2 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 1516 1524 -- Function: int mpfr_log10 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 1517 1525 Set ROP to the natural logarithm of OP, log2(OP) or log10(OP), 1518 respectively, rounded in the direction RND. Set ROP to âInf if OP 1519 is â0 (i.e., the sign of the zero has no influence on the result). 1526 respectively, rounded in the direction RND. Set ROP to +0 if OP is 1527 1 (in all rounding modes), for consistency with the ISO C99 and 1528 IEEE 754-2008 standards. Set ROP to âInf if OP is ±0 (i.e., the 1529 sign of the zero has no influence on the result). 1520 1530 1521 1531 -- Function: int mpfr_exp (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 1522 1532 -- Function: int mpfr_exp2 (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) … … 1649 1659 1650 1660 -- Function: int mpfr_lngamma (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 1651 1661 Set ROP to the value of the logarithm of the Gamma function on OP, 1652 rounded in the direction RND. When â2Kâ1 <= OP <= â2K, K being a 1653 non-negative integer, ROP is set to NaN. See also âmpfr_lgammaâ. 1662 rounded in the direction RND. When OP is 1 or 2, set ROP to +0 (in 1663 all rounding modes). When OP is an infinity or a nonpositive 1664 integer, set ROP to +Inf, following the general rules on special 1665 values. When â2Kâ1 < OP < â2K, K being a nonnegative integer, set 1666 ROP to NaN. See also âmpfr_lgammaâ. 1654 1667 1655 1668 -- Function: int mpfr_lgamma (mpfr_t ROP, int *SIGNP, mpfr_t OP, 1656 1669 mpfr_rnd_t RND) 1657 1670 Set ROP to the value of the logarithm of the absolute value of the 1658 1671 Gamma function on OP, rounded in the direction RND. The sign (1 or 1659 1672 â1) of Gamma(OP) is returned in the object pointed to by SIGNP. 1660 When OP is an infinity or a non-positive integer, set ROP to +Inf. 1661 When OP is NaN, âInf or a negative integer, *SIGNP is undefined, 1662 and when OP is ±0, *SIGNP is the sign of the zero. 1673 When OP is 1 or 2, set ROP to +0 (in all rounding modes). When OP 1674 is an infinity or a nonpositive integer, set ROP to +Inf. When OP 1675 is NaN, âInf or a negative integer, *SIGNP is undefined, and when 1676 OP is ±0, *SIGNP is the sign of the zero. 1663 1677 1664 1678 -- Function: int mpfr_digamma (mpfr_t ROP, mpfr_t OP, mpfr_rnd_t RND) 1665 1679 Set ROP to the value of the Digamma (sometimes also called Psi) … … 1703 1717 -- Function: int mpfr_fms (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2, mpfr_t 1704 1718 OP3, mpfr_rnd_t RND) 1705 1719 Set ROP to (OP1 times OP2) + OP3 (resp. (OP1 times OP2) - OP3) 1706 rounded in the direction RND. 1720 rounded in the direction RND. Concerning special values (signed 1721 zeros, infinities, NaN), these functions behave like a 1722 multiplication followed by a separate addition or subtraction. 1723 That is, the fused operation matters only for rounding. 1707 1724 1708 1725 -- Function: int mpfr_agm (mpfr_t ROP, mpfr_t OP1, mpfr_t OP2, 1709 1726 mpfr_rnd_t RND) … … 1717 1734 RND) 1718 1735 Set ROP to the Euclidean norm of X and Y, i.e., the square root of 1719 1736 the sum of the squares of X and Y, rounded in the direction RND. 1720 Special values are handled as described in Section F.9.4.3 of the 1721 ISO C99 and IEEE 754-2008 standards: If X or Y is an infinity, then 1722 +Inf is returned in ROP, even if the other number is NaN. 1737 Special values are handled as described in the ISO C99 (Section 1738 F.9.4.3) and IEEE 754-2008 (Section 9.2.1) standards: If X or Y is 1739 an infinity, then +Inf is returned in ROP, even if the other number 1740 is NaN. 1723 1741 1724 1742 -- Function: int mpfr_ai (mpfr_t ROP, mpfr_t X, mpfr_rnd_t RND) 1725 1743 Set ROP to the value of the Airy function Ai on X, rounded in the … … 2670 2688 5.16 Internals 2671 2689 ============== 2672 2690 2673 A "limb"means the part of a multi-precision number that fits in a2691 A âlimbâ means the part of a multi-precision number that fits in a 2674 2692 single word. Usually a limb contains 32 or 64 bits. The C data type 2675 2693 for a limb is âmp_limb_tâ. 2676 2694 … … 3140 3158 0. PREAMBLE 3141 3159 3142 3160 The purpose of this License is to make a manual, textbook, or other 3143 functional and useful document "free"in the sense of freedom: to3161 functional and useful document âfreeâ in the sense of freedom: to 3144 3162 assure everyone the effective freedom to copy and redistribute it, 3145 3163 with or without modifying it, either commercially or 3146 3164 noncommercially. Secondarily, this License preserves for the … … 3655 3673 * Menu: 3656 3674 3657 3675 * mpfr_abs: Basic Arithmetic Functions. 3658 (line 16 0)3659 * mpfr_acos: Special Functions. (line 5 1)3660 * mpfr_acosh: Special Functions. (line 11 5)3676 (line 165) 3677 * mpfr_acos: Special Functions. (line 53) 3678 * mpfr_acosh: Special Functions. (line 117) 3661 3679 * mpfr_add: Basic Arithmetic Functions. 3662 3680 (line 6) 3663 3681 * mpfr_add_d: Basic Arithmetic Functions. … … 3670 3688 (line 8) 3671 3689 * mpfr_add_z: Basic Arithmetic Functions. 3672 3690 (line 14) 3673 * mpfr_agm: Special Functions. (line 21 0)3674 * mpfr_ai: Special Functions. (line 2 26)3675 * mpfr_asin: Special Functions. (line 5 2)3676 * mpfr_asinh: Special Functions. (line 11 6)3691 * mpfr_agm: Special Functions. (line 219) 3692 * mpfr_ai: Special Functions. (line 236) 3693 * mpfr_asin: Special Functions. (line 54) 3694 * mpfr_asinh: Special Functions. (line 118) 3677 3695 * mpfr_asprintf: Formatted Output Functions. 3678 3696 (line 193) 3679 * mpfr_atan: Special Functions. (line 5 3)3680 * mpfr_atan2: Special Functions. (line 6 3)3681 * mpfr_atanh: Special Functions. (line 11 7)3697 * mpfr_atan: Special Functions. (line 55) 3698 * mpfr_atan2: Special Functions. (line 65) 3699 * mpfr_atanh: Special Functions. (line 119) 3682 3700 * mpfr_buildopt_decimal_p: Miscellaneous Functions. 3683 3701 (line 162) 3684 3702 * mpfr_buildopt_gmpinternals_p: Miscellaneous Functions. … … 3690 3708 * mpfr_can_round: Rounding Related Functions. 3691 3709 (line 39) 3692 3710 * mpfr_cbrt: Basic Arithmetic Functions. 3693 (line 1 08)3711 (line 113) 3694 3712 * mpfr_ceil: Integer Related Functions. 3695 3713 (line 7) 3696 3714 * mpfr_check_range: Exception Related Functions. … … 3735 3753 (line 27) 3736 3754 * mpfr_cmp_z: Comparison Functions. 3737 3755 (line 11) 3738 * mpfr_const_catalan: Special Functions. (line 2 37)3739 * mpfr_const_euler: Special Functions. (line 2 36)3740 * mpfr_const_log2: Special Functions. (line 2 34)3741 * mpfr_const_pi: Special Functions. (line 2 35)3756 * mpfr_const_catalan: Special Functions. (line 247) 3757 * mpfr_const_euler: Special Functions. (line 246) 3758 * mpfr_const_log2: Special Functions. (line 244) 3759 * mpfr_const_pi: Special Functions. (line 245) 3742 3760 * mpfr_copysign: Miscellaneous Functions. 3743 3761 (line 109) 3744 * mpfr_cos: Special Functions. (line 29)3745 * mpfr_cosh: Special Functions. (line 9 5)3746 * mpfr_cot: Special Functions. (line 4 7)3747 * mpfr_coth: Special Functions. (line 11 1)3748 * mpfr_csc: Special Functions. (line 4 6)3749 * mpfr_csch: Special Functions. (line 11 0)3762 * mpfr_cos: Special Functions. (line 31) 3763 * mpfr_cosh: Special Functions. (line 97) 3764 * mpfr_cot: Special Functions. (line 49) 3765 * mpfr_coth: Special Functions. (line 113) 3766 * mpfr_csc: Special Functions. (line 48) 3767 * mpfr_csch: Special Functions. (line 112) 3750 3768 * mpfr_custom_get_exp: Custom Interface. (line 75) 3751 3769 * mpfr_custom_get_kind: Custom Interface. (line 65) 3752 3770 * mpfr_custom_get_significand: Custom Interface. (line 70) … … 3756 3774 * mpfr_custom_move: Custom Interface. (line 82) 3757 3775 * MPFR_DECL_INIT: Initialization Functions. 3758 3776 (line 74) 3759 * mpfr_digamma: Special Functions. (line 1 66)3777 * mpfr_digamma: Special Functions. (line 172) 3760 3778 * mpfr_dim: Basic Arithmetic Functions. 3761 (line 1 66)3779 (line 171) 3762 3780 * mpfr_div: Basic Arithmetic Functions. 3763 (line 7 2)3781 (line 74) 3764 3782 * mpfr_divby0_p: Exception Related Functions. 3765 3783 (line 134) 3766 3784 * mpfr_div_2exp: Compatibility with MPF. 3767 3785 (line 49) 3768 3786 * mpfr_div_2si: Basic Arithmetic Functions. 3769 (line 18 1)3787 (line 186) 3770 3788 * mpfr_div_2ui: Basic Arithmetic Functions. 3771 (line 1 79)3789 (line 184) 3772 3790 * mpfr_div_d: Basic Arithmetic Functions. 3773 (line 8 4)3791 (line 86) 3774 3792 * mpfr_div_q: Basic Arithmetic Functions. 3775 (line 88)3793 (line 90) 3776 3794 * mpfr_div_si: Basic Arithmetic Functions. 3777 (line 8 0)3795 (line 82) 3778 3796 * mpfr_div_ui: Basic Arithmetic Functions. 3779 (line 7 6)3797 (line 78) 3780 3798 * mpfr_div_z: Basic Arithmetic Functions. 3781 (line 8 6)3799 (line 88) 3782 3800 * mpfr_d_div: Basic Arithmetic Functions. 3783 (line 8 2)3801 (line 84) 3784 3802 * mpfr_d_sub: Basic Arithmetic Functions. 3785 (line 3 5)3786 * mpfr_eint: Special Functions. (line 13 3)3803 (line 36) 3804 * mpfr_eint: Special Functions. (line 135) 3787 3805 * mpfr_eq: Compatibility with MPF. 3788 3806 (line 28) 3789 3807 * mpfr_equal_p: Comparison Functions. 3790 3808 (line 59) 3791 3809 * mpfr_erangeflag_p: Exception Related Functions. 3792 3810 (line 137) 3793 * mpfr_erf: Special Functions. (line 1 77)3794 * mpfr_erfc: Special Functions. (line 1 78)3795 * mpfr_exp: Special Functions. (line 2 3)3796 * mpfr_exp10: Special Functions. (line 2 5)3797 * mpfr_exp2: Special Functions. (line 2 4)3798 * mpfr_expm1: Special Functions. (line 1 29)3799 * mpfr_fac_ui: Special Functions. (line 12 1)3811 * mpfr_erf: Special Functions. (line 183) 3812 * mpfr_erfc: Special Functions. (line 184) 3813 * mpfr_exp: Special Functions. (line 25) 3814 * mpfr_exp10: Special Functions. (line 27) 3815 * mpfr_exp2: Special Functions. (line 26) 3816 * mpfr_expm1: Special Functions. (line 131) 3817 * mpfr_fac_ui: Special Functions. (line 123) 3800 3818 * mpfr_fits_intmax_p: Conversion Functions. 3801 3819 (line 150) 3802 3820 * mpfr_fits_sint_p: Conversion Functions. … … 3815 3833 (line 147) 3816 3834 * mpfr_floor: Integer Related Functions. 3817 3835 (line 8) 3818 * mpfr_fma: Special Functions. (line 20 3)3836 * mpfr_fma: Special Functions. (line 209) 3819 3837 * mpfr_fmod: Integer Related Functions. 3820 3838 (line 92) 3821 * mpfr_fms: Special Functions. (line 2 05)3839 * mpfr_fms: Special Functions. (line 211) 3822 3840 * mpfr_fprintf: Formatted Output Functions. 3823 3841 (line 157) 3824 3842 * mpfr_frac: Integer Related Functions. 3825 3843 (line 76) 3826 * mpfr_free_cache: Special Functions. (line 2 44)3844 * mpfr_free_cache: Special Functions. (line 254) 3827 3845 * mpfr_free_str: Conversion Functions. 3828 3846 (line 137) 3829 3847 * mpfr_frexp: Conversion Functions. 3830 3848 (line 45) 3831 * mpfr_gamma: Special Functions. (line 1 48)3849 * mpfr_gamma: Special Functions. (line 150) 3832 3850 * mpfr_get_d: Conversion Functions. 3833 3851 (line 7) 3834 3852 * mpfr_get_decimal64: Conversion Functions. … … 3887 3905 (line 56) 3888 3906 * mpfr_greater_p: Comparison Functions. 3889 3907 (line 55) 3890 * mpfr_hypot: Special Functions. (line 2 18)3908 * mpfr_hypot: Special Functions. (line 227) 3891 3909 * mpfr_inexflag_p: Exception Related Functions. 3892 3910 (line 136) 3893 3911 * mpfr_inf_p: Comparison Functions. … … 3922 3940 (line 31) 3923 3941 * mpfr_integer_p: Integer Related Functions. 3924 3942 (line 119) 3925 * mpfr_j0: Special Functions. (line 18 2)3926 * mpfr_j1: Special Functions. (line 18 3)3927 * mpfr_jn: Special Functions. (line 1 84)3943 * mpfr_j0: Special Functions. (line 188) 3944 * mpfr_j1: Special Functions. (line 189) 3945 * mpfr_jn: Special Functions. (line 190) 3928 3946 * mpfr_lessequal_p: Comparison Functions. 3929 3947 (line 58) 3930 3948 * mpfr_lessgreater_p: Comparison Functions. 3931 3949 (line 64) 3932 3950 * mpfr_less_p: Comparison Functions. 3933 3951 (line 57) 3934 * mpfr_lgamma: Special Functions. (line 1 57)3935 * mpfr_li2: Special Functions. (line 14 3)3936 * mpfr_lngamma: Special Functions. (line 15 2)3952 * mpfr_lgamma: Special Functions. (line 162) 3953 * mpfr_li2: Special Functions. (line 145) 3954 * mpfr_lngamma: Special Functions. (line 154) 3937 3955 * mpfr_log: Special Functions. (line 16) 3938 3956 * mpfr_log10: Special Functions. (line 18) 3939 * mpfr_log1p: Special Functions. (line 12 5)3957 * mpfr_log1p: Special Functions. (line 127) 3940 3958 * mpfr_log2: Special Functions. (line 17) 3941 3959 * mpfr_max: Miscellaneous Functions. 3942 3960 (line 22) … … 3947 3965 * mpfr_modf: Integer Related Functions. 3948 3966 (line 82) 3949 3967 * mpfr_mul: Basic Arithmetic Functions. 3950 (line 5 1)3968 (line 53) 3951 3969 * mpfr_mul_2exp: Compatibility with MPF. 3952 3970 (line 47) 3953 3971 * mpfr_mul_2si: Basic Arithmetic Functions. 3954 (line 17 4)3972 (line 179) 3955 3973 * mpfr_mul_2ui: Basic Arithmetic Functions. 3956 (line 17 2)3974 (line 177) 3957 3975 * mpfr_mul_d: Basic Arithmetic Functions. 3958 (line 5 7)3976 (line 59) 3959 3977 * mpfr_mul_q: Basic Arithmetic Functions. 3960 (line 6 1)3978 (line 63) 3961 3979 * mpfr_mul_si: Basic Arithmetic Functions. 3962 (line 5 5)3980 (line 57) 3963 3981 * mpfr_mul_ui: Basic Arithmetic Functions. 3964 (line 5 3)3982 (line 55) 3965 3983 * mpfr_mul_z: Basic Arithmetic Functions. 3966 (line 59)3984 (line 61) 3967 3985 * mpfr_nanflag_p: Exception Related Functions. 3968 3986 (line 135) 3969 3987 * mpfr_nan_p: Comparison Functions. 3970 3988 (line 39) 3971 3989 * mpfr_neg: Basic Arithmetic Functions. 3972 (line 1 59)3990 (line 164) 3973 3991 * mpfr_nextabove: Miscellaneous Functions. 3974 3992 (line 15) 3975 3993 * mpfr_nextbelow: Miscellaneous Functions. … … 3983 4001 * mpfr_overflow_p: Exception Related Functions. 3984 4002 (line 133) 3985 4003 * mpfr_pow: Basic Arithmetic Functions. 3986 (line 1 16)4004 (line 121) 3987 4005 * mpfr_pow_si: Basic Arithmetic Functions. 3988 (line 12 0)4006 (line 125) 3989 4007 * mpfr_pow_ui: Basic Arithmetic Functions. 3990 (line 1 18)4008 (line 123) 3991 4009 * mpfr_pow_z: Basic Arithmetic Functions. 3992 (line 12 2)4010 (line 127) 3993 4011 * mpfr_prec_round: Rounding Related Functions. 3994 4012 (line 13) 3995 4013 * âmpfr_prec_tâ: Nomenclature and Types. … … 3999 4017 * mpfr_print_rnd_mode: Rounding Related Functions. 4000 4018 (line 71) 4001 4019 * mpfr_rec_sqrt: Basic Arithmetic Functions. 4002 (line 10 3)4020 (line 105) 4003 4021 * mpfr_regular_p: Comparison Functions. 4004 4022 (line 43) 4005 4023 * mpfr_reldiff: Compatibility with MPF. … … 4021 4039 * âmpfr_rnd_tâ: Nomenclature and Types. 4022 4040 (line 34) 4023 4041 * mpfr_root: Basic Arithmetic Functions. 4024 (line 1 09)4042 (line 114) 4025 4043 * mpfr_round: Integer Related Functions. 4026 4044 (line 9) 4027 * mpfr_sec: Special Functions. (line 4 5)4028 * mpfr_sech: Special Functions. (line 1 09)4045 * mpfr_sec: Special Functions. (line 47) 4046 * mpfr_sech: Special Functions. (line 111) 4029 4047 * mpfr_set: Assignment Functions. 4030 4048 (line 9) 4031 4049 * mpfr_setsign: Miscellaneous Functions. … … 4100 4118 (line 49) 4101 4119 * mpfr_signbit: Miscellaneous Functions. 4102 4120 (line 99) 4103 * mpfr_sin: Special Functions. (line 3 0)4104 * mpfr_sinh: Special Functions. (line 9 6)4105 * mpfr_sinh_cosh: Special Functions. (line 10 1)4106 * mpfr_sin_cos: Special Functions. (line 3 5)4121 * mpfr_sin: Special Functions. (line 32) 4122 * mpfr_sinh: Special Functions. (line 98) 4123 * mpfr_sinh_cosh: Special Functions. (line 103) 4124 * mpfr_sin_cos: Special Functions. (line 37) 4107 4125 * mpfr_si_div: Basic Arithmetic Functions. 4108 (line 78)4126 (line 80) 4109 4127 * mpfr_si_sub: Basic Arithmetic Functions. 4110 (line 3 1)4128 (line 32) 4111 4129 * mpfr_snprintf: Formatted Output Functions. 4112 4130 (line 180) 4113 4131 * mpfr_sprintf: Formatted Output Functions. 4114 4132 (line 170) 4115 4133 * mpfr_sqr: Basic Arithmetic Functions. 4116 (line 69)4134 (line 71) 4117 4135 * mpfr_sqrt: Basic Arithmetic Functions. 4118 (line 9 6)4136 (line 98) 4119 4137 * mpfr_sqrt_ui: Basic Arithmetic Functions. 4120 (line 9 7)4138 (line 99) 4121 4139 * mpfr_strtofr: Assignment Functions. 4122 4140 (line 80) 4123 4141 * mpfr_sub: Basic Arithmetic Functions. 4124 (line 2 5)4142 (line 26) 4125 4143 * mpfr_subnormalize: Exception Related Functions. 4126 4144 (line 60) 4127 4145 * mpfr_sub_d: Basic Arithmetic Functions. 4128 (line 3 7)4146 (line 38) 4129 4147 * mpfr_sub_q: Basic Arithmetic Functions. 4130 (line 4 3)4148 (line 44) 4131 4149 * mpfr_sub_si: Basic Arithmetic Functions. 4132 (line 3 3)4150 (line 34) 4133 4151 * mpfr_sub_ui: Basic Arithmetic Functions. 4134 (line 29)4152 (line 30) 4135 4153 * mpfr_sub_z: Basic Arithmetic Functions. 4136 (line 4 1)4137 * mpfr_sum: Special Functions. (line 2 52)4154 (line 42) 4155 * mpfr_sum: Special Functions. (line 262) 4138 4156 * mpfr_swap: Assignment Functions. 4139 4157 (line 150) 4140 4158 * âmpfr_tâ: Nomenclature and Types. 4141 4159 (line 6) 4142 * mpfr_tan: Special Functions. (line 3 1)4143 * mpfr_tanh: Special Functions. (line 9 7)4160 * mpfr_tan: Special Functions. (line 33) 4161 * mpfr_tanh: Special Functions. (line 99) 4144 4162 * mpfr_trunc: Integer Related Functions. 4145 4163 (line 10) 4146 4164 * mpfr_ui_div: Basic Arithmetic Functions. 4147 (line 7 4)4165 (line 76) 4148 4166 * mpfr_ui_pow: Basic Arithmetic Functions. 4149 (line 1 26)4167 (line 131) 4150 4168 * mpfr_ui_pow_ui: Basic Arithmetic Functions. 4151 (line 12 4)4169 (line 129) 4152 4170 * mpfr_ui_sub: Basic Arithmetic Functions. 4153 (line 2 7)4171 (line 28) 4154 4172 * mpfr_underflow_p: Exception Related Functions. 4155 4173 (line 132) 4156 4174 * mpfr_unordered_p: Comparison Functions. … … 4181 4199 (line 182) 4182 4200 * mpfr_vsprintf: Formatted Output Functions. 4183 4201 (line 171) 4184 * mpfr_y0: Special Functions. (line 19 3)4185 * mpfr_y1: Special Functions. (line 194)4186 * mpfr_yn: Special Functions. (line 195)4202 * mpfr_y0: Special Functions. (line 199) 4203 * mpfr_y1: Special Functions. (line 200) 4204 * mpfr_yn: Special Functions. (line 201) 4187 4205 * mpfr_zero_p: Comparison Functions. 4188 4206 (line 42) 4189 * mpfr_zeta: Special Functions. (line 17 1)4190 * mpfr_zeta_ui: Special Functions. (line 17 2)4207 * mpfr_zeta: Special Functions. (line 177) 4208 * mpfr_zeta_ui: Special Functions. (line 178) 4191 4209 * mpfr_z_sub: Basic Arithmetic Functions. 4192 (line 39)4210 (line 40) 4193 4211 4194 4212 4195 4213 4196 4214 Tag Table: 4197 4215 Node: Top775 4198 4216 Node: Copying2007 4199 Node: Introduction to MPFR37 664200 Node: Installing MPFR588 04201 Node: Reporting Bugs1132 34202 Node: MPFR Basics1335 34203 Node: Headers and Libraries136 694204 Node: Nomenclature and Types168 284205 Node: MPFR Variable Conventions188 744206 Node: Rounding Modes204 184207 Ref: ternary value215 444208 Node: Floating-Point Values on Special Numbers235 264209 Node: Exceptions26 5724210 Node: Memory Handling29 7494211 Node: MPFR Interface3 08944212 Node: Initialization Functions33 0084213 Node: Assignment Functions40 3184214 Node: Combined Initialization and Assignment Functions49 6734215 Node: Conversion Functions5 09744216 Node: Basic Arithmetic Functions60 0354217 Node: Comparison Functions69 2004218 Node: Special Functions7 26874219 Node: Input and Output Functions8 66724220 Node: Formatted Output Functions8 86444221 Node: Integer Related Functions9 84314222 Node: Rounding Related Functions10 50514223 Node: Miscellaneous Functions1 088884224 Node: Exception Related Functions11 75684225 Node: Compatibility with MPF12 43864226 Node: Custom Interface12 71274227 Node: Internals13 15264228 Node: API Compatibility13 30664229 Node: Type and Macro Changes13 49954230 Node: Added Functions13 78444231 Node: Changed Functions14 11324232 Node: Removed Functions14 55454233 Node: Other Changes14 59734234 Node: Contributors14 75764235 Node: References15 02194236 Node: GNU Free Documentation License15 19734237 Node: Concept Index17 45624238 Node: Function and Type Index18 06594217 Node: Introduction to MPFR3770 4218 Node: Installing MPFR5884 4219 Node: Reporting Bugs11327 4220 Node: MPFR Basics13357 4221 Node: Headers and Libraries13673 4222 Node: Nomenclature and Types16832 4223 Node: MPFR Variable Conventions18894 4224 Node: Rounding Modes20438 4225 Ref: ternary value21568 4226 Node: Floating-Point Values on Special Numbers23554 4227 Node: Exceptions26813 4228 Node: Memory Handling29990 4229 Node: MPFR Interface31135 4230 Node: Initialization Functions33249 4231 Node: Assignment Functions40559 4232 Node: Combined Initialization and Assignment Functions49914 4233 Node: Conversion Functions51215 4234 Node: Basic Arithmetic Functions60276 4235 Node: Comparison Functions69777 4236 Node: Special Functions73264 4237 Node: Input and Output Functions87862 4238 Node: Formatted Output Functions89834 4239 Node: Integer Related Functions99621 4240 Node: Rounding Related Functions106241 4241 Node: Miscellaneous Functions110078 4242 Node: Exception Related Functions118758 4243 Node: Compatibility with MPF125576 4244 Node: Custom Interface128317 4245 Node: Internals132716 4246 Node: API Compatibility134260 4247 Node: Type and Macro Changes136189 4248 Node: Added Functions139038 4249 Node: Changed Functions142326 4250 Node: Removed Functions146739 4251 Node: Other Changes147167 4252 Node: Contributors148770 4253 Node: References151413 4254 Node: GNU Free Documentation License153167 4255 Node: Concept Index175760 4256 Node: Function and Type Index181857 4239 4257 4240 4258 End Tag Table 4241 4259 -
src/lngamma.c
diff -Naurd mpfr-3.1.3-a/src/lngamma.c mpfr-3.1.3-b/src/lngamma.c
old new 603 603 mpfr_get_prec (y), mpfr_log_prec, y, inex)); 604 604 605 605 /* special cases */ 606 if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x))) 606 if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x) || 607 (MPFR_IS_NEG (x) && mpfr_integer_p (x)))) 607 608 { 608 if (MPFR_IS_NAN (x) || MPFR_IS_NEG (x))609 if (MPFR_IS_NAN (x)) 609 610 { 610 611 MPFR_SET_NAN (y); 611 612 MPFR_RET_NAN; 612 613 } 613 else /* lngamma(+ Inf) = lngamma(+0) = +Inf */614 else /* lngamma(+/-Inf) = lngamma(nonpositive integer) = +Inf */ 614 615 { 615 if ( MPFR_IS_ZERO(x))616 if (!MPFR_IS_INF (x)) 616 617 mpfr_set_divby0 (); 617 618 MPFR_SET_INF (y); 618 619 MPFR_SET_POS (y); … … 620 621 } 621 622 } 622 623 623 /* if x < 0 and -2k-1 <= x <= -2k, then lngamma(x) = NaN */624 if (MPFR_IS_NEG (x) && (unit_bit (x) == 0 || mpfr_integer_p (x)))624 /* if -2k-1 < x < -2k <= 0, then lngamma(x) = NaN */ 625 if (MPFR_IS_NEG (x) && unit_bit (x) == 0) 625 626 { 626 627 MPFR_SET_NAN (y); 627 628 MPFR_RET_NAN; -
src/mpfr.h
diff -Naurd mpfr-3.1.3-a/src/mpfr.h mpfr-3.1.3-b/src/mpfr.h
old new 27 27 #define MPFR_VERSION_MAJOR 3 28 28 #define MPFR_VERSION_MINOR 1 29 29 #define MPFR_VERSION_PATCHLEVEL 3 30 #define MPFR_VERSION_STRING "3.1.3 "30 #define MPFR_VERSION_STRING "3.1.3-p1" 31 31 32 32 /* Macros dealing with MPFR VERSION */ 33 33 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) -
src/version.c
diff -Naurd mpfr-3.1.3-a/src/version.c mpfr-3.1.3-b/src/version.c
old new 25 25 const char * 26 26 mpfr_get_version (void) 27 27 { 28 return "3.1.3 ";28 return "3.1.3-p1"; 29 29 } -
tests/tlngamma.c
diff -Naurd mpfr-3.1.3-a/tests/tlngamma.c mpfr-3.1.3-b/tests/tlngamma.c
old new 33 33 special (void) 34 34 { 35 35 mpfr_t x, y; 36 int i nex;36 int i, inex; 37 37 38 38 mpfr_init (x); 39 39 mpfr_init (y); … … 46 46 exit (1); 47 47 } 48 48 49 mpfr_set_inf (x, -1); 49 mpfr_set_inf (x, 1); 50 mpfr_clear_flags (); 50 51 mpfr_lngamma (y, x, MPFR_RNDN); 51 if (!mpfr_ nan_p (y))52 if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0 || __gmpfr_flags != 0) 52 53 { 53 printf ("Error for lngamma( -Inf)\n");54 printf ("Error for lngamma(+Inf)\n"); 54 55 exit (1); 55 56 } 56 57 57 mpfr_set_inf (x, 1); 58 mpfr_set_inf (x, -1); 59 mpfr_clear_flags (); 58 60 mpfr_lngamma (y, x, MPFR_RNDN); 59 if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0 )61 if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0 || __gmpfr_flags != 0) 60 62 { 61 printf ("Error for lngamma( +Inf)\n");63 printf ("Error for lngamma(-Inf)\n"); 62 64 exit (1); 63 65 } 64 66 65 67 mpfr_set_ui (x, 0, MPFR_RNDN); 68 mpfr_clear_flags (); 66 69 mpfr_lngamma (y, x, MPFR_RNDN); 67 if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0) 70 if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0 || 71 __gmpfr_flags != MPFR_FLAGS_DIVBY0) 68 72 { 69 73 printf ("Error for lngamma(+0)\n"); 70 74 exit (1); … … 72 76 73 77 mpfr_set_ui (x, 0, MPFR_RNDN); 74 78 mpfr_neg (x, x, MPFR_RNDN); 79 mpfr_clear_flags (); 75 80 mpfr_lngamma (y, x, MPFR_RNDN); 76 if (!mpfr_nan_p (y)) 81 if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0 || 82 __gmpfr_flags != MPFR_FLAGS_DIVBY0) 77 83 { 78 84 printf ("Error for lngamma(-0)\n"); 79 85 exit (1); 80 86 } 81 87 82 88 mpfr_set_ui (x, 1, MPFR_RNDN); 89 mpfr_clear_flags (); 83 90 mpfr_lngamma (y, x, MPFR_RNDN); 84 if ( MPFR_IS_NAN (y) || mpfr_cmp_ui(y, 0) || MPFR_IS_NEG (y))91 if (mpfr_cmp_ui0 (y, 0) || MPFR_IS_NEG (y)) 85 92 { 86 93 printf ("Error for lngamma(1)\n"); 87 94 exit (1); 88 95 } 89 96 90 mpfr_set_si (x, -1, MPFR_RNDN); 91 mpfr_lngamma (y, x, MPFR_RNDN); 92 if (!mpfr_nan_p (y)) 97 for (i = 1; i <= 5; i++) 93 98 { 94 printf ("Error for lngamma(-1)\n"); 95 exit (1); 99 int c; 100 101 mpfr_set_si (x, -i, MPFR_RNDN); 102 mpfr_clear_flags (); 103 mpfr_lngamma (y, x, MPFR_RNDN); 104 if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0 || 105 __gmpfr_flags != MPFR_FLAGS_DIVBY0) 106 { 107 printf ("Error for lngamma(-%d)\n", i); 108 exit (1); 109 } 110 if (i & 1) 111 { 112 mpfr_nextabove (x); 113 c = '+'; 114 } 115 else 116 { 117 mpfr_nextbelow (x); 118 c = '-'; 119 } 120 mpfr_lngamma (y, x, MPFR_RNDN); 121 if (!mpfr_nan_p (y)) 122 { 123 printf ("Error for lngamma(-%d%cepsilon)\n", i, c); 124 exit (1); 125 } 96 126 } 97 127 98 128 mpfr_set_ui (x, 2, MPFR_RNDN); 99 129 mpfr_lngamma (y, x, MPFR_RNDN); 100 if ( MPFR_IS_NAN (y) || mpfr_cmp_ui(y, 0) || MPFR_IS_NEG (y))130 if (mpfr_cmp_ui0 (y, 0) || MPFR_IS_NEG (y)) 101 131 { 102 132 printf ("Error for lngamma(2)\n"); 103 133 exit (1); … … 127 157 mpfr_set_str (x, CHECK_X2, 10, MPFR_RNDN); 128 158 mpfr_lngamma (y, x, MPFR_RNDN); 129 159 mpfr_set_str (x, CHECK_Y2, 10, MPFR_RNDN); 130 if ( MPFR_IS_NAN (y) || mpfr_cmp(y, x))160 if (mpfr_cmp0 (y, x)) 131 161 { 132 162 printf ("mpfr_lngamma("CHECK_X2") is wrong:\n" 133 163 "expected "); … … 143 173 mpfr_lngamma (y, x, MPFR_RNDU); 144 174 mpfr_set_prec (x, 175); 145 175 mpfr_set_str_binary (x, "0.1010001100011101101011001101110010100001000001000001110011000001101100001111001001000101011011100100010101011110100111110101010100010011010010000101010111001100011000101111E7"); 146 if ( MPFR_IS_NAN (y) || mpfr_cmp(x, y))176 if (mpfr_cmp0 (x, y)) 147 177 { 148 178 printf ("Error in mpfr_lngamma (1)\n"); 149 179 exit (1); … … 155 185 mpfr_lngamma (x, y, MPFR_RNDZ); 156 186 mpfr_set_prec (y, 21); 157 187 mpfr_set_str_binary (y, "0.111000101000001100101E9"); 158 if ( MPFR_IS_NAN (x) || mpfr_cmp(x, y))188 if (mpfr_cmp0 (x, y)) 159 189 { 160 190 printf ("Error in mpfr_lngamma (120)\n"); 161 191 printf ("Expected "); mpfr_print_binary (y); puts (""); … … 169 199 inex = mpfr_lngamma (y, x, MPFR_RNDN); 170 200 mpfr_set_prec (x, 206); 171 201 mpfr_set_str_binary (x, "0.10000111011000000011100010101001100110001110000111100011000100100110110010001011011110101001111011110110000001010100111011010000000011100110110101100111000111010011110010000100010111101010001101000110101001E13"); 172 if ( MPFR_IS_NAN (y) || mpfr_cmp(x, y))202 if (mpfr_cmp0 (x, y)) 173 203 { 174 204 printf ("Error in mpfr_lngamma (768)\n"); 175 205 exit (1); … … 185 215 mpfr_set_str_binary (x, "0.1100E-66"); 186 216 mpfr_lngamma (y, x, MPFR_RNDN); 187 217 mpfr_set_str_binary (x, "0.1100E6"); 188 if ( MPFR_IS_NAN (y) || mpfr_cmp(x, y))218 if (mpfr_cmp0 (x, y)) 189 219 { 190 220 printf ("Error for lngamma(0.1100E-66)\n"); 191 221 exit (1); … … 199 229 mpfr_lngamma (y, x, MPFR_RNDN); 200 230 mpfr_set_prec (x, 32); 201 231 mpfr_set_str_binary (x, "-0.10001000111011111011000010100010E207"); 202 if ( MPFR_IS_NAN (y) || mpfr_cmp(x, y))232 if (mpfr_cmp0 (x, y)) 203 233 { 204 234 printf ("Error for lngamma(-2^199+0.5)\n"); 205 235 printf ("Got "); -
mpfr-3.1.
diff -Naurd mpfr-3.1.3-a/PATCHES mpfr-3.1.3-b/PATCHES
old new 1 muldiv-2exp-overflow -
mpfr-3.1.
diff -Naurd mpfr-3.1.3-a/VERSION mpfr-3.1.3-b/VERSION
old new 1 3.1.3-p 11 3.1.3-p2 -
src/div_2si.c
diff -Naurd mpfr-3.1.3-a/src/div_2si.c mpfr-3.1.3-b/src/div_2si.c
old new 49 49 rnd_mode = MPFR_RNDZ; 50 50 return mpfr_underflow (y, rnd_mode, MPFR_SIGN(y)); 51 51 } 52 else if (MPFR_UNLIKELY(n < 0 && (__gmpfr_emax < MPFR_EMIN_MIN - n ||52 else if (MPFR_UNLIKELY(n <= 0 && (__gmpfr_emax < MPFR_EMIN_MIN - n || 53 53 exp > __gmpfr_emax + n)) ) 54 54 return mpfr_overflow (y, rnd_mode, MPFR_SIGN(y)); 55 55 -
src/div_2ui.c
diff -Naurd mpfr-3.1.3-a/src/div_2ui.c mpfr-3.1.3-b/src/div_2ui.c
old new 32 32 rnd_mode), 33 33 ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, inexact)); 34 34 35 if (MPFR_UNLIKELY ( MPFR_IS_SINGULAR (x)))35 if (MPFR_UNLIKELY (n == 0 || MPFR_IS_SINGULAR (x))) 36 36 return mpfr_set (y, x, rnd_mode); 37 37 else 38 38 { -
src/mpfr.h
diff -Naurd mpfr-3.1.3-a/src/mpfr.h mpfr-3.1.3-b/src/mpfr.h
old new 27 27 #define MPFR_VERSION_MAJOR 3 28 28 #define MPFR_VERSION_MINOR 1 29 29 #define MPFR_VERSION_PATCHLEVEL 3 30 #define MPFR_VERSION_STRING "3.1.3-p 1"30 #define MPFR_VERSION_STRING "3.1.3-p2" 31 31 32 32 /* Macros dealing with MPFR VERSION */ 33 33 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) -
src/mul_2si.c
diff -Naurd mpfr-3.1.3-a/src/mul_2si.c mpfr-3.1.3-b/src/mul_2si.c
old new 39 39 { 40 40 mpfr_exp_t exp = MPFR_GET_EXP (x); 41 41 MPFR_SETRAW (inexact, y, x, exp, rnd_mode); 42 if (MPFR_UNLIKELY( n >0 && (__gmpfr_emax < MPFR_EMIN_MIN + n ||42 if (MPFR_UNLIKELY(n >= 0 && (__gmpfr_emax < MPFR_EMIN_MIN + n || 43 43 exp > __gmpfr_emax - n))) 44 44 return mpfr_overflow (y, rnd_mode, MPFR_SIGN(y)); 45 45 else if (MPFR_UNLIKELY(n < 0 && (__gmpfr_emin > MPFR_EMAX_MAX + n || -
src/version.c
diff -Naurd mpfr-3.1.3-a/src/version.c mpfr-3.1.3-b/src/version.c
old new 25 25 const char * 26 26 mpfr_get_version (void) 27 27 { 28 return "3.1.3-p 1";28 return "3.1.3-p2"; 29 29 } -
tests/tmul_2exp.c
diff -Naurd mpfr-3.1.3-a/tests/tmul_2exp.c mpfr-3.1.3-b/tests/tmul_2exp.c
old new 242 242 large (MPFR_EMAX_MAX); 243 243 } 244 244 245 /* Cases where the function overflows on n = 0 when rounding is like 246 away from zero. */ 247 static void 248 overflow0 (mpfr_exp_t emax) 249 { 250 mpfr_exp_t old_emax; 251 mpfr_t x, y1, y2; 252 int neg, r, op; 253 static char *sop[4] = { "mul_2ui", "mul_2si", "div_2ui", "div_2si" }; 254 255 old_emax = mpfr_get_emax (); 256 set_emax (emax); 257 258 mpfr_init2 (x, 8); 259 mpfr_inits2 (6, y1, y2, (mpfr_ptr) 0); 260 261 mpfr_set_inf (x, 1); 262 mpfr_nextbelow (x); 263 264 for (neg = 0; neg <= 1; neg++) 265 { 266 RND_LOOP (r) 267 { 268 int inex1, inex2; 269 unsigned int flags1, flags2; 270 271 /* Even if there isn't an overflow (rounding ~ toward zero), 272 the result is the same as the one of an overflow. */ 273 inex1 = mpfr_overflow (y1, (mpfr_rnd_t) r, neg ? -1 : 1); 274 flags1 = MPFR_FLAGS_INEXACT; 275 if (mpfr_inf_p (y1)) 276 flags1 |= MPFR_FLAGS_OVERFLOW; 277 for (op = 0; op < 4; op++) 278 { 279 mpfr_clear_flags (); 280 inex2 = 281 op == 0 ? mpfr_mul_2ui (y2, x, 0, (mpfr_rnd_t) r) : 282 op == 1 ? mpfr_mul_2si (y2, x, 0, (mpfr_rnd_t) r) : 283 op == 2 ? mpfr_div_2ui (y2, x, 0, (mpfr_rnd_t) r) : 284 op == 3 ? mpfr_div_2si (y2, x, 0, (mpfr_rnd_t) r) : 285 (MPFR_ASSERTN (0), 0); 286 flags2 = __gmpfr_flags; 287 if (!(mpfr_equal_p (y1, y2) && 288 SAME_SIGN (inex1, inex2) && 289 flags1 == flags2)) 290 { 291 printf ("Error in overflow0 for %s, mpfr_%s, emax = %" 292 MPFR_EXP_FSPEC "d,\nx = ", 293 mpfr_print_rnd_mode ((mpfr_rnd_t) r), sop[op], 294 (mpfr_eexp_t) emax); 295 mpfr_dump (x); 296 printf ("Expected "); 297 mpfr_dump (y1); 298 printf (" with inex = %d, flags =", inex1); 299 flags_out (flags1); 300 printf ("Got "); 301 mpfr_dump (y2); 302 printf (" with inex = %d, flags =", inex2); 303 flags_out (flags2); 304 exit (1); 305 } 306 } 307 } 308 mpfr_neg (x, x, MPFR_RNDN); 309 } 310 311 mpfr_clears (x, y1, y2, (mpfr_ptr) 0); 312 set_emax (old_emax); 313 } 314 245 315 int 246 316 main (int argc, char *argv[]) 247 317 { … … 334 404 underflow0 (); 335 405 large0 (); 336 406 407 if (mpfr_get_emax () != MPFR_EMAX_MAX) 408 overflow0 (mpfr_get_emax ()); 409 overflow0 (MPFR_EMAX_MAX); 410 overflow0 (-1); 411 337 412 tests_end_mpfr (); 338 413 return 0; 339 414 } -
mpfr-3.1.
diff -Naurd mpfr-3.1.3-a/PATCHES mpfr-3.1.3-b/PATCHES
old new 1 muldiv-2exp-underflow -
mpfr-3.1.
diff -Naurd mpfr-3.1.3-a/VERSION mpfr-3.1.3-b/VERSION
old new 1 3.1.3-p 21 3.1.3-p3 -
src/div_2si.c
diff -Naurd mpfr-3.1.3-a/src/div_2si.c mpfr-3.1.3-b/src/div_2si.c
old new 45 45 if (rnd_mode == MPFR_RNDN && 46 46 (__gmpfr_emin > MPFR_EMAX_MAX - (n - 1) || 47 47 exp < __gmpfr_emin + (n - 1) || 48 (inexact >= 0 && mpfr_powerof2_raw (y)))) 48 ((MPFR_IS_NEG (y) ? inexact <= 0 : inexact >= 0) && 49 mpfr_powerof2_raw (y)))) 49 50 rnd_mode = MPFR_RNDZ; 50 51 return mpfr_underflow (y, rnd_mode, MPFR_SIGN(y)); 51 52 } -
src/div_2ui.c
diff -Naurd mpfr-3.1.3-a/src/div_2ui.c mpfr-3.1.3-b/src/div_2ui.c
old new 44 44 if (MPFR_UNLIKELY (n >= diffexp)) /* exp - n <= emin - 1 */ 45 45 { 46 46 if (rnd_mode == MPFR_RNDN && 47 (n > diffexp || (inexact >= 0 && mpfr_powerof2_raw (y)))) 47 (n > diffexp || 48 ((MPFR_IS_NEG (y) ? inexact <= 0 : inexact >= 0) && 49 mpfr_powerof2_raw (y)))) 48 50 rnd_mode = MPFR_RNDZ; 49 51 return mpfr_underflow (y, rnd_mode, MPFR_SIGN (y)); 50 52 } -
src/mpfr.h
diff -Naurd mpfr-3.1.3-a/src/mpfr.h mpfr-3.1.3-b/src/mpfr.h
old new 27 27 #define MPFR_VERSION_MAJOR 3 28 28 #define MPFR_VERSION_MINOR 1 29 29 #define MPFR_VERSION_PATCHLEVEL 3 30 #define MPFR_VERSION_STRING "3.1.3-p 2"30 #define MPFR_VERSION_STRING "3.1.3-p3" 31 31 32 32 /* Macros dealing with MPFR VERSION */ 33 33 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) -
src/mul_2si.c
diff -Naurd mpfr-3.1.3-a/src/mul_2si.c mpfr-3.1.3-b/src/mul_2si.c
old new 48 48 if (rnd_mode == MPFR_RNDN && 49 49 (__gmpfr_emin > MPFR_EMAX_MAX + (n + 1) || 50 50 exp < __gmpfr_emin - (n + 1) || 51 (inexact >= 0 && mpfr_powerof2_raw (y)))) 51 ((MPFR_IS_NEG (y) ? inexact <= 0 : inexact >= 0) && 52 mpfr_powerof2_raw (y)))) 52 53 rnd_mode = MPFR_RNDZ; 53 54 return mpfr_underflow (y, rnd_mode, MPFR_SIGN(y)); 54 55 } -
src/version.c
diff -Naurd mpfr-3.1.3-a/src/version.c mpfr-3.1.3-b/src/version.c
old new 25 25 const char * 26 26 mpfr_get_version (void) 27 27 { 28 return "3.1.3-p 2";28 return "3.1.3-p3"; 29 29 } -
tests/tmul_2exp.c
diff -Naurd mpfr-3.1.3-a/tests/tmul_2exp.c mpfr-3.1.3-b/tests/tmul_2exp.c
old new 50 50 { 51 51 mpfr_t x, y, z1, z2; 52 52 mpfr_exp_t emin; 53 int i, k ;53 int i, k, s; 54 54 int prec; 55 55 int rnd; 56 56 int div; 57 57 int inex1, inex2; 58 58 unsigned int flags1, flags2; 59 59 60 /* Test mul_2si(x, e - k), div_2si(x, k - e) and div_2ui(x, k - e) 61 * with emin = e, x = 1 + i/16, i in { -1, 0, 1 }, and k = 1 to 4,62 * by comparing the result with the one of a simple division.60 /* Test mul_2si(x, e - k), div_2si(x, k - e) and div_2ui(x, k - e) with 61 * emin = e, x = s * (1 + i/16), i in { -1, 0, 1 }, s in { -1, 1 }, and 62 * k = 1 to 4, by comparing the result with the one of a simple division. 63 63 */ 64 64 emin = mpfr_get_emin (); 65 65 set_emin (e); 66 66 mpfr_inits2 (8, x, y, (mpfr_ptr) 0); 67 67 for (i = 15; i <= 17; i++) 68 { 69 inex1 = mpfr_set_ui_2exp (x, i, -4, MPFR_RNDN); 70 MPFR_ASSERTN (inex1 == 0); 71 for (prec = 6; prec >= 3; prec -= 3) 72 { 73 mpfr_inits2 (prec, z1, z2, (mpfr_ptr) 0); 74 RND_LOOP (rnd) 75 for (k = 1; k <= 4; k++) 76 { 77 /* The following one is assumed to be correct. */ 78 inex1 = mpfr_mul_2si (y, x, e, MPFR_RNDN); 79 MPFR_ASSERTN (inex1 == 0); 80 inex1 = mpfr_set_ui (z1, 1 << k, MPFR_RNDN); 81 MPFR_ASSERTN (inex1 == 0); 82 mpfr_clear_flags (); 83 /* Do not use mpfr_div_ui to avoid the optimization 84 by mpfr_div_2si. */ 85 inex1 = mpfr_div (z1, y, z1, (mpfr_rnd_t) rnd); 86 flags1 = __gmpfr_flags; 87 88 for (div = 0; div <= 2; div++) 68 for (s = 1; s >= -1; s -= 2) 69 { 70 inex1 = mpfr_set_si_2exp (x, s * i, -4, MPFR_RNDN); 71 MPFR_ASSERTN (inex1 == 0); 72 for (prec = 6; prec >= 3; prec -= 3) 73 { 74 mpfr_inits2 (prec, z1, z2, (mpfr_ptr) 0); 75 RND_LOOP (rnd) 76 for (k = 1; k <= 4; k++) 89 77 { 78 /* The following one is assumed to be correct. */ 79 inex1 = mpfr_mul_2si (y, x, e, MPFR_RNDN); 80 MPFR_ASSERTN (inex1 == 0); 81 inex1 = mpfr_set_ui (z1, 1 << k, MPFR_RNDN); 82 MPFR_ASSERTN (inex1 == 0); 90 83 mpfr_clear_flags (); 91 inex2 = div == 0 ? 92 mpfr_mul_2si (z2, x, e - k, (mpfr_rnd_t) rnd) : div == 1 ? 93 mpfr_div_2si (z2, x, k - e, (mpfr_rnd_t) rnd) : 94 mpfr_div_2ui (z2, x, k - e, (mpfr_rnd_t) rnd); 95 flags2 = __gmpfr_flags; 96 if (flags1 == flags2 && SAME_SIGN (inex1, inex2) && 97 mpfr_equal_p (z1, z2)) 98 continue; 99 printf ("Error in underflow("); 100 if (e == MPFR_EMIN_MIN) 101 printf ("MPFR_EMIN_MIN"); 102 else if (e == emin) 103 printf ("default emin"); 104 else if (e >= LONG_MIN) 105 printf ("%ld", (long) e); 106 else 107 printf ("<LONG_MIN"); 108 printf (") with mpfr_%s,\nx = %d/16, prec = %d, k = %d, " 109 "%s\n", div == 0 ? "mul_2si" : div == 1 ? 110 "div_2si" : "div_2ui", i, prec, k, 111 mpfr_print_rnd_mode ((mpfr_rnd_t) rnd)); 112 printf ("Expected "); 113 mpfr_out_str (stdout, 16, 0, z1, MPFR_RNDN); 114 printf (", inex = %d, flags = %u\n", SIGN (inex1), flags1); 115 printf ("Got "); 116 mpfr_out_str (stdout, 16, 0, z2, MPFR_RNDN); 117 printf (", inex = %d, flags = %u\n", SIGN (inex2), flags2); 118 exit (1); 119 } /* div */ 120 } /* k */ 121 mpfr_clears (z1, z2, (mpfr_ptr) 0); 122 } /* prec */ 123 } /* i */ 84 /* Do not use mpfr_div_ui to avoid the optimization 85 by mpfr_div_2si. */ 86 inex1 = mpfr_div (z1, y, z1, (mpfr_rnd_t) rnd); 87 flags1 = __gmpfr_flags; 88 89 for (div = 0; div <= 2; div++) 90 { 91 mpfr_clear_flags (); 92 inex2 = 93 div == 0 ? 94 mpfr_mul_2si (z2, x, e - k, (mpfr_rnd_t) rnd) : 95 div == 1 ? 96 mpfr_div_2si (z2, x, k - e, (mpfr_rnd_t) rnd) : 97 mpfr_div_2ui (z2, x, k - e, (mpfr_rnd_t) rnd); 98 flags2 = __gmpfr_flags; 99 if (flags1 == flags2 && SAME_SIGN (inex1, inex2) && 100 mpfr_equal_p (z1, z2)) 101 continue; 102 printf ("Error in underflow("); 103 if (e == MPFR_EMIN_MIN) 104 printf ("MPFR_EMIN_MIN"); 105 else if (e == emin) 106 printf ("default emin"); 107 else if (e >= LONG_MIN) 108 printf ("%ld", (long) e); 109 else 110 printf ("<LONG_MIN"); 111 printf (") with mpfr_%s,\nx = %d/16, prec = %d, k = %d," 112 " %s\n", div == 0 ? "mul_2si" : div == 1 ? 113 "div_2si" : "div_2ui", s * i, prec, k, 114 mpfr_print_rnd_mode ((mpfr_rnd_t) rnd)); 115 printf ("Expected "); 116 mpfr_out_str (stdout, 16, 0, z1, MPFR_RNDN); 117 printf (", inex = %d, flags = %u\n", 118 SIGN (inex1), flags1); 119 printf ("Got "); 120 mpfr_out_str (stdout, 16, 0, z2, MPFR_RNDN); 121 printf (", inex = %d, flags = %u\n", 122 SIGN (inex2), flags2); 123 exit (1); 124 } /* div */ 125 } /* k */ 126 mpfr_clears (z1, z2, (mpfr_ptr) 0); 127 } /* prec */ 128 } /* i */ 124 129 mpfr_clears (x, y, (mpfr_ptr) 0); 125 130 set_emin (emin); 126 131 } -
mpfr-3.1.
diff -Naurd mpfr-3.1.3-a/PATCHES mpfr-3.1.3-b/PATCHES
old new 1 frexp -
mpfr-3.1.
diff -Naurd mpfr-3.1.3-a/VERSION mpfr-3.1.3-b/VERSION
old new 1 3.1.3-p 31 3.1.3-p4 -
src/frexp.c
diff -Naurd mpfr-3.1.3-a/src/frexp.c mpfr-3.1.3-b/src/frexp.c
old new 26 26 mpfr_frexp (mpfr_exp_t *exp, mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) 27 27 { 28 28 int inex; 29 unsigned int saved_flags = __gmpfr_flags; 30 MPFR_BLOCK_DECL (flags); 31 32 MPFR_LOG_FUNC 33 (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec (x), mpfr_log_prec, x, rnd), 34 ("y[%Pu]=%.*Rg exp=%" MPFR_EXP_FSPEC "d inex=%d", mpfr_get_prec (y), 35 mpfr_log_prec, y, (mpfr_eexp_t) *exp, inex)); 29 36 30 37 if (MPFR_UNLIKELY(MPFR_IS_SINGULAR(x))) 31 38 { … … 49 56 } 50 57 } 51 58 52 inex = mpfr_set (y, x, rnd); 59 MPFR_BLOCK (flags, inex = mpfr_set (y, x, rnd)); 60 __gmpfr_flags = saved_flags; 61 62 /* Possible overflow due to the rounding, no possible underflow. */ 63 64 if (MPFR_UNLIKELY (MPFR_OVERFLOW (flags))) 65 { 66 int inex2; 67 68 /* An overflow here means that the exponent of y would be larger than 69 the one of x, thus x would be rounded to the next power of 2, and 70 the returned y should be 1/2 in absolute value, rounded (i.e. with 71 possible underflow or overflow). This also implies that x and y are 72 different objects, so that the exponent of x has not been lost. */ 73 MPFR_LOG_MSG (("Internal overflow\n", 0)); 74 MPFR_ASSERTD (x != y); 75 *exp = MPFR_GET_EXP (x) + 1; 76 inex2 = mpfr_set_si_2exp (y, MPFR_INT_SIGN (x), -1, rnd); 77 MPFR_LOG_MSG (("inex=%d inex2=%d\n", inex, inex2)); 78 if (inex2 != 0) 79 inex = inex2; 80 MPFR_RET (inex); 81 } 82 53 83 *exp = MPFR_GET_EXP (y); 54 MPFR_SET_EXP (y, 0); 84 /* Do not use MPFR_SET_EXP because the range has not been checked yet. */ 85 MPFR_EXP (y) = 0; 55 86 return mpfr_check_range (y, inex, rnd); 56 87 } -
src/mpfr.h
diff -Naurd mpfr-3.1.3-a/src/mpfr.h mpfr-3.1.3-b/src/mpfr.h
old new 27 27 #define MPFR_VERSION_MAJOR 3 28 28 #define MPFR_VERSION_MINOR 1 29 29 #define MPFR_VERSION_PATCHLEVEL 3 30 #define MPFR_VERSION_STRING "3.1.3-p 3"30 #define MPFR_VERSION_STRING "3.1.3-p4" 31 31 32 32 /* Macros dealing with MPFR VERSION */ 33 33 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) -
src/version.c
diff -Naurd mpfr-3.1.3-a/src/version.c mpfr-3.1.3-b/src/version.c
old new 25 25 const char * 26 26 mpfr_get_version (void) 27 27 { 28 return "3.1.3-p 3";28 return "3.1.3-p4"; 29 29 } -
tests/tfrexp.c
diff -Naurd mpfr-3.1.3-a/tests/tfrexp.c mpfr-3.1.3-b/tests/tfrexp.c
old new 129 129 mpfr_clear (x); 130 130 } 131 131 132 static void check1 (void) 133 { 134 mpfr_exp_t emin, emax, e; 135 mpfr_t x, y1, y2; 136 int r, neg, red; 137 138 emin = mpfr_get_emin (); 139 emax = mpfr_get_emax (); 140 set_emin (MPFR_EMIN_MIN); 141 set_emax (MPFR_EMAX_MAX); 142 143 mpfr_init2 (x, 7); 144 mpfr_inits2 (4, y1, y2, (mpfr_ptr) 0); 145 146 mpfr_set_ui_2exp (x, 1, -2, MPFR_RNDN); 147 while (mpfr_regular_p (x)) 148 { 149 /* Test the exponents up to 3 and with the maximum exponent 150 (to check potential intermediate overflow). */ 151 if (MPFR_GET_EXP (x) == 4) 152 mpfr_set_exp (x, MPFR_EMAX_MAX); 153 e = MPFR_GET_EXP (x); 154 for (neg = 0; neg < 2; neg++) 155 { 156 RND_LOOP (r) 157 { 158 int inex1, inex2; 159 mpfr_exp_t e1, e2; 160 unsigned int flags1, flags2; 161 162 for (red = 0; red < 2; red++) 163 { 164 if (red) 165 { 166 /* e1: exponent of the rounded value of x. */ 167 MPFR_ASSERTN (e1 == e || e1 == e + 1); 168 set_emin (e); 169 set_emax (e); 170 mpfr_clear_flags (); 171 inex1 = e1 < 0 ? 172 mpfr_mul_2ui (y1, x, -e1, (mpfr_rnd_t) r) : 173 mpfr_div_2ui (y1, x, e1, (mpfr_rnd_t) r); 174 flags1 = __gmpfr_flags; 175 } 176 else 177 { 178 inex1 = mpfr_set (y1, x, (mpfr_rnd_t) r); 179 e1 = MPFR_IS_INF (y1) ? e + 1 : MPFR_GET_EXP (y1); 180 flags1 = inex1 != 0 ? MPFR_FLAGS_INEXACT : 0; 181 } 182 mpfr_clear_flags (); 183 inex2 = mpfr_frexp (&e2, y2, x, (mpfr_rnd_t) r); 184 flags2 = __gmpfr_flags; 185 set_emin (MPFR_EMIN_MIN); 186 set_emax (MPFR_EMAX_MAX); 187 if ((!red || e == 0) && 188 (! mpfr_regular_p (y2) || MPFR_GET_EXP (y2) != 0)) 189 { 190 printf ("Error in check1 for %s, red = %d, x = ", 191 mpfr_print_rnd_mode ((mpfr_rnd_t) r), red); 192 mpfr_dump (x); 193 printf ("Expected 1/2 <= |y| < 1, got y = "); 194 mpfr_dump (y2); 195 exit (1); 196 } 197 if (!red) 198 { 199 if (e2 > 0) 200 mpfr_mul_2ui (y2, y2, e2, MPFR_RNDN); 201 else if (e2 < 0) 202 mpfr_div_2ui (y2, y2, -e2, MPFR_RNDN); 203 } 204 if (! (SAME_SIGN (inex1, inex2) && 205 mpfr_equal_p (y1, y2) && 206 flags1 == flags2)) 207 { 208 printf ("Error in check1 for %s, red = %d, x = ", 209 mpfr_print_rnd_mode ((mpfr_rnd_t) r), red); 210 mpfr_dump (x); 211 printf ("Expected y1 = "); 212 mpfr_dump (y1); 213 printf ("Got y2 = "); 214 mpfr_dump (y2); 215 printf ("Expected inex ~= %d, got %d\n", inex1, inex2); 216 printf ("Expected flags:"); 217 flags_out (flags1); 218 printf ("Got flags: "); 219 flags_out (flags2); 220 exit (1); 221 } 222 } 223 } 224 mpfr_neg (x, x, MPFR_RNDN); 225 } 226 mpfr_nextabove (x); 227 } 228 229 mpfr_clears (x, y1, y2, (mpfr_ptr) 0); 230 set_emin (emin); 231 set_emax (emax); 232 } 233 132 234 int 133 235 main (int argc, char *argv[]) 134 236 { 135 237 tests_start_mpfr (); 136 238 137 239 check_special (); 240 check1 (); 138 241 139 242 tests_end_mpfr (); 140 243 return 0;
Note:
See TracBrowser
for help on using the repository browser.