From 119e389660b9d5d9d9e05a49df08cbcae0011946 Mon Sep 17 00:00:00 2001 From: enge Date: Thu, 5 Jul 2012 09:15:58 +0000 Subject: new functions mul_2si, div_2si git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@1226 211d60ee-9f03-0410-a15a-8952a2c7a4e4 --- src/Makefile.am | 9 +++++---- src/div_2si.c | 32 ++++++++++++++++++++++++++++++++ src/div_2ui.c | 4 ++-- src/mpc.h | 2 ++ src/mul_2si.c | 32 ++++++++++++++++++++++++++++++++ src/mul_2ui.c | 4 ++-- 6 files changed, 75 insertions(+), 8 deletions(-) create mode 100644 src/div_2si.c create mode 100644 src/mul_2si.c (limited to 'src') 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); } -- cgit v1.2.1