From 45a1f4726a33ea6bc41ddc88fd41dbb8c9176933 Mon Sep 17 00:00:00 2001 From: enge Date: Fri, 4 Feb 2005 16:52:31 +0000 Subject: Removed cmp_ui, added cmp_si_si and the macro cmp_si git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@30 211d60ee-9f03-0410-a15a-8952a2c7a4e4 --- cmp_si_si.c | 37 +++++++++++++++++++++++++++++++++++++ cmp_ui.c | 36 ------------------------------------ makefile | 4 ++-- mpc.h | 5 +++-- mpc.texi | 12 ++++++++---- 5 files changed, 50 insertions(+), 44 deletions(-) create mode 100644 cmp_si_si.c delete mode 100644 cmp_ui.c diff --git a/cmp_si_si.c b/cmp_si_si.c new file mode 100644 index 0000000..67b65ee --- /dev/null +++ b/cmp_si_si.c @@ -0,0 +1,37 @@ +/* mpc_cmp_si_si -- Compare a complex number to a number of the form + b+c*i with b and c signed integers. + +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_si_si (mpc_srcptr a, long int b, long int c) +{ + int cmp_re, cmp_im; + + cmp_re = mpfr_cmp_si (MPC_RE(a), b); + cmp_im = mpfr_cmp_si (MPC_IM(a), c); + + return MPC_INEX(cmp_re, cmp_im); +} diff --git a/cmp_ui.c b/cmp_ui.c deleted file mode 100644 index 9f1787c..0000000 --- a/cmp_ui.c +++ /dev/null @@ -1,36 +0,0 @@ -/* 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 bc8c972..8fbc567 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_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 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_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 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 +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 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 65e5566..edf6540 100644 --- a/mpc.h +++ b/mpc.h @@ -128,7 +128,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)); +int mpc_cmp_si_si __MPC_PROTO ((mpc_srcptr, long int, 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)); @@ -161,5 +161,6 @@ size_t mpc_out_str __MPC_PROTO ((FILE *, int, size_t, mpc_srcptr, mpc_rnd_t)); ( mpc_init(x), mpc_set_si_si((x), (y), (z), (rnd)) ) #define mpc_add_si(x, y, z, rnd) \ ( (z) >= 0 ? mpc_add_ui ((x), (y), (z), (rnd)) : mpc_sub_ui ((x), (y), -(z), (rnd)) ) - +#define mpc_cmp_si(x, y) \ + ( mpc_cmp_si_si ((x), (y), 0) ) #endif /* ifndef __MPC_H */ diff --git a/mpc.texi b/mpc.texi index f0ef433..a253378 100644 --- a/mpc.texi +++ b/mpc.texi @@ -672,9 +672,12 @@ when @var{rop} and @var{op1} are identical. @cindex Complex comparisons functions @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}. +@deftypefn Function int mpc_cmp (mpc_t @var{op1}, mpc_t @var{op2}) +@deftypefnx Function int mpc_cmp_si_si (mpc_t @var{op1}, long int @var{op2r}, long int @var{op2i}) +@deftypefnx Macro int mpc_cmp_si (mpc_t @var{op1}, long int @var{op2}) + +Compare @var{op1} and @var{op2}, where in the case of @code{mpc_cmp_si_si}, +@var{op2} is taken to be @var{op2r} + i @var{op2i}. 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 positive if the real part of @var{op1} is greater than that of @var{op2}, @@ -686,7 +689,8 @@ It is not allowed that one of the operands has a NaN (Not-a-Number) part. The storage of the return value is such that equality can be simply checked with @code{mpc_cmp (op1, op2) == 0}. -@end deftypefun +@end deftypefn + @node Special Complex Functions, I/O of Complex Numbers, Complex Comparison, Complex Functions @comment node-name, next, previous, up -- cgit v1.2.1