Mercurial > hg > octave-nkf
changeset 4074:a67f76924703
[project @ 2002-09-27 21:06:02 by jwe]
author | jwe |
---|---|
date | Fri, 27 Sep 2002 21:06:02 +0000 |
parents | 38a22328f192 |
children | 9a2102864eb0 |
files | liboctave/ChangeLog liboctave/lo-cieee.c liboctave/lo-ieee.cc liboctave/lo-ieee.h liboctave/lo-mappers.cc |
diffstat | 5 files changed, 75 insertions(+), 68 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,16 +1,16 @@ 2002-09-27 John W. Eaton <jwe@bevo.che.wisc.edu> + * lo-mappers.cc (xisnan, xfinite, xisinf): Simply forward to + lo_ieee_* functions. * Makefile.in (LIBOCTAVE_C_SOURCES): Add lo-cieee.c to the list. + * lo-ieee.cc (lo_ieee_double): Rename from ieee_double. + (LO_IEEE_NA_HW, LO_IEEE_NA_LW): Rename from NA_HW and NA_LW. * lo-cieee.c: New file. - (lo_ieee_is_NaN_or_NA): Move here from lo-ieee.cc. - (lo_ieee_is_NA): Likewise. - [SCO] (isinf, isnan): Likewise. + [SCO] (isinf, isnan): Move here from lo-ieee.cc. * lo-ieee.h: Now all extern "C". - (LO_IEEE_NA_HW, LO_IEEE_NA_LW): Move here from lo-ieee.cc and - rename from NA_HW and NA_LW. - (lo_ieee_double): Move typedef here from lo-ieee.cc and rename - from ieee_double. - (lo_ieee_hw, lo_ieee_low): Provide decl. + (lo_ieee_isnan, lo_ieee_finite, lo_ieee_isinf): Move here from + lo-mappers.cc and rename from xisnan, xfinite, xisinf. + * lo-ieee.cc (lo_ieee_hw, lo_ieee_low): Rename from hw and lw. Now extern.
--- a/liboctave/lo-cieee.c +++ b/liboctave/lo-cieee.c @@ -47,6 +47,11 @@ #include "lo-ieee.h" +#if defined (_AIX) && defined (__GNUG__) +#undef finite +#define finite(x) ((x) < DBL_MAX && (x) > -DBL_MAX) +#endif + #if defined (SCO) int @@ -64,17 +69,37 @@ #endif int -lo_ieee_is_NA (double x) +lo_ieee_isnan (double x) { - lo_ieee_double t; - t.value = x; - return (isnan (x) && t.word[lo_ieee_lw] == LO_IEEE_NA_LW) ? 1 : 0; +#if defined (HAVE_ISNAN) + return lo_ieee_isnan (x) ? ! lo_ieee_is_NA (x) : 0; +#else + return 0; +#endif } int -lo_ieee_is_NaN_or_NA (double x) +lo_ieee_finite (double x) { - return isnan (x); +#if defined (HAVE_FINITE) + return finite (x) != 0 && ! lo_ieee_is_NaN_or_NA (x); +#elif defined (HAVE_ISINF) + return (! isinf (x) && ! lo_ieee_is_NaN_or_NA (x)); +#else + return ! lo_ieee_is_NaN_or_NA (x); +#endif +} + +int +lo_ieee_isinf (double x) +{ +#if defined (HAVE_ISINF) + return isinf (x); +#elif defined (HAVE_FINITE) + return (! (finite (x) || lo_ieee_is_NaN_or_NA (x))); +#else + return 0; +#endif } /*
--- a/liboctave/lo-ieee.cc +++ b/liboctave/lo-ieee.cc @@ -57,8 +57,17 @@ // Octave's idea of a missing value. double octave_NA; -int lo_ieee_hw; -int lo_ieee_lw; +static int lo_ieee_hw; +static int lo_ieee_lw; + +typedef union +{ + double value; + unsigned int word[2]; +} lo_ieee_double; + +#define LO_IEEE_NA_HW 0x7ff00000 +#define LO_IEEE_NA_LW 1954 void octave_ieee_init (void) @@ -121,6 +130,20 @@ #endif } +int +lo_ieee_is_NA (double x) +{ + lo_ieee_double t; + t.value = x; + return (lo_ieee_isnan (x) && t.word[lo_ieee_lw] == LO_IEEE_NA_LW) ? 1 : 0; +} + +int +lo_ieee_is_NaN_or_NA (double x) +{ + return lo_ieee_isnan (x); +} + /* ;;; Local Variables: *** ;;; mode: C++ ***
--- a/liboctave/lo-ieee.h +++ b/liboctave/lo-ieee.h @@ -36,27 +36,19 @@ // Octave's idea of a missing value. extern double octave_NA; -void octave_ieee_init (void); +extern void octave_ieee_init (void); -int lo_ieee_is_NA (double); -int lo_ieee_is_NaN_or_NA (double); +extern int lo_ieee_is_NA (double); +extern int lo_ieee_is_NaN_or_NA (double); #if defined (SCO) -int isnan (double); -int isinf (double); +extern int isnan (double); +extern int isinf (double); #endif -extern int lo_ieee_hw; -extern int lo_ieee_lw; - -typedef union -{ - double value; - unsigned int word[2]; -} lo_ieee_double; - -#define LO_IEEE_NA_HW 0x7ff00000 -#define LO_IEEE_NA_LW 1954 +extern int lo_ieee_isnan (double x); +extern int lo_ieee_finite (double x); +extern int lo_ieee_isinf (double x); #ifdef __cplusplus }
--- a/liboctave/lo-mappers.cc +++ b/liboctave/lo-mappers.cc @@ -27,10 +27,6 @@ #include <cfloat> #include <cmath> -#if defined (HAVE_IEEEFP_H) -#include <ieeefp.h> -#endif - #if defined (HAVE_SUNMATH_H) #include <sunmath.h> #endif @@ -44,11 +40,6 @@ #include "f77-fcn.h" -#if defined (_AIX) && defined (__GNUG__) -#undef finite -#define finite(x) ((x) < DBL_MAX && (x) > -DBL_MAX) -#endif - #ifndef M_LOG10E #define M_LOG10E 0.43429448190325182765 #endif @@ -76,11 +67,7 @@ double imag (double x) { -#if defined (HAVE_ISNAN) return xisnan (x) ? octave_NaN : 0.0; -#else - return 0.0; -#endif } double @@ -104,11 +91,7 @@ else if (x > 0.0) tmp = 1.0; -#if defined (HAVE_ISNAN) return xisnan (x) ? octave_NaN : tmp; -#else - return tmp; -#endif } // double -> bool mappers. @@ -116,35 +99,19 @@ bool xisnan (double x) { -#if defined (HAVE_ISNAN) - return isnan (x) ? ! lo_ieee_is_NA (x) : false; -#else - return false; -#endif + return lo_ieee_isnan (x); } bool xfinite (double x) { -#if defined (HAVE_FINITE) - return finite (x) != 0 && ! octave_is_NaN_or_NA (x); -#elif defined (HAVE_ISINF) - return (! isinf (x) && ! octave_is_NaN_or_NA (x)); -#else - return ! octave_is_NaN_or_NA (x); -#endif + return lo_ieee_finite (x); } bool xisinf (double x) { -#if defined (HAVE_ISINF) - return isinf (x); -#elif defined (HAVE_FINITE) - return (! (finite (x) || octave_is_NaN_or_NA (x))); -#else - return false; -#endif + return lo_ieee_isinf (x); } bool