summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorenge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2005-02-03 15:05:08 +0000
committerenge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2005-02-03 15:05:08 +0000
commit765b3d617903974c1fd2fd3558f5c868373d3451 (patch)
treee71960f4d44d866d03dcefed840844f9d541f640
parent7782e420d3c688142d639912684498a1f4824aba (diff)
downloadmpc-765b3d617903974c1fd2fd3558f5c868373d3451.tar.gz
Added cmp_ui
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@27 211d60ee-9f03-0410-a15a-8952a2c7a4e4
-rw-r--r--cmp_ui.c36
-rw-r--r--makefile4
-rw-r--r--mpc.h1
-rw-r--r--mpc.texi1
4 files changed, 40 insertions, 2 deletions
diff --git a/cmp_ui.c b/cmp_ui.c
new file mode 100644
index 0000000..9f1787c
--- /dev/null
+++ b/cmp_ui.c
@@ -0,0 +1,36 @@
+/* mpc_cmp -- Compare a complex number to a non-negative integer.
+
+Copyright (C) 2005 Andreas Enge
+
+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"
+
+/* return 0 iff a = b */
+int
+mpc_cmp_ui (mpc_srcptr a, unsigned long int b)
+{
+ int cmp_re, cmp_im;
+
+ cmp_re = mpfr_cmp_ui (MPC_RE(a), b);
+ cmp_im = mpfr_cmp_ui (MPC_IM(a), 0);
+
+ return MPC_INEX(cmp_re, cmp_im);
+}
diff --git a/makefile b/makefile
index 03bf9a7..99cf763 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 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 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 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 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_ui.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 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_ui.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 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
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 b99ac56..583a308 100644
--- a/mpc.h
+++ b/mpc.h
@@ -127,6 +127,7 @@ int mpc_set_ui_fr __MPC_PROTO ((mpc_ptr, unsigned long int, mpfr_srcptr, mpc_rn
int mpc_set_ui_ui __MPC_PROTO ((mpc_ptr, unsigned long int, unsigned long int, mpc_rnd_t));
int mpc_set_si_si __MPC_PROTO ((mpc_ptr, long int, long int, mpc_rnd_t));
int mpc_cmp __MPC_PROTO ((mpc_srcptr, mpc_srcptr));
+int mpc_cmp_ui __MPC_PROTO ((mpc_srcptr, unsigned long int));
void mpc_exp __MPC_PROTO ((mpc_ptr, mpc_srcptr, mpc_rnd_t));
void mpc_clear __MPC_PROTO ((mpc_ptr));
void mpc_init __MPC_PROTO ((mpc_ptr));
diff --git a/mpc.texi b/mpc.texi
index 4b1c0ec..3fea60f 100644
--- a/mpc.texi
+++ b/mpc.texi
@@ -667,6 +667,7 @@ when @var{rop} and @var{op1} are identical.
@cindex Comparison functions
@deftypefun int mpc_cmp (mpc_t @var{op1}, mpc_t @var{op2})
+@deftypefunx int mpc_cmp_ui (mpc_t @var{op1}, unsigned long int @var{op2})
Compare @var{op1} and @var{op2}.
The return value @var{c} can be decomposed into @code{x = MPC_INEX_RE(c)}
and @code{y = MPC_INEX_IM(c)}, such that @var{x} is