Mercurial > jwe > octave
diff liboctave/util/oct-inttypes.h @ 21782:2aef506f3fec
use namespace for lo-mappers.h functions
* lo-mappers.h, lo-mappers.cc (acos, arg, asin, atan, ceil, conj,
copysign, exp2, finite, fix, floor, imag, is_NA, is_NaN_or_NA, isinf,
isinteger, isnan, log2, max, min, mod, negative_sign, nint, nint_big,
positive_sign, rc_acos, rc_acosh, rc_asin, rc_atanh, rc_log, rc_log10,
rc_log2, rc_sqrt, real, rem, round, roundb, signbit, signum, trunc,
x_nint): Define in octave::math namespace. Deprecate old names.
Change all uses.
* oct-inttypes.h: Put round and isnan functions in octave::math
namespace and rename from xround and xisnan. Change all uses.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 25 May 2016 16:51:16 -0400 |
parents | b571fc85953f |
children | c9f8a7f7915e |
line wrap: on
line diff
--- a/liboctave/util/oct-inttypes.h Fri May 27 10:20:48 2016 -0400 +++ b/liboctave/util/oct-inttypes.h Wed May 25 16:51:16 2016 -0400 @@ -36,9 +36,27 @@ #include "lo-mappers.h" #if defined (OCTAVE_INT_USE_LONG_DOUBLE) -inline long double xround (long double x) { return roundl (x); } -inline long double xisnan (long double x) -{ return xisnan (static_cast<double> (x)); } + +namespace octave +{ + namespace math + { + inline long double round (long double x) { return roundl (x); } + + inline long double isnan (long double x) { return isnan (static_cast<double> (x)); } + } +} + +#if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS) + +OCTAVE_DEPRECATED ("use 'octave::math::isnan' instead") +inline long double xround (long double x) { return octave::math::round (x); } + +OCTAVE_DEPRECATED ("use 'octave::math::isnan' instead") +inline bool xisnan (long double x) { return octave::math::isnan (x); } + +#endif + #endif // FIXME: we define this by our own because some compilers, such as @@ -309,9 +327,9 @@ static S compute_threshold (S val, T orig_val) { - val = xround (val); // Fool optimizations (maybe redundant) + val = octave::math::round (val); // Fool optimizations (maybe redundant) // If val is even, but orig_val is odd, we're one unit off. - if (orig_val % 2 && val / 2 == xround (val / 2)) + if (orig_val % 2 && val / 2 == octave::math::round (val / 2)) // FIXME: is this always correct? val *= (static_cast<S> (1) - (std::numeric_limits<S>::epsilon () / 2)); return val; @@ -949,10 +967,30 @@ // No mixed integer binary operations! +namespace octave +{ + namespace math + { + template <typename T> + bool + isnan (const octave_int<T>&) + { + return false; + } + } +} + +#if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS) + template <typename T> -inline bool -xisnan (const octave_int<T>&) -{ return false; } +OCTAVE_DEPRECATED ("use 'octave::math::isnan' instead") +bool +xisnan (const octave_int<T>& x) +{ + return octave::math::isnan (x); +} + +#endif // FIXME: can/should any of these be inline?