summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorenge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2012-07-05 09:15:58 +0000
committerenge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2012-07-05 09:15:58 +0000
commit119e389660b9d5d9d9e05a49df08cbcae0011946 (patch)
treec922d8ca3d54ff64ea5e24cfb8dbd986bc006a36
parent47dc25b9ec0c8b8583339a51eaa50b81fc5bfa87 (diff)
downloadmpc-119e389660b9d5d9d9e05a49df08cbcae0011946.tar.gz
new functions mul_2si, div_2si
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@1226 211d60ee-9f03-0410-a15a-8952a2c7a4e4
-rw-r--r--NEWS2
-rw-r--r--TODO3
-rw-r--r--doc/mpc.texi6
-rw-r--r--src/Makefile.am9
-rw-r--r--src/div_2si.c32
-rw-r--r--src/div_2ui.c4
-rw-r--r--src/mpc.h2
-rw-r--r--src/mul_2si.c32
-rw-r--r--src/mul_2ui.c4
-rw-r--r--tests/Makefile.am7
-rw-r--r--tests/tdiv_2si.c35
-rw-r--r--tests/tdiv_2ui.c2
-rw-r--r--tests/tmul_2si.c35
-rw-r--r--tests/tmul_2ui.c2
14 files changed, 159 insertions, 16 deletions
diff --git a/NEWS b/NEWS
index fbef739..73c69eb 100644
--- a/NEWS
+++ b/NEWS
@@ -6,7 +6,7 @@ Changes in version 1.0:
- 0^0, which returned (NaN,NaN) previously, now returns (1,+0).
- Removed compatibility with K&R compilers, untestable due to lack of
such compilers
- - New function mpc_log10.
+ - New functions: mpc_log10, mpc_mul_2si, mpc_div_2si
- Optimisation:
- fma
- Bug fixes:
diff --git a/TODO b/TODO
index 498e0fa..42d94b4 100644
--- a/TODO
+++ b/TODO
@@ -13,6 +13,9 @@ get_version.c and update mpc.h.
Use MPFR_RND? instead of GMP_RND?, and remove workarounds for MPFR_RNDA from
mpc-impl.h.
+From Andreas Enge 05 July 2012:
+Add support for rounding mode MPFR_RNDA.
+
Bench:
- from Andreas Enge 9 June 2009:
Scripts and web page comparing timings with different systems,
diff --git a/doc/mpc.texi b/doc/mpc.texi
index f43b297..45e921d 100644
--- a/doc/mpc.texi
+++ b/doc/mpc.texi
@@ -913,15 +913,17 @@ rounded in the direction @var{rnd}.
@end deftypefun
@deftypefun int mpc_mul_2ui (mpc_t @var{rop}, mpc_t @var{op1}, unsigned long int @var{op2}, mpc_rnd_t @var{rnd})
+@deftypefunx int mpc_mul_2si (mpc_t @var{rop}, mpc_t @var{op1}, long int @var{op2}, mpc_rnd_t @var{rnd})
Set @var{rop} to @var{op1} times 2 raised to @var{op2}
-rounded according to @var{rnd}. Just increases the exponents
+rounded according to @var{rnd}. Just modifies the exponents
of the real and imaginary parts by @var{op2}
when @var{rop} and @var{op1} are identical.
@end deftypefun
@deftypefun int mpc_div_2ui (mpc_t @var{rop}, mpc_t @var{op1}, unsigned long int @var{op2}, mpc_rnd_t @var{rnd})
+@deftypefunx int mpc_div_2ui (mpc_t @var{rop}, mpc_t @var{op1}, long int @var{op2}, mpc_rnd_t @var{rnd})
Set @var{rop} to @var{op1} divided by 2 raised to @var{op2}
-rounded according to @var{rnd}. Just decreases the exponents
+rounded according to @var{rnd}. Just modifies the exponents
of the real and imaginary parts by @var{op2}
when @var{rop} and @var{op1} are identical.
@end deftypefun
diff --git a/src/Makefile.am b/src/Makefile.am
index 03f7de7..7514ed5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -21,10 +21,11 @@ lib_LTLIBRARIES = libmpc.la
libmpc_la_LDFLAGS = $(MPC_LDFLAGS) -version-info 2:0:0
libmpc_la_SOURCES = mpc-impl.h abs.c acos.c acosh.c add.c add_fr.c \
add_si.c add_ui.c arg.c asin.c asinh.c atan.c atanh.c clear.c cmp.c \
- cmp_si_si.c conj.c cos.c cosh.c div_2ui.c div.c div_fr.c div_ui.c exp.c \
- fma.c fr_div.c fr_sub.c get_prec2.c get_prec.c get_version.c get_x.c \
- imag.c init2.c init3.c inp_str.c log.c log10.c mem.c mul_2ui.c mul.c \
- mul_fr.c mul_i.c mul_si.c mul_ui.c neg.c norm.c out_str.c pow.c pow_fr.c \
+ cmp_si_si.c conj.c cos.c cosh.c div_2si.c div_2ui.c div.c div_fr.c \
+ div_ui.c exp.c fma.c fr_div.c fr_sub.c get_prec2.c get_prec.c \
+ get_version.c get_x.c imag.c init2.c init3.c inp_str.c log.c log10.c \
+ mem.c mul_2si.c mul_2ui.c mul.c mul_fr.c mul_i.c mul_si.c mul_ui.c \
+ neg.c norm.c out_str.c pow.c pow_fr.c \
pow_ld.c pow_d.c pow_si.c pow_ui.c pow_z.c proj.c real.c urandom.c set.c \
set_prec.c set_str.c set_x.c set_x_x.c sin.c sin_cos.c sinh.c sqr.c \
sqrt.c strtoc.c sub.c sub_fr.c sub_ui.c swap.c tan.c tanh.c uceil_log2.c \
diff --git a/src/div_2si.c b/src/div_2si.c
new file mode 100644
index 0000000..511f2cb
--- /dev/null
+++ b/src/div_2si.c
@@ -0,0 +1,32 @@
+/* mpc_div_2si -- Divide a complex number by 2^e.
+
+Copyright (C) 2012 INRIA
+
+This file is part of GNU MPC.
+
+GNU MPC is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
+more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see http://www.gnu.org/licenses/ .
+*/
+
+#include "mpc-impl.h"
+
+int
+mpc_div_2si (mpc_ptr a, mpc_srcptr b, long int c, mpc_rnd_t rnd)
+{
+ int inex_re, inex_im;
+
+ inex_re = mpfr_div_2si (mpc_realref(a), mpc_realref(b), c, MPC_RND_RE(rnd));
+ inex_im = mpfr_div_2si (mpc_imagref(a), mpc_imagref(b), c, MPC_RND_IM(rnd));
+
+ return MPC_INEX(inex_re, inex_im);
+}
diff --git a/src/div_2ui.c b/src/div_2ui.c
index 1319930..cd53855 100644
--- a/src/div_2ui.c
+++ b/src/div_2ui.c
@@ -25,8 +25,8 @@ mpc_div_2ui (mpc_ptr a, mpc_srcptr b, unsigned long int c, mpc_rnd_t rnd)
{
int inex_re, inex_im;
- inex_re = mpfr_div_2exp (mpc_realref(a), mpc_realref(b), c, MPC_RND_RE(rnd));
- inex_im = mpfr_div_2exp (mpc_imagref(a), mpc_imagref(b), c, MPC_RND_IM(rnd));
+ inex_re = mpfr_div_2ui (mpc_realref(a), mpc_realref(b), c, MPC_RND_RE(rnd));
+ inex_im = mpfr_div_2ui (mpc_imagref(a), mpc_imagref(b), c, MPC_RND_IM(rnd));
return MPC_INEX(inex_re, inex_im);
}
diff --git a/src/mpc.h b/src/mpc.h
index 3f2b56e..60ffaee 100644
--- a/src/mpc.h
+++ b/src/mpc.h
@@ -153,6 +153,8 @@ __MPC_DECLSPEC int mpc_div_ui (mpc_ptr, mpc_srcptr, unsigned long int, mpc_r
__MPC_DECLSPEC int mpc_ui_div (mpc_ptr, unsigned long int, mpc_srcptr, mpc_rnd_t);
__MPC_DECLSPEC int mpc_div_2ui (mpc_ptr, mpc_srcptr, unsigned long int, mpc_rnd_t);
__MPC_DECLSPEC int mpc_mul_2ui (mpc_ptr, mpc_srcptr, unsigned long int, mpc_rnd_t);
+__MPC_DECLSPEC int mpc_div_2si (mpc_ptr, mpc_srcptr, long int, mpc_rnd_t);
+__MPC_DECLSPEC int mpc_mul_2si (mpc_ptr, mpc_srcptr, long int, mpc_rnd_t);
__MPC_DECLSPEC int mpc_conj (mpc_ptr, mpc_srcptr, mpc_rnd_t);
__MPC_DECLSPEC int mpc_neg (mpc_ptr, mpc_srcptr, mpc_rnd_t);
__MPC_DECLSPEC int mpc_norm (mpfr_ptr, mpc_srcptr, mpfr_rnd_t);
diff --git a/src/mul_2si.c b/src/mul_2si.c
new file mode 100644
index 0000000..14d0ca2
--- /dev/null
+++ b/src/mul_2si.c
@@ -0,0 +1,32 @@
+/* mpc_mul_2si -- Multiply a complex number by 2^e.
+
+Copyright (C) 2012 INRIA
+
+This file is part of GNU MPC.
+
+GNU MPC is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
+more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see http://www.gnu.org/licenses/ .
+*/
+
+#include "mpc-impl.h"
+
+int
+mpc_mul_2si (mpc_ptr a, mpc_srcptr b, long int c, mpc_rnd_t rnd)
+{
+ int inex_re, inex_im;
+
+ inex_re = mpfr_mul_2si (mpc_realref(a), mpc_realref(b), c, MPC_RND_RE(rnd));
+ inex_im = mpfr_mul_2si (mpc_imagref(a), mpc_imagref(b), c, MPC_RND_IM(rnd));
+
+ return MPC_INEX(inex_re, inex_im);
+}
diff --git a/src/mul_2ui.c b/src/mul_2ui.c
index 7a6f1ec..46aa788 100644
--- a/src/mul_2ui.c
+++ b/src/mul_2ui.c
@@ -25,8 +25,8 @@ mpc_mul_2ui (mpc_ptr a, mpc_srcptr b, unsigned long int c, mpc_rnd_t rnd)
{
int inex_re, inex_im;
- inex_re = mpfr_mul_2exp (mpc_realref(a), mpc_realref(b), c, MPC_RND_RE(rnd));
- inex_im = mpfr_mul_2exp (mpc_imagref(a), mpc_imagref(b), c, MPC_RND_IM(rnd));
+ inex_re = mpfr_mul_2ui (mpc_realref(a), mpc_realref(b), c, MPC_RND_RE(rnd));
+ inex_im = mpfr_mul_2ui (mpc_imagref(a), mpc_imagref(b), c, MPC_RND_IM(rnd));
return MPC_INEX(inex_re, inex_im);
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 72ea589..8f193ed 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -28,9 +28,10 @@ AM_LDFLAGS = -no-install
LOADLIBES=$(DEFS) -I$(top_srcdir)/src -I$(top_builddir) $(CPPFLAGS) $(CFLAGS) -L$(top_builddir)/tests/.libs -lmpc-tests -lmpc -lm $(LIBS)
check_PROGRAMS = tabs tacos tacosh tadd tadd_fr tadd_si tadd_ui targ tasin \
-tasinh tatan tatanh tconj tcos tcosh tdiv tdiv_2ui tdiv_fr tdiv_ui texp tfma \
-tfr_div tfr_sub timag tio_str tlog tlog10 tmul tmul_2ui tmul_fr tmul_i \
-tmul_si tmul_ui tneg tnorm tpow tpow_ld tpow_d tpow_fr tpow_si tpow_ui tpow_z \
+tasinh tatan tatanh tconj tcos tcosh tdiv tdiv_2si tdiv_2ui tdiv_fr tdiv_ui \
+texp tfma tfr_div tfr_sub timag tio_str tlog tlog10 \
+tmul tmul_2ui tmul_2ui tmul_fr tmul_i tmul_si tmul_ui \
+tneg tnorm tpow tpow_ld tpow_d tpow_fr tpow_si tpow_ui tpow_z \
tprec tproj treal treimref tset tsin tsin_cos tsinh tsqr tsqrt tstrtoc tsub \
tsub_fr tsub_ui tswap ttan ttanh tui_div tui_ui_sub tget_version
diff --git a/tests/tdiv_2si.c b/tests/tdiv_2si.c
new file mode 100644
index 0000000..5046201
--- /dev/null
+++ b/tests/tdiv_2si.c
@@ -0,0 +1,35 @@
+/* tdiv_2si -- test file for mpc_div_2si.
+
+Copyright (C) 2012 INRIA
+
+This file is part of GNU MPC.
+
+GNU MPC is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
+more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see http://www.gnu.org/licenses/ .
+*/
+
+#include "mpc-tests.h"
+
+int
+main (void)
+{
+ DECL_FUNC (CCS, f, mpc_div_2si);
+
+ test_start ();
+
+ tgeneric (f, 2, 1024, 7, -1);
+
+ test_end ();
+
+ return 0;
+}
diff --git a/tests/tdiv_2ui.c b/tests/tdiv_2ui.c
index 3a36ebd..6cc8f14 100644
--- a/tests/tdiv_2ui.c
+++ b/tests/tdiv_2ui.c
@@ -1,4 +1,4 @@
-/* tdiv_2exp -- test file for mpc_div_2exp.
+/* tdiv_2ui -- test file for mpc_div_2ui.
Copyright (C) 2008, 2012 INRIA
diff --git a/tests/tmul_2si.c b/tests/tmul_2si.c
new file mode 100644
index 0000000..bf86f18
--- /dev/null
+++ b/tests/tmul_2si.c
@@ -0,0 +1,35 @@
+/* tmul_2si -- test file for mpc_mul_2si.
+
+Copyright (C) 2012 INRIA
+
+This file is part of GNU MPC.
+
+GNU MPC is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
+more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program. If not, see http://www.gnu.org/licenses/ .
+*/
+
+#include "mpc-tests.h"
+
+int
+main (void)
+{
+ DECL_FUNC (CCS, f, mpc_mul_2si);
+
+ test_start ();
+
+ tgeneric (f, 2, 1024, 7, -1);
+
+ test_end ();
+
+ return 0;
+}
diff --git a/tests/tmul_2ui.c b/tests/tmul_2ui.c
index 7f6ec48..97073db 100644
--- a/tests/tmul_2ui.c
+++ b/tests/tmul_2ui.c
@@ -1,4 +1,4 @@
-/* tmul_2exp -- test file for mpc_mul_2exp.
+/* tmul_2ui -- test file for mpc_mul_2ui.
Copyright (C) 2008, 2012 INRIA