Mercurial > hg > octave-nkf
diff liboctave/lo-mappers.cc @ 8998:a48fba01e4ac
optimize isnan/isinf/isfinite mappers
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 19 Mar 2009 17:46:38 +0100 |
parents | eb63fbe60fab |
children | 0d9178575dd7 |
line wrap: on
line diff
--- a/liboctave/lo-mappers.cc +++ b/liboctave/lo-mappers.cc @@ -190,23 +190,29 @@ // double -> bool mappers. +#if ! defined(HAVE_CMATH_ISNAN) bool xisnan (double x) { return lo_ieee_isnan (x); } +#endif +#if ! defined(HAVE_CMATH_ISFINITE) bool xfinite (double x) { return lo_ieee_finite (x); } +#endif +#if ! defined(HAVE_CMATH_ISINF) bool xisinf (double x) { return lo_ieee_isinf (x); } +#endif bool octave_is_NA (double x) @@ -321,28 +327,6 @@ // complex -> bool mappers. bool -xisnan (const Complex& x) -{ - return (xisnan (real (x)) || xisnan (imag (x))); -} - -bool -xfinite (const Complex& x) -{ - double rx = real (x); - double ix = imag (x); - - return (xfinite (rx) && ! xisnan (rx) - && xfinite (ix) && ! xisnan (ix)); -} - -bool -xisinf (const Complex& x) -{ - return (xisinf (real (x)) || xisinf (imag (x))); -} - -bool octave_is_NA (const Complex& x) { return (octave_is_NA (real (x)) || octave_is_NA (imag (x))); @@ -524,23 +508,29 @@ // float -> bool mappers. +#if ! defined(HAVE_CMATH_ISNANF) bool xisnan (float x) { return lo_ieee_isnan (x); } +#endif +#if ! defined(HAVE_CMATH_ISFINITEF) bool xfinite (float x) { return lo_ieee_finite (x); } +#endif +#if ! defined(HAVE_CMATH_ISINFF) bool xisinf (float x) { return lo_ieee_isinf (x); } +#endif bool octave_is_NA (float x) @@ -655,28 +645,6 @@ // complex -> bool mappers. bool -xisnan (const FloatComplex& x) -{ - return (xisnan (real (x)) || xisnan (imag (x))); -} - -bool -xfinite (const FloatComplex& x) -{ - float rx = real (x); - float ix = imag (x); - - return (xfinite (rx) && ! xisnan (rx) - && xfinite (ix) && ! xisnan (ix)); -} - -bool -xisinf (const FloatComplex& x) -{ - return (xisinf (real (x)) || xisinf (imag (x))); -} - -bool octave_is_NA (const FloatComplex& x) { return (octave_is_NA (real (x)) || octave_is_NA (imag (x)));