diff options
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | TODO | 6 | ||||
-rw-r--r-- | doc/mpc.texi | 9 | ||||
-rw-r--r-- | src/Makefile.am | 18 | ||||
-rw-r--r-- | src/mpc.h | 6 | ||||
-rw-r--r-- | src/pow_d.c | 36 | ||||
-rw-r--r-- | src/pow_fr.c | 38 | ||||
-rw-r--r-- | src/pow_ld.c | 38 | ||||
-rw-r--r-- | src/pow_si.c | 37 | ||||
-rw-r--r-- | src/pow_ui.c | 37 | ||||
-rw-r--r-- | src/pow_z.c | 36 |
11 files changed, 249 insertions, 15 deletions
@@ -1,6 +1,7 @@ Recent changes: - New functions: - - mpc_asin, mpc_acos, mpc_atan, mpc_asinh, mpc_acosh, mpc_atanh + - mpc_asin, mpc_acos, mpc_atan, mpc_asinh, mpc_acosh, mpc_atanh, + mpc_pow_d, mpc_pow_ld, mpc_pow_si, mpc_pow_ui, mpc_pow_z, mpc_pow_fr - Bug fixes: - ui_div: real divisor @@ -19,11 +19,7 @@ New functions to implement: mpc_sin_cos (needs mpfr_sinh_cosh) - from Mickael Gastineau <gastineau@imcce.fr> 14 Apr 2008: mpc_fma: d=a*b+c - - from Andreas Enge 9 April 2008: - mpc_pow_ui - Also add mpc_pow_z, _d, _ld, _si, _fr (K. Ghazi 17 Jun 2009)? - What about the mpc_foo_pow functions? - - from Kaveh Ghazi, 5 October 2009: mpc_pow_z (for fortran frontend) + - What about the mpc_foo_pow functions? - from Andreas Enge and Philippe Théveny 17 July 2008 agm (and complex logarithm with agm ?) - from Andreas Enge 25 June 2009: diff --git a/doc/mpc.texi b/doc/mpc.texi index 433962a..0d1b3c6 100644 --- a/doc/mpc.texi +++ b/doc/mpc.texi @@ -933,8 +933,17 @@ Set @var{rop} to the square root of @var{op} rounded according to @var{rnd}. @end deftypefun @deftypefun int mpc_pow (mpc_t @var{rop}, mpc_t @var{op1}, mpc_t @var{op2}, mpc_rnd_t @var{rnd}) +@deftypefunx int mpc_pow_d (mpc_t @var{rop}, mpc_t @var{op1}, double @var{op2}, mpc_rnd_t @var{rnd}) +@deftypefunx int mpc_pow_ld (mpc_t @var{rop}, mpc_t @var{op1}, long double @var{op2}, mpc_rnd_t @var{rnd}) +@deftypefunx int mpc_pow_si (mpc_t @var{rop}, mpc_t @var{op1}, long @var{op2}, mpc_rnd_t @var{rnd}) +@deftypefunx int mpc_pow_ui (mpc_t @var{rop}, mpc_t @var{op1}, unsigned long @var{op2}, mpc_rnd_t @var{rnd}) +@deftypefunx int mpc_pow_z (mpc_t @var{rop}, mpc_t @var{op1}, mpz_t @var{op2}, mpc_rnd_t @var{rnd}) +@deftypefunx int mpc_pow_fr (mpc_t @var{rop}, mpc_t @var{op1}, mpfr_t @var{op2}, mpc_rnd_t @var{rnd}) Set @var{rop} to @var{op1} raised to the power @var{op2}, rounded according to @var{rnd}. +For @code{mpc_pow_d}, @code{mpc_pow_ld}, @code{mpc_pow_si}, @code{mpc_pow_ui}, +@code{mpc_pow_z} and @code{mpc_pow_fr}, +the imaginary part of @var{op2} is considered as +0. @end deftypefun @deftypefun int mpc_exp (mpc_t @var{rop}, mpc_t @var{op}, mpc_rnd_t @var{rnd}) diff --git a/src/Makefile.am b/src/Makefile.am index 247cab6..d4bc8b2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,13 +3,13 @@ AM_CFLAGS=@WARNINGCFLAGS@ lib_LTLIBRARIES = libmpc.la libmpc_la_LDFLAGS = -version-info 2:0:0 -libmpc_la_SOURCES = mpc-impl.h abs.c acos.c acosh.c add.c add_fr.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_2exp.c div.c div_fr.c div_ui.c exp.c fr_div.c \ - fr_sub.c get_prec2.c get_prec.c get_str.c get_version.c imag.c init2.c \ - init3.c inp_str.c log.c mem.c mul_2exp.c mul.c mul_fr.c mul_i.c \ - mul_si.c mul_ui.c neg.c norm.c out_str.c pow.c proj.c real.c urandom.c \ - set.c set_prec.c set_str.c set_x.c set_x_x.c sin.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 \ - ui_div.c ui_ui_sub.c +libmpc_la_SOURCES = mpc-impl.h abs.c acos.c acosh.c add.c add_fr.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_2exp.c div.c div_fr.c div_ui.c exp.c fr_div.c \ + fr_sub.c get_prec2.c get_prec.c get_str.c get_version.c imag.c init2.c \ + init3.c inp_str.c log.c mem.c mul_2exp.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 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 ui_div.c ui_ui_sub.c @@ -144,6 +144,12 @@ __MPC_DECLSPEC int mpc_mul_i __MPC_PROTO ((mpc_ptr, mpc_srcptr, int, mpc_rnd_t __MPC_DECLSPEC int mpc_sqr __MPC_PROTO ((mpc_ptr, mpc_srcptr, mpc_rnd_t)); __MPC_DECLSPEC int mpc_div __MPC_PROTO ((mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t)); __MPC_DECLSPEC int mpc_pow __MPC_PROTO ((mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t)); +__MPC_DECLSPEC int mpc_pow_fr __MPC_PROTO ((mpc_ptr, mpc_srcptr, mpfr_srcptr, mpc_rnd_t)); +__MPC_DECLSPEC int mpc_pow_ld __MPC_PROTO ((mpc_ptr, mpc_srcptr, long double, mpc_rnd_t)); +__MPC_DECLSPEC int mpc_pow_d __MPC_PROTO ((mpc_ptr, mpc_srcptr, double, mpc_rnd_t)); +__MPC_DECLSPEC int mpc_pow_si __MPC_PROTO ((mpc_ptr, mpc_srcptr, long, mpc_rnd_t)); +__MPC_DECLSPEC int mpc_pow_ui __MPC_PROTO ((mpc_ptr, mpc_srcptr, unsigned long, mpc_rnd_t)); +__MPC_DECLSPEC int mpc_pow_z __MPC_PROTO ((mpc_ptr, mpc_srcptr, mpz_srcptr, mpc_rnd_t)); __MPC_DECLSPEC int mpc_div_fr __MPC_PROTO ((mpc_ptr, mpc_srcptr, mpfr_srcptr, mpc_rnd_t)); __MPC_DECLSPEC int mpc_fr_div __MPC_PROTO ((mpc_ptr, mpfr_srcptr, mpc_srcptr, mpc_rnd_t)); __MPC_DECLSPEC int mpc_div_ui __MPC_PROTO ((mpc_ptr, mpc_srcptr, unsigned long int, mpc_rnd_t)); diff --git a/src/pow_d.c b/src/pow_d.c new file mode 100644 index 0000000..db0d775 --- /dev/null +++ b/src/pow_d.c @@ -0,0 +1,36 @@ +/* mpc_pow_d -- Raise a complex number to a double-precision power. + +Copyright (C) 2009 Paul Zimmermann + +This file is part of the MPC Library. + +The MPC Library 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 2.1 of the License, or (at your +option) any later version. + +The MPC Library 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 the MPC Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +#include "mpc-impl.h" + +int +mpc_pow_d (mpc_ptr z, mpc_srcptr x, double y, mpc_rnd_t rnd) +{ + mpc_t yy; + int inex; + + mpc_init3 (yy, 53, MPFR_PREC_MIN); + mpc_set_d (yy, y, MPC_RNDNN); /* exact */ + inex = mpc_pow (z, x, yy, rnd); + mpc_clear (yy); + return inex; +} + diff --git a/src/pow_fr.c b/src/pow_fr.c new file mode 100644 index 0000000..c998060 --- /dev/null +++ b/src/pow_fr.c @@ -0,0 +1,38 @@ +/* mpc_pow_fr -- Raise a complex number to a floating-point power. + +Copyright (C) 2009 Paul Zimmermann + +This file is part of the MPC Library. + +The MPC Library 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 2.1 of the License, or (at your +option) any later version. + +The MPC Library 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 the MPC Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +#include "mpc-impl.h" + +int +mpc_pow_fr (mpc_ptr z, mpc_srcptr x, mpfr_srcptr y, mpc_rnd_t rnd) +{ + mpc_t yy; + int inex; + + /* avoid copying the significand of y by copying only the struct */ + MPC_RE(yy)[0] = y[0]; + mpfr_init2 (MPC_IM(yy), MPFR_PREC_MIN); + mpfr_set_ui (MPC_IM(yy), 0, GMP_RNDN); + inex = mpc_pow (z, x, yy, rnd); + mpfr_clear (MPC_IM(yy)); + return inex; +} + diff --git a/src/pow_ld.c b/src/pow_ld.c new file mode 100644 index 0000000..3bc83e2 --- /dev/null +++ b/src/pow_ld.c @@ -0,0 +1,38 @@ +/* mpc_pow_ld -- Raise a complex number to a long double power. + +Copyright (C) 2009 Paul Zimmermann + +This file is part of the MPC Library. + +The MPC Library 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 2.1 of the License, or (at your +option) any later version. + +The MPC Library 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 the MPC Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +#include "mpc-impl.h" + +int +mpc_pow_ld (mpc_ptr z, mpc_srcptr x, long double y, mpc_rnd_t rnd) +{ + mpc_t yy; + int inex; + + /* since logn double might be implemented with two 'double' on some + platforms, the resulting precision might be 2 * 53 + 1 or more */ + mpc_init3 (yy, 2 * 53 + 1, MPFR_PREC_MIN); + mpc_set_ld (yy, y, MPC_RNDNN); /* exact */ + inex = mpc_pow (z, x, yy, rnd); + mpc_clear (yy); + return inex; +} + diff --git a/src/pow_si.c b/src/pow_si.c new file mode 100644 index 0000000..0105b72 --- /dev/null +++ b/src/pow_si.c @@ -0,0 +1,37 @@ +/* mpc_pow_si -- Raise a complex number to an integer power. + +Copyright (C) 2009 Paul Zimmermann + +This file is part of the MPC Library. + +The MPC Library 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 2.1 of the License, or (at your +option) any later version. + +The MPC Library 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 the MPC Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +#include <limits.h> /* for CHAR_BIT */ +#include "mpc-impl.h" + +int +mpc_pow_si (mpc_ptr z, mpc_srcptr x, long y, mpc_rnd_t rnd) +{ + mpc_t yy; + int inex; + + mpc_init3 (yy, sizeof (unsigned long) * CHAR_BIT, MPFR_PREC_MIN); + mpc_set_si (yy, y, MPC_RNDNN); /* exact */ + inex = mpc_pow (z, x, yy, rnd); + mpc_clear (yy); + return inex; +} + diff --git a/src/pow_ui.c b/src/pow_ui.c new file mode 100644 index 0000000..1b3b10f --- /dev/null +++ b/src/pow_ui.c @@ -0,0 +1,37 @@ +/* mpc_pow_ui -- Raise a complex number to an integer power. + +Copyright (C) 2009 Paul Zimmermann + +This file is part of the MPC Library. + +The MPC Library 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 2.1 of the License, or (at your +option) any later version. + +The MPC Library 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 the MPC Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +#include <limits.h> /* for CHAR_BIT */ +#include "mpc-impl.h" + +int +mpc_pow_ui (mpc_ptr z, mpc_srcptr x, unsigned long y, mpc_rnd_t rnd) +{ + mpc_t yy; + int inex; + + mpc_init3 (yy, sizeof (unsigned long) * CHAR_BIT, MPFR_PREC_MIN); + mpc_set_ui (yy, y, MPC_RNDNN); /* exact */ + inex = mpc_pow (z, x, yy, rnd); + mpc_clear (yy); + return inex; +} + diff --git a/src/pow_z.c b/src/pow_z.c new file mode 100644 index 0000000..e4126ed --- /dev/null +++ b/src/pow_z.c @@ -0,0 +1,36 @@ +/* mpc_pow_z -- Raise a complex number to an integer power. + +Copyright (C) 2009 Paul Zimmermann + +This file is part of the MPC Library. + +The MPC Library 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 2.1 of the License, or (at your +option) any later version. + +The MPC Library 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 the MPC Library; see the file COPYING.LIB. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +MA 02111-1307, USA. */ + +#include "mpc-impl.h" + +int +mpc_pow_z (mpc_ptr z, mpc_srcptr x, mpz_srcptr y, mpc_rnd_t rnd) +{ + mpc_t yy; + int inex; + + mpc_init3 (yy, mpz_sizeinbase (y, 2), MPFR_PREC_MIN); + mpc_set_z (yy, y, MPC_RNDNN); /* exact */ + inex = mpc_pow (z, x, yy, rnd); + mpc_clear (yy); + return inex; +} + |