# HG changeset patch # User jwe # Date 1094609636 0 # Node ID c09cbec5119088187f33a0106244cad78a43f888 # Parent 0355f2f7d19350396b3993538b592642eaa1697c [project @ 2004-09-08 02:13:55 by jwe] diff -r 0355f2f7d193 -r c09cbec51190 ChangeLog --- a/ChangeLog Tue Sep 07 15:09:14 2004 +0000 +++ b/ChangeLog Wed Sep 08 02:13:56 2004 +0000 @@ -1,3 +1,7 @@ +2004-09-07 John W. Eaton + + * configure.in: Check for round. + 2004-06-22 David Bateman * configure.in: Use -Wl,-Bsymbolic for MKOCTFILE_DL_LDFLAGS on diff -r 0355f2f7d193 -r c09cbec51190 configure.in --- a/configure.in Tue Sep 07 15:09:14 2004 +0000 +++ b/configure.in Wed Sep 08 02:13:56 2004 +0000 @@ -29,7 +29,7 @@ EXTERN_CXXFLAGS="$CXXFLAGS" AC_INIT -AC_REVISION($Revision: 1.454 $) +AC_REVISION($Revision: 1.455 $) AC_PREREQ(2.57) AC_CONFIG_SRCDIR([src/octave.cc]) AC_CONFIG_HEADER(config.h) @@ -963,8 +963,8 @@ getgrnam getpgrp getpid getppid getpwent getpwuid gettimeofday \ getuid getwd _kbhit kill link localtime_r lstat memmove mkdir \ mkfifo mkstemp on_exit pipe poll putenv raise readlink rename \ - rindex rmdir select setgrent setpwent setvbuf sigaction siglongjmp \ - sigpending sigprocmask sigsuspend stat strcasecmp strdup \ + rindex rmdir round select setgrent setpwent setvbuf sigaction \ + siglongjmp sigpending sigprocmask sigsuspend stat strcasecmp strdup \ strerror strftime stricmp strncasecmp strnicmp strptime symlink \ tempnam umask unlink usleep vfprintf vsprintf vsnprintf waitpid) diff -r 0355f2f7d193 -r c09cbec51190 liboctave/ChangeLog --- a/liboctave/ChangeLog Tue Sep 07 15:09:14 2004 +0000 +++ b/liboctave/ChangeLog Wed Sep 08 02:13:56 2004 +0000 @@ -1,3 +1,12 @@ +2004-09-07 John W. Eaton + + * Range.cc (round): Delete unused function. + + * lo-mappers.cc (xround): Rename from round. Change all uses. + If HAVE_ROUND, call round, otherwise fake with floor and ceil. + + * oct-inttypes.h: Include here. + 2004-09-03 David Bateman * boolNDArray.cc (boolNDArray::concat, boolNDArray::insert): diff -r 0355f2f7d193 -r c09cbec51190 liboctave/Range.cc --- a/liboctave/Range.cc Tue Sep 07 15:09:14 2004 +0000 +++ b/liboctave/Range.cc Wed Sep 08 02:13:56 2004 +0000 @@ -242,12 +242,6 @@ return -tfloor (-x, ct); } -static inline double -round (double x, double ct) -{ - return tfloor (x+0.5, ct); -} - static inline bool teq (double u, double v, double ct = 3.0 * DBL_EPSILON) { diff -r 0355f2f7d193 -r c09cbec51190 liboctave/lo-mappers.cc --- a/liboctave/lo-mappers.cc Tue Sep 07 15:09:14 2004 +0000 +++ b/liboctave/lo-mappers.cc Wed Sep 08 02:13:56 2004 +0000 @@ -77,9 +77,13 @@ } double -round (double x) +xround (double x) { - return D_NINT (x); +#if defined HAVE_ROUND + return round (x); +#else + return (x < 0 ? ceil (x - 0.5) : floor (x + 0.5); +#endif } double @@ -253,9 +257,9 @@ } Complex -round (const Complex& x) +xround (const Complex& x) { - return Complex (D_NINT (real (x)), D_NINT (imag (x))); + return Complex (xround (real (x)), xround (imag (x))); } Complex diff -r 0355f2f7d193 -r c09cbec51190 liboctave/lo-mappers.h --- a/liboctave/lo-mappers.h Tue Sep 07 15:09:14 2004 +0000 +++ b/liboctave/lo-mappers.h Wed Sep 08 02:13:56 2004 +0000 @@ -30,7 +30,7 @@ extern double fix (double x); extern double imag (double x); extern double real (double x); -extern double round (double x); +extern double xround (double x); extern double signum (double x); extern bool xisnan (double x); @@ -59,7 +59,7 @@ extern Complex ceil (const Complex& x); extern Complex fix (const Complex& x); extern Complex floor (const Complex& x); -extern Complex round (const Complex& x); +extern Complex xround (const Complex& x); extern Complex signum (const Complex& x); extern bool xisnan (const Complex& x); diff -r 0355f2f7d193 -r c09cbec51190 liboctave/oct-inttypes.h --- a/liboctave/oct-inttypes.h Tue Sep 07 15:09:14 2004 +0000 +++ b/liboctave/oct-inttypes.h Wed Sep 08 02:13:56 2004 +0000 @@ -23,8 +23,9 @@ #if !defined (octave_inttypes_h) #define octave_inttypes_h 1 +#include + #include - #include #include "data-conv.h" @@ -286,7 +287,7 @@ { double t = static_cast (value ()); double tx = static_cast (x.value ()); - double r = (t == 0 && tx == 0) ? 0 : round (t / tx); + double r = (t == 0 && tx == 0) ? 0 : xround (t / tx); ival = OCTAVE_INT_FIT_TO_RANGE (r, T); return *this; } @@ -360,7 +361,7 @@ { double tb = static_cast (b.value ()); double r = pow (a, tb); - r = lo_ieee_isnan (r) ? 0 : round (r); + r = lo_ieee_isnan (r) ? 0 : xround (r); return OCTAVE_INT_FIT_TO_RANGE (r, T); } @@ -370,7 +371,7 @@ { double ta = static_cast (a.value ()); double r = pow (ta, b); - r = lo_ieee_isnan (r) ? 0 : round (r); + r = lo_ieee_isnan (r) ? 0 : xround (r); return OCTAVE_INT_FIT_TO_RANGE (r, T); } @@ -435,8 +436,8 @@ operator OP (const octave_int& x, double y) \ { \ double tx = static_cast (x.value ()); \ - double r = round (tx OP y); \ - r = lo_ieee_isnan (r) ? 0 : round (r); \ + double r = xround (tx OP y); \ + r = lo_ieee_isnan (r) ? 0 : xround (r); \ return OCTAVE_INT_FIT_TO_RANGE (r, T); \ } @@ -453,7 +454,7 @@ { \ double ty = static_cast (y.value ()); \ double r = x OP ty; \ - r = lo_ieee_isnan (r) ? 0 : round (r); \ + r = lo_ieee_isnan (r) ? 0 : xround (r); \ return OCTAVE_INT_FIT_TO_RANGE (r, T); \ } diff -r 0355f2f7d193 -r c09cbec51190 src/mappers.cc --- a/src/mappers.cc Tue Sep 07 15:09:14 2004 +0000 +++ b/src/mappers.cc Wed Sep 08 02:13:56 2004 +0000 @@ -565,7 +565,7 @@ @end deftypefn\n\ @seealso{imag and conj}"); - DEFUN_MAPPER (round, 0, 0, 0, round, 0, round, 0.0, 0.0, 0, 0, + DEFUN_MAPPER (round, 0, 0, 0, xround, 0, xround, 0.0, 0.0, 0, 0, "-*- texinfo -*-\n\ @deftypefn {Mapping Function} {} round (@var{x})\n\ Return the integer nearest to @var{x}. If @var{x} is complex, return\n\