summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2013-11-07 14:30:26 +0000
committerthevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2013-11-07 14:30:26 +0000
commitbe01156bfd4e4f1517b4b7eaa177f54c7882e7ca (patch)
tree676dd055dd78a60d1a45e3dd758ca2d4e8bb2e6d
parentdc7baa6385e187ef5193663e0653a9db0d7f7879 (diff)
downloadmpc-be01156bfd4e4f1517b4b7eaa177f54c7882e7ca.tar.gz
Synchronize with r1329 from trunk.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/branches/benchs_tests@1330 211d60ee-9f03-0410-a15a-8952a2c7a4e4
-rw-r--r--NEWS2
-rw-r--r--TODO34
-rw-r--r--doc/mpc.texi26
-rw-r--r--src/atan.c10
-rw-r--r--src/exp.c3
-rw-r--r--src/mpc-impl.h2
-rw-r--r--src/mul.c2
-rw-r--r--src/pow.c2
-rw-r--r--src/tan.c2
-rw-r--r--tests/atan.dat12
-rw-r--r--tests/atanh.dat3
11 files changed, 66 insertions, 32 deletions
diff --git a/NEWS b/NEWS
index 96a6031..b754788 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@ Recent changes in the trunk:
- Minimally required library version: mpfr 3.0.0
Changes in version 1.0.2:
+ - Fixed mpc_atan, mpc_atanh for (+-0, +-1), see
+ http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57994#c7
- Fixed mpc_log10 for purely imaginary argument, see
http://lists.gforge.inria.fr/pipermail/mpc-discuss/2012-September/001208.html
diff --git a/TODO b/TODO
index 1b10204..4a7f47f 100644
--- a/TODO
+++ b/TODO
@@ -17,7 +17,39 @@ Add support for rounding mode MPFR_RNDA.
From Andreas Enge and Paul Zimmermann 6 July 2012:
Improve speed of Im (atan) for x+i*y with small y, for instance by using
-the Taylor series directly.
+the Taylor series directly. See also the discussion
+http://lists.gforge.inria.fr/pipermail/mpc-discuss/2012-August/001196.html
+and the timing program on
+http://lists.gforge.inria.fr/pipermail/mpc-discuss/2013-August/001254.html
+
+For example with Sage 5.11:
+sage: %timeit atan(MPComplexField()(1,1))
+10000 loops, best of 3: 42.2 us per loop
+sage: %timeit atan(MPComplexField()(1,1e-1000))
+100 loops, best of 3: 5.29 ms per loop
+
+Same for asin:
+sage: %timeit asin(MPComplexField()(1,1))
+10000 loops, best of 3: 83.7 us per loop
+sage: %timeit asin(MPComplexField()(1,1e-1000))
+100 loops, best of 3: 17 ms per loop
+
+Same for acos:
+sage: %timeit acos(MPComplexField()(1,1))
+10000 loops, best of 3: 90.8 us per loop
+sage: %timeit acos(MPComplexField()(1,1e-1000))
+1 loops, best of 3: 2.29 s per loop
+
+Same for asinh:
+sage: %timeit asinh(MPComplexField()(1,1))
+10000 loops, best of 3: 84 us per loop
+sage: %timeit asinh(MPComplexField()(1,1e-1000))
+100 loops, best of 3: 2.1 ms per loop
+
+sage: %timeit acosh(MPComplexField()(1,1))
+10000 loops, best of 3: 92 us per loop
+sage: %timeit acosh(MPComplexField()(1,1e-1000))
+1 loops, best of 3: 2.28 s per loop
Bench:
- from Andreas Enge 9 June 2009:
diff --git a/doc/mpc.texi b/doc/mpc.texi
index 33f1b03..ccb338b 100644
--- a/doc/mpc.texi
+++ b/doc/mpc.texi
@@ -375,23 +375,23 @@ This
computes the square of @var{x} with rounding mode @code{rnd_mode}
and puts the result back in @var{x}.
-Before you can assign to an GNU MPC variable, you need to initialize it by calling
+Before you can assign to an GNU MPC variable, you need to initialise it by calling
one of the special initialization functions. When you are done with a
variable, you need to clear it out, using one of the functions for that
purpose.
-A variable should only be initialized once, or at least cleared out between
-each initialization. After a variable has been initialized, it may be
+A variable should only be initialised once, or at least cleared out between
+each initialization. After a variable has been initialised, it may be
assigned to any number of times.
-For efficiency reasons, avoid to initialize and clear out a variable in loops.
-Instead, initialize it before entering the loop, and clear it out after the
+For efficiency reasons, avoid to initialise and clear out a variable in loops.
+Instead, initialise it before entering the loop, and clear it out after the
loop has exited.
You do not need to be concerned about allocating additional space for GNU MPC
variables, since each of its real and imaginary part
has a mantissa of fixed size.
-Hence unless you change its precision, or clear and reinitialize it,
+Hence unless you change its precision, or clear and reinitialise it,
a complex variable will have the same allocated space during all its
life.
@@ -486,19 +486,19 @@ different word size.
@node Initializing Complex Numbers
@section Initialization Functions
-An @code{mpc_t} object must be initialized before storing the first value in
+An @code{mpc_t} object must be initialised before storing the first value in
it. The functions @code{mpc_init2} and @code{mpc_init3}
are used for that purpose.
@deftypefun void mpc_init2 (mpc_t @var{z}, mpfr_prec_t @var{prec})
-Initialize @var{z} to precision @var{prec} bits
+Initialise @var{z} to precision @var{prec} bits
and set its real and imaginary parts to NaN.
-Normally, a variable should be initialized once only
+Normally, a variable should be initialised once only
or at least be cleared, using @code{mpc_clear}, between initializations.
@end deftypefun
@deftypefun void mpc_init3 (mpc_t @var{z}, mpfr_prec_t @var{prec_r}, mpfr_prec_t @var{prec_i})
-Initialize @var{z} with the precision of its real part being
+Initialise @var{z} with the precision of its real part being
@var{prec_r} bits and the precision of its imaginary part being
@var{prec_i} bits, and set the real and imaginary parts to NaN.
@end deftypefun
@@ -509,7 +509,7 @@ Free the space occupied by @var{z}. Make sure to call this function for all
@end deftypefun
@need 2000
-Here is an example on how to initialize complex variables:
+Here is an example on how to initialise complex variables:
@example
@{
mpc_t x, y;
@@ -550,7 +550,7 @@ via @var{pi}.
@section Assignment Functions
@cindex Complex assignment functions
-These functions assign new values to already initialized complex numbers
+These functions assign new values to already initialised complex numbers
(@pxref{Initializing Complex Numbers}).
When using any functions with @code{intmax_t} or @code{uintmax_t}
parameters, you must include
@@ -751,7 +751,7 @@ of ascii letters, digits or @code{'_'}.
For instance, upon input of @code{"nan(13 1)"}, the function
@code{mpc_inp_str} starts to recognise a value of NaN followed by an
n-char-sequence indicated by the opening parenthesis; as soon as the
-space is reached, it becocmes clear that the expression in parentheses
+space is reached, it becomes clear that the expression in parentheses
is not an n-char-sequence, and the error flag -1 is returned after 6
characters have been consumed from the stream (the whitespace itself
remaining in the stream).
diff --git a/src/atan.c b/src/atan.c
index 70e1726..b962955 100644
--- a/src/atan.c
+++ b/src/atan.c
@@ -1,6 +1,6 @@
/* mpc_atan -- arctangent of a complex number.
-Copyright (C) 2009, 2010, 2011, 2012 INRIA
+Copyright (C) 2009, 2010, 2011, 2012, 2013 INRIA
This file is part of GNU MPC.
@@ -133,10 +133,10 @@ mpc_atan (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd)
}
else if (cmp_1 == 0)
{
- /* atan(+/-0+i) = NaN +i*inf
- atan(+/-0-i) = NaN -i*inf */
- mpfr_set_nan (mpc_realref (rop));
- mpfr_set_inf (mpc_imagref (rop), s_im ? -1 : +1);
+ /* atan(+/-0 +i) = +/-0 +i*inf
+ atan(+/-0 -i) = +/-0 -i*inf */
+ mpfr_set_zero (mpc_realref (rop), s_re ? -1 : +1);
+ mpfr_set_inf (mpc_imagref (rop), s_im ? -1 : +1);
}
else
{
diff --git a/src/exp.c b/src/exp.c
index 06faff3..f117a08 100644
--- a/src/exp.c
+++ b/src/exp.c
@@ -94,8 +94,9 @@ mpc_exp (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd)
if (mpfr_inf_p (mpc_imagref (op)))
{
+ int real_sign = mpfr_signbit (mpc_realref (op));
inex_re = mpfr_set (mpc_realref (rop), n, MPFR_RNDN);
- if (mpfr_signbit (mpc_realref (op)))
+ if (real_sign)
inex_im = mpfr_set (mpc_imagref (rop), n, MPFR_RNDN);
else
{
diff --git a/src/mpc-impl.h b/src/mpc-impl.h
index 5664955..f8001cd 100644
--- a/src/mpc-impl.h
+++ b/src/mpc-impl.h
@@ -62,7 +62,7 @@ along with this program. If not, see http://www.gnu.org/licenses/ .
/* work around spurious signs in nan */
#define MPFR_ADD_ONE_ULP(x) mpfr_add_one_ulp (x, MPFR_RNDN)
#define MPFR_SUB_ONE_ULP(x) mpfr_sub_one_ulp (x, MPFR_RNDN)
- /* drop unused rounding mode from macroes */
+ /* drop unused rounding mode from macros */
#define MPFR_SWAP(a,b) do { mpfr_srcptr tmp; tmp = a; a = b; b = tmp; } while (0)
diff --git a/src/mul.c b/src/mul.c
index 3927888..73c581d 100644
--- a/src/mul.c
+++ b/src/mul.c
@@ -43,7 +43,7 @@ mul_infinite (mpc_ptr z, mpc_srcptr x, mpc_srcptr y)
/* compute the sign of
u = xrs * yrs * xr * yr - xis * yis * xi * yi
v = xrs * yis * xr * yi + xis * yrs * xi * yr
- +1 if positive, -1 if negatiye, 0 if NaN */
+ +1 if positive, -1 if negative, 0 if NaN */
if ( mpfr_nan_p (mpc_realref (x)) || mpfr_nan_p (mpc_imagref (x))
|| mpfr_nan_p (mpc_realref (y)) || mpfr_nan_p (mpc_imagref (y))) {
u = 0;
diff --git a/src/pow.c b/src/pow.c
index 4b394ea..5a2b819 100644
--- a/src/pow.c
+++ b/src/pow.c
@@ -659,7 +659,7 @@ mpc_pow (mpc_ptr z, mpc_srcptr x, mpc_srcptr y, mpc_rnd_t rnd)
int ret_exp;
mpfr_exp_t dr, di;
mpfr_prec_t q=0;
- /* to avoid warning message, real initialisation below */
+ /* to avoid warning message, real initialization below */
mpc_log (t, x, MPC_RNDNN);
mpc_mul (t, t, y, MPC_RNDNN);
diff --git a/src/tan.c b/src/tan.c
index 0764db8..ce73621 100644
--- a/src/tan.c
+++ b/src/tan.c
@@ -237,7 +237,7 @@ mpc_tan (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd)
inex = mpc_div (x, x, y, MPC_RNDZZ);
/* OP is no pure real nor pure imaginary, so in theory the real and
imaginary parts of its tangent cannot be null. However due to
- rouding errors this might happen. Consider for example
+ rounding errors this might happen. Consider for example
tan(1+14*I) = 1.26e-10 + 1.00*I. For small precision sin(op) and
cos(op) differ only by a factor I, thus after mpc_div x = I and
its real part is zero. */
diff --git a/tests/atan.dat b/tests/atan.dat
index f3ba3ec..871f706 100644
--- a/tests/atan.dat
+++ b/tests/atan.dat
@@ -1,6 +1,6 @@
# Data file for mpc_atan.
#
-# Copyright (C) 2009, 2012 INRIA
+# Copyright (C) 2009, 2012, 2013 INRIA
#
# This file is part of GNU MPC.
#
@@ -113,8 +113,8 @@
- + 53 +0x1921FB54442D18p-52 53 -0x1269621134DB92p-55 53 +0 53 -7 N N
+ + 53 -0x1921FB54442D18p-52 53 -0x19C041F7ED8D33p-53 53 -0 53 -1.5 N N
- + 53 +0x1921FB54442D18p-52 53 -0x19C041F7ED8D33p-53 53 +0 53 -1.5 N N
-0 0 53 nan 53 -inf 53 -0 53 -1 N N
-0 0 53 nan 53 -inf 53 +0 53 -1 N N
+0 0 53 -0 53 -inf 53 -0 53 -1 N N
+0 0 53 +0 53 -inf 53 +0 53 -1 N N
0 + 53 -0 53 -0x15AA16394D481Fp-52 53 -0 53 -0.875 N N
0 + 53 +0 53 -0x15AA16394D481Fp-52 53 +0 53 -0.875 N N
0 + 53 -0 53 -0x1015891C9EAEF7p-55 53 -0 53 -0.125 N N
@@ -123,15 +123,13 @@
0 - 53 -0 53 +0x1015891C9EAEF7p-55 53 -0 53 +0.125 N N
0 - 53 +0 53 +0x15AA16394D481Fp-52 53 +0 53 +0.875 N N
0 - 53 -0 53 +0x15AA16394D481Fp-52 53 -0 53 +0.875 N N
-0 0 53 nan 53 +inf 53 +0 53 +1 N N
-0 0 53 nan 53 +inf 53 -0 53 +1 N N
+0 0 53 +0 53 +inf 53 +0 53 +1 N N
+0 0 53 -0 53 +inf 53 -0 53 +1 N N
- - 53 +0x1921FB54442D18p-52 53 +0x19C041F7ED8D33p-53 53 +0 53 +1.5 N N
+ - 53 -0x1921FB54442D18p-52 53 +0x19C041F7ED8D33p-53 53 -0 53 +1.5 N N
- - 53 +0x1921FB54442D18p-52 53 +0x1269621134DB92p-55 53 +0 53 +7 N N
+ - 53 -0x1921FB54442D18p-52 53 +0x1269621134DB92p-55 53 -0 53 +7 N N
0 + 53 +0 53 0x1FFFFFFFFFFF82p-52 53 +0 53 0x1ED9505E1BC3C2p-53 N N
-0 0 53 nan 53 -inf 53 +0 53 -1 N N
-0 0 53 nan 53 +inf 53 +0 53 +1 N N
+ - 512 0x6487ED5110B4611A62633145C06E0E68948127044533E63A0105DF531D89CD9128A5043CC71A026EF7CA8CD9E69D218D98158536F92F8A1BA7F09AB6B6A8E123p-510 512 0x5D137113B914461DA3202D77346EE4980DA5FD0BAD68F5A7928DCA9F632750D9BFFA00654C523929F15DED554EC6BC476DB2C46FA433E569227085E0BDEA86FFp-509 512 0 512 0x1018734E311AB77B710F9212969B3C86E8F388BB7DA5BAF74ADE078F43D96456D088C8A0B2A370159DFB8D4A4BC51BCDA91F2DCD01B2EC610C62AA33FAD1688p-504 N Z
+ - 12 0xC91p-11 12 0x6F1p-50 12 +0 12 0x9380000000 N N
diff --git a/tests/atanh.dat b/tests/atanh.dat
index b0f9977..c6517a8 100644
--- a/tests/atanh.dat
+++ b/tests/atanh.dat
@@ -1,6 +1,6 @@
# Data file for mpc_atanh.
#
-# Copyright (C) 2009 INRIA
+# Copyright (C) 2009, 2013 INRIA
#
# This file is part of GNU MPC.
#
@@ -85,6 +85,7 @@
0 0 53 nan 53 nan 53 nan 53 +1 N N
0 - 53 0 53 +0x1921FB54442D18p-52 53 nan 53 +inf N N
0 0 53 nan 53 nan 53 nan 53 nan N N
+0 0 53 +inf 53 +0 53 1 53 +0 N N
# pure real argument
- + 53 -0x1E27076E2AF2E6p-57 53 -0x1921FB54442D18p-52 53 -17 53 -0 N N