diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2015-07-02 00:47:18 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2015-07-02 00:47:18 +0000 |
commit | f62e3e6cbd88ea00b17bd9496aeaaaac7858adc5 (patch) | |
tree | 716a3b80b053a30e5bdee09fe69b5be1283ab237 /doc | |
parent | 4b54c30ab8914451bc2aa4018629061ff7818f63 (diff) | |
download | mpfr-f62e3e6cbd88ea00b17bd9496aeaaaac7858adc5.tar.gz |
[doc/mpfr.texi] Completed specification:
* on special numbers (±0, ±Inf);
* of mpfr_lngamma and mpfr_lgamma on 1 and 2 (result is +0);
* general rules for special values and on mpfr_lngamma.
[src/lngamma.c] Fixed mpfr_lngamma behavior on nonpositive integers
and -Inf.
[tests/tlngamma.c] Update. Test the flags for some special values.
See <https://sympa.inria.fr/sympa/arc/mpfr/2013-08/msg00008.html> about
the behavior of mpfr_lngamma on zero and general rule for such limits.
(merged changesets r8629,8632-8633,8841,8847 from the trunk)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/3.1@9605 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'doc')
-rw-r--r-- | doc/mpfr.texi | 64 |
1 files changed, 41 insertions, 23 deletions
diff --git a/doc/mpfr.texi b/doc/mpfr.texi index 0c2f6cc4a..f62a966dc 100644 --- a/doc/mpfr.texi +++ b/doc/mpfr.texi @@ -810,13 +810,17 @@ positive value when @var{n} goes to the infinity. When the input point is in the closure of the domain of the mathematical function and an input argument is +0 (resp.@: @minus{}0), one considers the limit when the corresponding argument approaches 0 from above -(resp.@: below). If the limit is not defined (e.g., @code{mpfr_log} on -@minus{}0), the behavior is specified in the description of the MPFR function. +(resp.@: below), if possible. If the limit is not defined (e.g., +@code{mpfr_sqrt} and @code{mpfr_log} on @minus{}0), the behavior is +specified in the description of the MPFR function, but must be consistent +with the rule from the above paragraph (e.g., @code{mpfr_log} on @pom{}0 +gives @minus{}Inf). When the result is equal to 0, its sign is determined by considering the limit as if the input point were not in the domain: If one approaches 0 from above (resp.@: below), the result is +0 (resp.@: @minus{}0); -for example, @code{mpfr_sin} on +0 gives +0. +for example, @code{mpfr_sin} on @minus{}0 gives @minus{}0 and +@code{mpfr_acos} on 1 gives +0 (in all rounding modes). In the other cases, the sign is specified in the description of the MPFR function; for example @code{mpfr_max} on @minus{}0 and +0 gives +0. @@ -832,8 +836,8 @@ such a case is always explicitly specified in @ref{MPFR Interface}. @c that advantages in practice), like for any bug fix. Example: @code{mpfr_hypot} on (NaN,0) gives NaN, but @code{mpfr_hypot} on (NaN,+Inf) gives +Inf (as specified in @ref{Special Functions}), -since for any finite input @var{x}, @code{mpfr_hypot} on (@var{x},+Inf) -gives +Inf. +since for any finite or infinite input @var{x}, @code{mpfr_hypot} on +(@var{x},+Inf) gives +Inf. @node Exceptions, Memory Handling, Floating-Point Values on Special Numbers, MPFR Basics @comment node-name, next, previous, up @@ -1581,7 +1585,8 @@ respectively @code{unsigned long}, @code{long}, @code{unsigned int}, @deftypefunx int mpfr_add_z (mpfr_t @var{rop}, mpfr_t @var{op1}, mpz_t @var{op2}, mpfr_rnd_t @var{rnd}) @deftypefunx int mpfr_add_q (mpfr_t @var{rop}, mpfr_t @var{op1}, mpq_t @var{op2}, mpfr_rnd_t @var{rnd}) Set @var{rop} to @math{@var{op1} + @var{op2}} rounded in the direction -@var{rnd}. For types having no signed zero, it is considered unsigned +@var{rnd}. The IEEE-754 rules are used, in particular for signed zeros. +But for types having no signed zeros, 0 is considered unsigned (i.e., (+0) + 0 = (+0) and (@minus{}0) + 0 = (@minus{}0)). The @code{mpfr_add_d} function assumes that the radix of the @code{double} type is a power of 2, with a precision at most that declared by the C implementation @@ -1599,7 +1604,8 @@ is a power of 2, with a precision at most that declared by the C implementation @deftypefunx int mpfr_sub_z (mpfr_t @var{rop}, mpfr_t @var{op1}, mpz_t @var{op2}, mpfr_rnd_t @var{rnd}) @deftypefunx int mpfr_sub_q (mpfr_t @var{rop}, mpfr_t @var{op1}, mpq_t @var{op2}, mpfr_rnd_t @var{rnd}) Set @var{rop} to @math{@var{op1} - @var{op2}} rounded in the direction -@var{rnd}. For types having no signed zero, it is considered unsigned +@var{rnd}. The IEEE-754 rules are used, in particular for signed zeros. +But for types having no signed zeros, 0 is considered unsigned (i.e., (+0) @minus{} 0 = (+0), (@minus{}0) @minus{} 0 = (@minus{}0), 0 @minus{} (+0) = (@minus{}0) and 0 @minus{} (@minus{}0) = (+0)). The same restrictions than for @code{mpfr_add_d} apply to @code{mpfr_d_sub} @@ -1615,7 +1621,7 @@ and @code{mpfr_sub_d}. Set @var{rop} to @math{@var{op1} @GMPtimes{} @var{op2}} rounded in the direction @var{rnd}. When a result is zero, its sign is the product of the signs of the operands -(for types having no signed zero, it is considered positive). +(for types having no signed zeros, 0 is considered positive). The same restrictions than for @code{mpfr_add_d} apply to @code{mpfr_mul_d}. @end deftypefun @@ -1635,7 +1641,7 @@ rounded in the direction @var{rnd}. @deftypefunx int mpfr_div_q (mpfr_t @var{rop}, mpfr_t @var{op1}, mpq_t @var{op2}, mpfr_rnd_t @var{rnd}) Set @var{rop} to @math{@var{op1}/@var{op2}} rounded in the direction @var{rnd}. When a result is zero, its sign is the product of the signs of the operands -(for types having no signed zero, it is considered positive). +(for types having no signed zeros, 0 is considered positive). The same restrictions than for @code{mpfr_add_d} apply to @code{mpfr_d_div} and @code{mpfr_div_d}. @end deftypefun @@ -1643,15 +1649,18 @@ and @code{mpfr_div_d}. @deftypefun int mpfr_sqrt (mpfr_t @var{rop}, mpfr_t @var{op}, mpfr_rnd_t @var{rnd}) @deftypefunx int mpfr_sqrt_ui (mpfr_t @var{rop}, unsigned long int @var{op}, mpfr_rnd_t @var{rnd}) Set @var{rop} to @m{\sqrt{@var{op}}, the square root of @var{op}} -rounded in the direction @var{rnd} (set @var{rop} to @minus{}0 if @var{op} is -@minus{}0, to be consistent with the IEEE 754 standard). +rounded in the direction @var{rnd}. Set @var{rop} to @minus{}0 if +@var{op} is @minus{}0, to be consistent with the IEEE 754 standard. Set @var{rop} to NaN if @var{op} is negative. @end deftypefun @deftypefun int mpfr_rec_sqrt (mpfr_t @var{rop}, mpfr_t @var{op}, mpfr_rnd_t @var{rnd}) Set @var{rop} to @m{1/\sqrt{@var{op}}, the reciprocal square root of @var{op}} -rounded in the direction @var{rnd}. Set @var{rop} to +Inf if @var{op} is -@pom{}0, +0 if @var{op} is +Inf, and NaN if @var{op} is negative. +rounded in the direction @var{rnd}. Set @var{rop} to +Inf if @var{op} is +@pom{}0, +0 if @var{op} is +Inf, and NaN if @var{op} is negative. Warning! +Therefore the result on @minus{}0 is different from the one of the rSqrt +function recommended by the IEEE 754-2008 standard (Section 9.2.1), which +is @minus{}Inf instead of +Inf. @end deftypefun @deftypefun int mpfr_cbrt (mpfr_t @var{rop}, mpfr_t @var{op}, mpfr_rnd_t @var{rnd}) @@ -1832,7 +1841,9 @@ Set @var{rop} to the natural logarithm of @var{op}, @m{\log_2 @var{op}, log2(@var{op})} or @m{\log_{10} @var{op}, log10(@var{op})}, respectively, rounded in the direction @var{rnd}. -Set @var{rop} to @minus{}Inf if @var{op} is @minus{}0 +Set @var{rop} to +0 if @var{op} is 1 (in all rounding modes), +for consistency with the ISO C99 and IEEE 754-2008 standards. +Set @var{rop} to @minus{}Inf if @var{op} is @pom{}0 (i.e., the sign of the zero has no influence on the result). @end deftypefun @@ -2003,8 +2014,11 @@ to NaN. @deftypefun int mpfr_lngamma (mpfr_t @var{rop}, mpfr_t @var{op}, mpfr_rnd_t @var{rnd}) Set @var{rop} to the value of the logarithm of the Gamma function on @var{op}, rounded in the direction @var{rnd}. -When @math{@minus{}2@var{k}@minus{}1 @le{} @var{op} @le{} @minus{}2@var{k}}, -@var{k} being a non-negative integer, @var{rop} is set to NaN. +When @var{op} is 1 or 2, set @var{rop} to +0 (in all rounding modes). +When @var{op} is an infinity or a nonpositive integer, set @var{rop} to +Inf, +following the general rules on special values. +When @math{@minus{}2@var{k}@minus{}1 < @var{op} < @minus{}2@var{k}}, +@var{k} being a nonnegative integer, set @var{rop} to NaN@. See also @code{mpfr_lgamma}. @end deftypefun @@ -2012,10 +2026,11 @@ See also @code{mpfr_lgamma}. Set @var{rop} to the value of the logarithm of the absolute value of the Gamma function on @var{op}, rounded in the direction @var{rnd}. The sign (1 or @minus{}1) of Gamma(@var{op}) is returned in the object pointed to -by @var{signp}. When @var{op} is an infinity or a non-positive integer, set -@var{rop} to +Inf. When @var{op} is NaN, @minus{}Inf or a negative integer, -*@var{signp} is undefined, and when @var{op} is @pom{}0, *@var{signp} is -the sign of the zero. +by @var{signp}. +When @var{op} is 1 or 2, set @var{rop} to +0 (in all rounding modes). +When @var{op} is an infinity or a nonpositive integer, set @var{rop} to +Inf. +When @var{op} is NaN, @minus{}Inf or a negative integer, *@var{signp} is +undefined, and when @var{op} is @pom{}0, *@var{signp} is the sign of the zero. @end deftypefun @deftypefun int mpfr_digamma (mpfr_t @var{rop}, mpfr_t @var{op}, mpfr_rnd_t @var{rnd}) @@ -2064,7 +2079,10 @@ or @minus{}Inf depending on the parity and sign of @var{n}. @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}) Set @var{rop} to @math{(@var{op1} @GMPtimes{} @var{op2}) + @var{op3}} (resp.@: @math{(@var{op1} @GMPtimes{} @var{op2}) - @var{op3}}) -rounded in the direction @var{rnd}. +rounded in the direction @var{rnd}. Concerning special values (signed zeros, +infinities, NaN), these functions behave like a multiplication followed by a +separate addition or subtraction. That is, the fused operation matters only +for rounding. @end deftypefun @deftypefun int mpfr_agm (mpfr_t @var{rop}, mpfr_t @var{op1}, mpfr_t @var{op2}, mpfr_rnd_t @var{rnd}) @@ -2089,8 +2107,8 @@ i.e., the square root of the sum of the squares of @var{x} and @var{y}, i.e., $\sqrt{x^2+y^2}$, @end tex rounded in the direction @var{rnd}. -Special values are handled as described in Section F.9.4.3 of -the ISO C99 and IEEE 754-2008 standards: +Special values are handled as described in the ISO C99 (Section F.9.4.3) +and IEEE 754-2008 (Section 9.2.1) standards: If @var{x} or @var{y} is an infinity, then +Inf is returned in @var{rop}, even if the other number is NaN. @end deftypefun |