From b7c13d52eee1c7946010f0a6aba28d22bc504008 Mon Sep 17 00:00:00 2001 From: zimmerma Date: Tue, 6 Mar 2012 20:51:08 +0000 Subject: [mul.c] don't call mpc_sqr any more when both inputs are the same variable [mpc.texi,NEWS] document the above change git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@1139 211d60ee-9f03-0410-a15a-8952a2c7a4e4 --- NEWS | 1 + doc/mpc.texi | 2 ++ src/mul.c | 6 ------ 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index f4ca2d7..00e7f30 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,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), + - mpc_mul no longer calls mpc_sqr when the two inputs are the same - Bug fixes: - div and norm now return a value indicating the effective rounding direction, as the other functions. diff --git a/doc/mpc.texi b/doc/mpc.texi index dfa74ec..acb4576 100644 --- a/doc/mpc.texi +++ b/doc/mpc.texi @@ -863,6 +863,8 @@ For @code{mpc_ui_ui_sub}, @var{op1} is @var{re1} + @var{im1}. @deftypefunx int mpc_mul_si (mpc_t @var{rop}, mpc_t @var{op1}, long int @var{op2}, mpc_rnd_t @var{rnd}) @deftypefunx int mpc_mul_fr (mpc_t @var{rop}, mpc_t @var{op1}, mpfr_t @var{op2}, mpc_rnd_t @var{rnd}) Set @var{rop} to @var{op1} times @var{op2} rounded according to @var{rnd}. +Note: for @code{mpc_mul}, in case @var{op1} and @var{op2} have the same value, +use @code{mpc_sqr} for better efficiency. @end deftypefun @deftypefun int mpc_mul_i (mpc_t @var{rop}, mpc_t @var{op}, int @var{sgn}, mpc_rnd_t @var{rnd}) diff --git a/src/mul.c b/src/mul.c index ead0087..2be9b8d 100644 --- a/src/mul.c +++ b/src/mul.c @@ -623,12 +623,6 @@ mpc_mul (mpc_ptr a, mpc_srcptr b, mpc_srcptr c, mpc_rnd_t rnd) if (mpfr_zero_p (mpc_realref (c))) return mul_imag (a, b, c, rnd); - /* Check if b==c and call mpc_sqr in this case, to make sure */ - /* mpc_mul(a,b,b) behaves exactly like mpc_sqr(a,b) concerning */ - /* internal overflows etc. */ - if (mpc_cmp (b, c) == 0) - return mpc_sqr (a, b, rnd); - /* If the real and imaginary part of one argument have a very different */ /* exponent, it is not reasonable to use Karatsuba multiplication. */ if ( SAFE_ABS (mpfr_exp_t, -- cgit v1.2.1