summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorenge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2012-01-23 18:08:28 +0000
committerenge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2012-01-23 18:08:28 +0000
commit85c8e57d4cbbb5c24babdbf53a87a3ef40c43aea (patch)
tree4eec5e99ff6fcaddfae5f43cc302633ab37e00bf
parent04d836e20bad46104f9ff06c3bce5349dbfa362d (diff)
downloadmpc-85c8e57d4cbbb5c24babdbf53a87a3ef40c43aea.tar.gz
define 0^0 as (1,+0), since the sign of the imaginary part cannot be determined
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@1121 211d60ee-9f03-0410-a15a-8952a2c7a4e4
-rw-r--r--NEWS4
-rw-r--r--src/pow.c32
-rw-r--r--tests/pow.dat18
-rw-r--r--tests/pow_ui.dat6
4 files changed, 17 insertions, 43 deletions
diff --git a/NEWS b/NEWS
index b018daa..f4ca2d7 100644
--- a/NEWS
+++ b/NEWS
@@ -1,9 +1,7 @@
Changes in version 1.0:
- First release as a GNU package
- License change: LGPLv3+ for code, GFDLv1.3+ for documentation
- - 0^0, which returned (NaN,NaN) previously, now returns (1,0),
- with the sign of the imaginary part of the result being the opposite of
- the sign of the imaginary part of the exponent
+ - 0^0, which returned (NaN,NaN) previously, now returns (1,+0),
- Bug fixes:
- div and norm now return a value indicating the effective rounding
direction, as the other functions.
diff --git a/src/pow.c b/src/pow.c
index f6d54a8..3c4e8dc 100644
--- a/src/pow.c
+++ b/src/pow.c
@@ -1,6 +1,6 @@
/* mpc_pow -- Raise a complex number to the power of another complex number.
-Copyright (C) 2009, 2010, 2011 INRIA
+Copyright (C) 2009, 2010, 2011, 2012 INRIA
This file is part of GNU MPC.
@@ -491,34 +491,10 @@ mpc_pow (mpc_ptr z, mpc_srcptr x, mpc_srcptr y, mpc_rnd_t rnd)
{
if (x_real && mpfr_zero_p (mpc_realref(x)))
{
- /* we define 0^0 to be (1, -sign(Im(y))*0) since the real part is
+ /* we define 0^0 to be (1, +0) since the real part is
coherent with MPFR where 0^0 gives 1, and the sign of the
- imaginary part is the most frequent one obtained for random
- tiny x and y, for example with the following Sage program:
- D = dict()
- for sa in [-1,1]:
- for sb in [-1,1]:
- for sc in [-1,1]:
- for sd in [-1,1]:
- D[(sa,sb,sc,sd)] = [0,0]
- def tiny():
- return (random() - 0.5) * 1e-3
- for n in range(10^4):
- a = tiny()
- b = tiny()
- c = tiny()
- d = tiny()
- x = a+I*b
- y = c+I*d
- z = x^y
- t = sign(a),sign(b),sign(c),sign(d)
- if sign(z.imag()) == 1:
- D[t] = [D[t][0],D[t][1]+1]
- else:
- D[t] = [D[t][0]+1,D[t][1]] */
- mpfr_set_ui (mpc_realref(z), 1, GMP_RNDZ);
- mpfr_set_zero (mpc_imagref(z),
- mpfr_signbit (mpc_imagref(y)) ? 1 : -1);
+ imaginary part cannot be determined */
+ mpc_set_ui_ui (z, 1, 0, MPC_RNDNN);
return 0;
}
else /* x^0 = 1 +/- i*0 even for x=NaN see algorithms.tex for the
diff --git a/tests/pow.dat b/tests/pow.dat
index 6331496..9d14b5d 100644
--- a/tests/pow.dat
+++ b/tests/pow.dat
@@ -1,6 +1,6 @@
# Data file for mpc_pow.
#
-# Copyright (C) 2009 INRIA
+# Copyright (C) 2009, 2011, 2012 INRIA
#
# This file is part of GNU MPC.
#
@@ -133,14 +133,14 @@
0 0 53 0 53 0 53 -inf 53 -1 53 -inf 53 +1 N N
0 0 53 0 53 0 53 -inf 53 -1 53 -inf 53 -1 N N
-0 0 53 1 53 -0 53 +0 53 +0 53 +0 53 +0 N N
-0 0 53 1 53 -0 53 +0 53 +0 53 -0 53 +0 N N
-0 0 53 1 53 -0 53 +0 53 -0 53 +0 53 +0 N N
-0 0 53 1 53 -0 53 +0 53 -0 53 -0 53 +0 N N
-0 0 53 1 53 -0 53 -0 53 +0 53 +0 53 +0 N N
-0 0 53 1 53 -0 53 -0 53 +0 53 -0 53 +0 N N
-0 0 53 1 53 -0 53 -0 53 -0 53 +0 53 +0 N N
-0 0 53 1 53 -0 53 -0 53 -0 53 -0 53 +0 N N
+0 0 53 1 53 +0 53 +0 53 +0 53 +0 53 +0 N N
+0 0 53 1 53 +0 53 +0 53 +0 53 -0 53 +0 N N
+0 0 53 1 53 +0 53 +0 53 -0 53 +0 53 +0 N N
+0 0 53 1 53 +0 53 +0 53 -0 53 -0 53 +0 N N
+0 0 53 1 53 +0 53 -0 53 +0 53 +0 53 +0 N N
+0 0 53 1 53 +0 53 -0 53 +0 53 -0 53 +0 N N
+0 0 53 1 53 +0 53 -0 53 -0 53 +0 53 +0 N N
+0 0 53 1 53 +0 53 -0 53 -0 53 -0 53 +0 N N
0 0 53 1 53 +0 53 +0 53 +0 53 +0 53 -0 N N
0 0 53 1 53 +0 53 +0 53 +0 53 -0 53 -0 N N
0 0 53 1 53 +0 53 +0 53 -0 53 +0 53 -0 N N
diff --git a/tests/pow_ui.dat b/tests/pow_ui.dat
index 9ecde18..2a82700 100644
--- a/tests/pow_ui.dat
+++ b/tests/pow_ui.dat
@@ -1,6 +1,6 @@
# Data file for mpc_pow_ui.
#
-# Copyright (C) 2010, 2011 INRIA
+# Copyright (C) 2010, 2011, 2012 INRIA
#
# This file is part of GNU MPC.
#
@@ -34,8 +34,8 @@
0 0 53 +inf 53 nan 53 -inf 53 +1 +1 N N
0 0 53 +inf 53 nan 53 -inf 53 -1 +1 N N
-0 0 53 +1 53 -0 53 +0 53 +0 +0 N N
-0 0 53 0 53 0 53 +0 53 +0 +1 N N
+0 0 53 +1 53 +0 53 +0 53 +0 +0 N N
+0 0 53 +0 53 +0 53 +0 53 +0 +1 N N
0 0 53 +1 53 +0 53 +0 53 +1 +0 N N
0 0 53 +1 53 -0 53 +0 53 +1 +0 N D