diff options
author | enge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2011-02-23 18:43:48 +0000 |
---|---|---|
committer | enge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2011-02-23 18:43:48 +0000 |
commit | ea00be676a5e57f8b5324ffc445bf622d712e1ca (patch) | |
tree | 02ad2a93d30c244aaa858aadaea5031287c0f0a5 /src/proj.c | |
parent | bc86d84429d4659e5e0935e6ce62b6c83aba4971 (diff) | |
download | mpc-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
Diffstat (limited to 'src/proj.c')
-rw-r--r-- | src/proj.c | 25 |
1 files changed, 8 insertions, 17 deletions
@@ -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); } |