Skip to content

Commit

Permalink
use std's isnan/isinf
Browse files Browse the repository at this point in the history
  • Loading branch information
Soeren Sonnenburg committed Jul 26, 2013
1 parent d8d7a85 commit d459978
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
12 changes: 12 additions & 0 deletions src/shogun/mathematics/Math.cpp
Expand Up @@ -10,6 +10,7 @@
*/
#include <shogun/base/SGObject.h>
#include <shogun/lib/common.h>
#include <cmath>
#include <shogun/mathematics/Math.h>
#include <shogun/mathematics/lapack.h>
#include <shogun/io/SGIO.h>
Expand Down Expand Up @@ -196,3 +197,14 @@ void CMath::linspace(float64_t* output, float64_t start, float64_t end, int32_t
}
output[n-1] = end;
}


int CMath::is_nan(double f)
{
return std::isnan(f);
}

int CMath::is_infinity(double f)
{
return std::isinf(f);
}
21 changes: 2 additions & 19 deletions src/shogun/mathematics/Math.h
Expand Up @@ -1236,27 +1236,10 @@ class CMath : public CSGObject
}

/// checks whether a float is infinity
inline static int is_infinity(double f)
{
#ifdef SUNOS
if (fpclass(f) == FP_NINF || fpclass(f) == FP_PINF)
return 1;
else
return 0;
#else
return isinf(f);
#endif
}
static int is_infinity(double f);

/// checks whether a float is nan
inline static int is_nan(double f)
{
#ifdef SUNOS
return isnand(f);
#else
return isnan(f);
#endif
}
static int is_nan(double f);

/**@name summing functions */
//@{
Expand Down

0 comments on commit d459978

Please sign in to comment.