summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzimmerma <zimmerma@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2005-05-30 12:37:35 +0000
committerzimmerma <zimmerma@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2005-05-30 12:37:35 +0000
commit0478a7e772aa071643c236edb93288de5bd745ec (patch)
tree6a24f5423bc0b711d470a2646909c323f2711468
parentc5363efca4c4acd3f6535df6b3db06b1c949f164 (diff)
downloadmpc-0478a7e772aa071643c236edb93288de5bd745ec.tar.gz
added ui_sub and ui_ui_sub (contributed from Marc Helbling)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@38 211d60ee-9f03-0410-a15a-8952a2c7a4e4
-rw-r--r--makefile4
-rw-r--r--mpc.h2
-rw-r--r--mpc.texi5
-rw-r--r--ui_sub.c35
-rw-r--r--ui_ui_sub.c36
5 files changed, 80 insertions, 2 deletions
diff --git a/makefile b/makefile
index 92f9a0a..1e18a4f 100644
--- a/makefile
+++ b/makefile
@@ -41,8 +41,8 @@ VERSION=0.4.5
INCLUDES=-I. -I$(MPFR)/include -I$(GMP)/include
LIBS=$(MPFR)/lib/libmpfr.a $(GMP)/lib/libgmp.a
-OBJECTS= abs.o add.o add_fr.o add_ui.o clear.o cmp.o cmp_si_si.o conj.o div.o div_2exp.o div_fr.o div_ui.o exp.o init.o init2.o init3.o inp_str.o mul.o mul_2exp.o mul_fr.o mul_ui.o mul_si.o mul_i.o neg.o norm.o out_str.o random.o random2.o set.o set_d_d.o set_dfl_prec.o set_prec.o set_ui_fr.o set_si_si.o set_ui_ui.o sqr.o sqrt.o sub.o sub_ui.o ui_div.o uceil_log2.o
-SOURCES= abs.c add.c add_fr.c add_ui.c clear.c cmp.c cmp_si_si.c conj.c div.c div_2exp.c div_fr.c div_ui.c exp.c init.c init2.c init3.c inp_str.c mul.c mul_2exp.c mul_fr.c mul_ui.c mul_si.c mul_i.c neg.c norm.c out_str.c random.c random2.c set.c set_d_d.c set_dfl_prec.c set_prec.c set_ui_fr.c set_si_si.c set_ui_ui.c sqr.c sqrt.c sub.c sub_ui.c ui_div.c uceil_log2.c
+OBJECTS= abs.o add.o add_fr.o add_ui.o clear.o cmp.o cmp_si_si.o conj.o div.o div_2exp.o div_fr.o div_ui.o exp.o init.o init2.o init3.o inp_str.o mul.o mul_2exp.o mul_fr.o mul_ui.o mul_si.o mul_i.o neg.o norm.o out_str.o random.o random2.o set.o set_d_d.o set_dfl_prec.o set_prec.o set_ui_fr.o set_si_si.o set_ui_ui.o sqr.o sqrt.o sub.o sub_ui.o ui_div.o uceil_log2.o ui_sub.o ui_ui_sub.o
+SOURCES= abs.c add.c add_fr.c add_ui.c clear.c cmp.c cmp_si_si.c conj.c div.c div_2exp.c div_fr.c div_ui.c exp.c init.c init2.c init3.c inp_str.c mul.c mul_2exp.c mul_fr.c mul_ui.c mul_si.c mul_i.c neg.c norm.c out_str.c random.c random2.c set.c set_d_d.c set_dfl_prec.c set_prec.c set_ui_fr.c set_si_si.c set_ui_ui.c sqr.c sqrt.c sub.c sub_ui.c ui_div.c uceil_log2.c ui_sub.c ui_ui_sub.c
TESTS= test.c tmul.c tsqr.c tdiv.c texp.c
DIST= $(SOURCES) $(TESTS) makefile mpc.h mpc-impl.h COPYING.LIB mpc.texi INSTALL
diff --git a/mpc.h b/mpc.h
index edf6540..c569c78 100644
--- a/mpc.h
+++ b/mpc.h
@@ -105,6 +105,8 @@ int mpc_add_fr __MPC_PROTO ((mpc_ptr, mpc_srcptr, mpfr_srcptr, mpc_rnd_t));
int mpc_add_ui __MPC_PROTO ((mpc_ptr, mpc_srcptr, unsigned long int, mpc_rnd_t));
int mpc_sub __MPC_PROTO ((mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t));
int mpc_sub_ui __MPC_PROTO ((mpc_ptr, mpc_srcptr, unsigned long int, mpc_rnd_t));
+int mpc_ui_sub __MPC_PROTO ((mpc_ptr, unsigned long int, mpc_srcptr, mpc_rnd_t));
+int mpc_ui_ui_sub __MPC_PROTO ((mpc_ptr, unsigned long int, unsigned long int, mpc_srcptr, mpc_rnd_t));
int mpc_mul __MPC_PROTO ((mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t));
int mpc_mul_fr __MPC_PROTO ((mpc_ptr, mpc_srcptr, mpfr_srcptr, mpc_rnd_t));
int mpc_mul_ui __MPC_PROTO ((mpc_ptr, mpc_srcptr, unsigned long int, mpc_rnd_t));
diff --git a/mpc.texi b/mpc.texi
index a253378..01e45b4 100644
--- a/mpc.texi
+++ b/mpc.texi
@@ -591,7 +591,10 @@ Set @var{rop} to @var{op1} @math{+} @var{op2} rounded according to @var{rnd}.
@deftypefun int mpc_sub (mpc_t @var{rop}, mpc_t @var{op1}, mpc_t @var{op2}, mpc_rnd_t @var{rnd})
@deftypefunx int mpc_sub_ui (mpc_t @var{rop}, mpc_t @var{op1}, unsigned long int @var{op2}, mpc_rnd_t @var{rnd})
+@deftypefunx int mpc_ui_sub (mpc_t @var{rop}, unsigned long int @var{op1}, mpc_t @var{op2}, mpc_rnd_t @var{rnd})
+@deftypefunx int mpc_ui_ui_sub (mpc_t @var{rop}, unsigned long int @var{re1}, unsigned long int @var{im1}, mpc_t @var{op2}, mpc_rnd_t @var{rnd})
Set @var{rop} to @var{op1} @minus{} @var{op2} rounded according to @var{rnd}.
+For @code{mpc_ui_ui_sub}, @var{op1} is @var{re1} + @var{im1}.
@end deftypefun
@deftypefun int mpc_mul (mpc_t @var{rop}, mpc_t @var{op1}, mpc_t @var{op2}, mpc_rnd_t @var{rnd})
@@ -805,6 +808,8 @@ of the real and imaginary parts.
The main developers of the MPC library are Andreas Enge and
Paul Zimmermann. Patrick Pelissier has cleaned up the code.
+Marc Helbling contributed the @code{mpc_ui_sub} and
+@code{mpc_ui_ui_sub} functions.
@node References, Concept Index, Contributors, Top
@comment node-name, next, previous, up
diff --git a/ui_sub.c b/ui_sub.c
new file mode 100644
index 0000000..a4effc4
--- /dev/null
+++ b/ui_sub.c
@@ -0,0 +1,35 @@
+/* mpc_ui_sub -- Subtract a complex number from an unsigned long int.
+
+Copyright (C) 2005 Marc Helbling, 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 "gmp.h"
+#include "mpfr.h"
+#include "mpc.h"
+
+int
+mpc_ui_sub (mpc_ptr a, unsigned long int b, mpc_srcptr c, mpc_rnd_t rnd)
+{
+ int inex_re, inex_im;
+
+ inex_re = mpfr_ui_sub (MPC_RE (a), b, MPC_RE (c), MPC_RND_RE (rnd));
+ inex_im = mpfr_neg (MPC_IM (a), MPC_IM (c), MPC_RND_IM (rnd));
+
+ return MPC_INEX (inex_re, inex_im);
+}
diff --git a/ui_ui_sub.c b/ui_ui_sub.c
new file mode 100644
index 0000000..bf75f67
--- /dev/null
+++ b/ui_ui_sub.c
@@ -0,0 +1,36 @@
+/* mpc_ui_ui_sub -- Subtract a complex number from two unsigned long ints.
+
+Copyright (C) 2005 Marc Helbling, 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 "gmp.h"
+#include "mpfr.h"
+#include "mpc.h"
+
+int
+mpc_ui_ui_sub (mpc_ptr a, unsigned long int b, unsigned long int c,
+ mpc_srcptr d, mpc_rnd_t rnd)
+{
+ int inex_re, inex_im;
+
+ inex_re = mpfr_ui_sub (MPC_RE (a), b, MPC_RE (d), MPC_RND_RE (rnd));
+ inex_im = mpfr_ui_sub (MPC_IM (a), c, MPC_IM (d), MPC_RND_IM (rnd));
+
+ return MPC_INEX (inex_re, inex_im);
+}