Mercurial > hg > octave-nkf
changeset 4968:c09cbec51190
[project @ 2004-09-08 02:13:55 by jwe]
author | jwe |
---|---|
date | Wed, 08 Sep 2004 02:13:56 +0000 |
parents | 0355f2f7d193 |
children | 52f808101130 |
files | ChangeLog configure.in liboctave/ChangeLog liboctave/Range.cc liboctave/lo-mappers.cc liboctave/lo-mappers.h liboctave/oct-inttypes.h src/mappers.cc |
diffstat | 8 files changed, 35 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-09-07 John W. Eaton <jwe@octave.org> + + * configure.in: Check for round. + 2004-06-22 David Bateman <dbateman@free.fr> * configure.in: Use -Wl,-Bsymbolic for MKOCTFILE_DL_LDFLAGS on
--- a/configure.in +++ b/configure.in @@ -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)
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,12 @@ +2004-09-07 John W. Eaton <jwe@octave.org> + + * 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 <cmath> here. + 2004-09-03 David Bateman <dbateman@free.fr> * boolNDArray.cc (boolNDArray::concat, boolNDArray::insert):
--- a/liboctave/Range.cc +++ b/liboctave/Range.cc @@ -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) {
--- a/liboctave/lo-mappers.cc +++ b/liboctave/lo-mappers.cc @@ -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
--- a/liboctave/lo-mappers.h +++ b/liboctave/lo-mappers.h @@ -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);
--- a/liboctave/oct-inttypes.h +++ b/liboctave/oct-inttypes.h @@ -23,8 +23,9 @@ #if !defined (octave_inttypes_h) #define octave_inttypes_h 1 +#include <cmath> + #include <limits> - #include <iostream> #include "data-conv.h" @@ -286,7 +287,7 @@ { double t = static_cast<double> (value ()); double tx = static_cast<double> (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<double> (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<double> (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<T>& x, double y) \ { \ double tx = static_cast<double> (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<double> (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); \ }
--- a/src/mappers.cc +++ b/src/mappers.cc @@ -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\