summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorenge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2011-02-23 18:43:48 +0000
committerenge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2011-02-23 18:43:48 +0000
commitea00be676a5e57f8b5324ffc445bf622d712e1ca (patch)
tree02ad2a93d30c244aaa858aadaea5031287c0f0a5
parentbc86d84429d4659e5e0935e6ce62b6c83aba4971 (diff)
downloadmpc-ea00be676a5e57f8b5324ffc445bf622d712e1ca.tar.gz
proj.c: corrected (and simplified) infinite input with overlap
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@959 211d60ee-9f03-0410-a15a-8952a2c7a4e4
-rw-r--r--NEWS8
-rw-r--r--src/proj.c25
2 files changed, 13 insertions, 20 deletions
diff --git a/NEWS b/NEWS
index 4532eea..bb9ca90 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,9 @@
Recent changes:
- - Bug fix:
- mpc_mul returns correct results even if there are over- or underflows
- during the computation
+ - Bug fixes:
+ - mul now returns correct results even if there are over- or underflows
+ during the computation
+ - proj: wrong result when input variable has infinite part and equals
+ output variable
Changes in version 0.9:
- New functions:
diff --git a/src/proj.c b/src/proj.c
index b9d7940..f3aa4b5 100644
--- a/src/proj.c
+++ b/src/proj.c
@@ -1,6 +1,6 @@
/* mpc_proj -- projection of a complex number onto the Riemann sphere.
-Copyright (C) INRIA, 2008, 2009
+Copyright (C) INRIA, 2008, 2009, 2011
This file is part of the MPC Library.
@@ -24,21 +24,12 @@ MA 02111-1307, USA. */
int
mpc_proj (mpc_ptr a, mpc_srcptr b, mpc_rnd_t rnd)
{
- if (mpc_inf_p (b))
- {
- /* infinities projects to +Inf +i* copysign(0.0, cimag(z)) */
- int inex;
-
+ if (mpc_inf_p (b)) {
+ /* infinities project to +Inf +i* copysign(0.0, cimag(z)) */
mpfr_set_inf (MPC_RE (a), +1);
- inex = mpfr_set_ui (MPC_IM (a), 0, MPC_RND_IM (rnd));
- if (mpfr_signbit (MPC_IM (b)))
- {
- mpc_conj (a, a, MPC_RNDNN);
- inex = -inex;
- }
-
- return MPC_INEX (0, inex);
- }
- else
- return mpc_set (a, b, rnd);
+ mpfr_set_zero (MPC_IM (a), (mpfr_signbit (MPC_IM (b)) ? -1 : 1));
+ return MPC_INEX (0, 0);
+ }
+ else
+ return mpc_set (a, b, rnd);
}