diff options
author | zimmerma <zimmerma@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2005-04-21 06:19:55 +0000 |
---|---|---|
committer | zimmerma <zimmerma@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2005-04-21 06:19:55 +0000 |
commit | c5363efca4c4acd3f6535df6b3db06b1c949f164 (patch) | |
tree | 1b50dfdcbed92924b7a0b9388743318adaaddfc3 | |
parent | 85a425e3fe604b227833f9d178e502ef49af40cf (diff) | |
download | mpc-c5363efca4c4acd3f6535df6b3db06b1c949f164.tar.gz |
use mpfr_sqr (a, b, r) instead of mpfr_mul (a, b, b, r)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@37 211d60ee-9f03-0410-a15a-8952a2c7a4e4
-rw-r--r-- | abs.c | 12 | ||||
-rw-r--r-- | norm.c | 8 | ||||
-rw-r--r-- | sqr.c | 5 |
3 files changed, 12 insertions, 13 deletions
@@ -45,8 +45,8 @@ mpc_abs_basic (mpfr_ptr a, mpc_srcptr b, mp_rnd_t rnd) mpfr_set_prec (v, prec); /* first compute norm(b)^2 */ - inexact = mpfr_mul (u, MPC_RE(b), MPC_RE(b), GMP_RNDU); /* err<=1ulp */ - inexact |= mpfr_mul (v, MPC_IM(b), MPC_IM(b), GMP_RNDU); /* err<=1ulp*/ + inexact = mpfr_sqr (u, MPC_RE(b), GMP_RNDU); /* err<=1ulp */ + inexact |= mpfr_sqr (v, MPC_IM(b), GMP_RNDU); /* err<=1ulp*/ inexact |= mpfr_add (u, u, v, GMP_RNDU); /* err <= 3 ulps */ inexact |= mpfr_sqrt (u, u, GMP_RNDU); /* err <= 4 ulps */ @@ -124,7 +124,7 @@ mpc_abs (mpfr_ptr a, mpc_srcptr b, mp_rnd_t rnd) so we round towards infinity */ { inexact = 1; - mpfr_mul (u, MPC_IM (b), MPC_IM (b), GMP_RNDU); /* err <= 1 ulp */ + mpfr_sqr (u, MPC_IM (b), GMP_RNDU); /* err <= 1 ulp */ if (MPFR_SIGN (MPC_RE (b)) > 0) { mpfr_div (u, u, MPC_RE (b), GMP_RNDU); /* err <= 3 ulp */ @@ -144,7 +144,7 @@ mpc_abs (mpfr_ptr a, mpc_srcptr b, mp_rnd_t rnd) (signed long) prec) { inexact = 1; - mpfr_mul (u, MPC_RE (b), MPC_RE (b), GMP_RNDU); + mpfr_sqr (u, MPC_RE (b), GMP_RNDU); if (MPFR_SIGN (MPC_IM (b)) > 0) { mpfr_div (u, u, MPC_IM (b), GMP_RNDU); @@ -162,8 +162,8 @@ mpc_abs (mpfr_ptr a, mpc_srcptr b, mp_rnd_t rnd) else { /* first compute norm(b)^2 */ - inexact = mpfr_mul (u, MPC_RE(b), MPC_RE(b), GMP_RNDU); /* err<=1ulp */ - inexact |= mpfr_mul (v, MPC_IM(b), MPC_IM(b), GMP_RNDU); /* err<=1ulp*/ + inexact = mpfr_sqr (u, MPC_RE(b), GMP_RNDU); /* err<=1ulp */ + inexact |= mpfr_sqr (v, MPC_IM(b), GMP_RNDU); /* err<=1ulp*/ inexact |= mpfr_add (u, u, v, GMP_RNDU); /* err <= 3 ulps */ inexact |= mpfr_sqrt (u, u, GMP_RNDU); /* err <= 4 ulps */ } @@ -45,8 +45,8 @@ mpc_norm (mpfr_ptr a, mpc_srcptr b, mp_rnd_t rnd) { mpfr_set_prec (u, 2 * MPFR_PREC (MPC_RE (b))); mpfr_set_prec (v, 2 * MPFR_PREC (MPC_IM (b))); - mpfr_mul (u, MPC_RE (b), MPC_RE (b), GMP_RNDN); - mpfr_mul (v, MPC_IM (b), MPC_IM (b), GMP_RNDN); + mpfr_sqr (u, MPC_RE (b), GMP_RNDN); + mpfr_sqr (v, MPC_IM (b), GMP_RNDN); inexact = mpfr_add (a, u, v, rnd); } else @@ -59,8 +59,8 @@ mpc_norm (mpfr_ptr a, mpc_srcptr b, mp_rnd_t rnd) mpfr_set_prec (v, prec); /* first compute norm(b)^2 */ - inexact = mpfr_mul (u, MPC_RE(b), MPC_RE(b), GMP_RNDN); /* err<=1/2ulp */ - inexact |= mpfr_mul (v, MPC_IM(b), MPC_IM(b), GMP_RNDN); /* err<=1/2ulp*/ + inexact = mpfr_sqr (u, MPC_RE(b), GMP_RNDN); /* err<=1/2ulp */ + inexact |= mpfr_sqr (v, MPC_IM(b), GMP_RNDN); /* err<=1/2ulp*/ inexact |= mpfr_add (u, u, v, GMP_RNDN); /* err <= 3/2 ulps */ } @@ -43,14 +43,13 @@ mpc_sqr (mpc_ptr a, mpc_srcptr b, mpc_rnd_t rnd) /* first check for real resp. purely imaginary number */ if (MPFR_IS_ZERO (MPC_IM(b))) { - inex_re = mpfr_mul (MPC_RE(a), MPC_RE(b), MPC_RE(b), MPC_RND_RE(rnd)); + inex_re = mpfr_sqr (MPC_RE(a), MPC_RE(b), MPC_RND_RE(rnd)); inex_im = mpfr_set_ui (MPC_IM(a), 0, GMP_RNDN); return MPC_INEX(inex_re, inex_im); } if (MPFR_IS_ZERO (MPC_RE(b))) { - inex_re = -mpfr_mul (MPC_RE(a), MPC_IM(b), MPC_IM(b), - INV_RND (MPC_RND_RE(rnd))); + inex_re = -mpfr_sqr (MPC_RE(a), MPC_IM(b), INV_RND (MPC_RND_RE(rnd))); mpfr_neg (MPC_RE(a), MPC_RE(a), GMP_RNDN); inex_im = mpfr_set_ui (MPC_IM(a), 0, GMP_RNDN); return MPC_INEX(inex_re, inex_im); |