Use std::isnan instead of _isnan
This commit is contained in:
parent
bf58d8631b
commit
6b39c3e7d5
2 changed files with 15 additions and 27 deletions
|
@ -10,13 +10,6 @@
|
||||||
|
|
||||||
typedef float KEYER_FLOAT;
|
typedef float KEYER_FLOAT;
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#define ISNAN _isnan
|
|
||||||
#else
|
|
||||||
#define ISNAN std::isnan
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
//#define CLUSTER_ELEM_CONTAINER_IS_A_SET
|
//#define CLUSTER_ELEM_CONTAINER_IS_A_SET
|
||||||
|
@ -180,7 +173,7 @@ void chooseLeafToClusterize(ClusterContainer::iterator &itRet,
|
||||||
Cluster *cluster = *it;
|
Cluster *cluster = *it;
|
||||||
// Calculates the covariance matrix.
|
// Calculates the covariance matrix.
|
||||||
const KEYER_FLOAT *clusterCovariance = cluster->statistic.covariance;
|
const KEYER_FLOAT *clusterCovariance = cluster->statistic.covariance;
|
||||||
assert(!ISNAN(clusterCovariance[0]));
|
assert(!std::isnan(clusterCovariance[0]));
|
||||||
|
|
||||||
// Calculate the eigenvalues of the covariance matrix of the cluster
|
// Calculate the eigenvalues of the covariance matrix of the cluster
|
||||||
// statistics
|
// statistics
|
||||||
|
@ -344,9 +337,9 @@ eigenVector[2] /= eigenVectorMagnitude;
|
||||||
clusterFound->eigenVector[1] = eigenVector[1];
|
clusterFound->eigenVector[1] = eigenVector[1];
|
||||||
clusterFound->eigenVector[2] = eigenVector[2];
|
clusterFound->eigenVector[2] = eigenVector[2];
|
||||||
|
|
||||||
assert(!ISNAN(eigenVector[0]));
|
assert(!std::isnan(eigenVector[0]));
|
||||||
assert(!ISNAN(eigenVector[1]));
|
assert(!std::isnan(eigenVector[1]));
|
||||||
assert(!ISNAN(eigenVector[2]));
|
assert(!std::isnan(eigenVector[2]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,9 +370,9 @@ unsigned short int calcCovarianceEigenValues(
|
||||||
assert(solutionsCount > 0);
|
assert(solutionsCount > 0);
|
||||||
multeplicity = 4 - solutionsCount;
|
multeplicity = 4 - solutionsCount;
|
||||||
|
|
||||||
assert(!ISNAN(eigenValues[0]));
|
assert(!std::isnan(eigenValues[0]));
|
||||||
assert(!ISNAN(eigenValues[1]));
|
assert(!std::isnan(eigenValues[1]));
|
||||||
assert(!ISNAN(eigenValues[2]));
|
assert(!std::isnan(eigenValues[2]));
|
||||||
|
|
||||||
assert(multeplicity > 0);
|
assert(multeplicity > 0);
|
||||||
return multeplicity;
|
return multeplicity;
|
||||||
|
@ -422,9 +415,9 @@ void SolveCubic(KEYER_FLOAT a, /* coefficient of x^3 */
|
||||||
x[2] = (KEYER_FLOAT)(-2.0 * sqrt(Q) * cos((theta + 4.0 * PI) / 3.0) -
|
x[2] = (KEYER_FLOAT)(-2.0 * sqrt(Q) * cos((theta + 4.0 * PI) / 3.0) -
|
||||||
a1 / 3.0);
|
a1 / 3.0);
|
||||||
|
|
||||||
assert(!ISNAN(x[0]));
|
assert(!std::isnan(x[0]));
|
||||||
assert(!ISNAN(x[1]));
|
assert(!std::isnan(x[1]));
|
||||||
assert(!ISNAN(x[2]));
|
assert(!std::isnan(x[2]));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
long KEYER_FLOAT v;
|
long KEYER_FLOAT v;
|
||||||
|
@ -442,7 +435,7 @@ assert(areAlmostEqual(a*v*v*v+b*v*v+c*v+d, 0.0));
|
||||||
x[0] *= (KEYER_FLOAT)((R < 0.0) ? 1 : -1);
|
x[0] *= (KEYER_FLOAT)((R < 0.0) ? 1 : -1);
|
||||||
x[0] -= (KEYER_FLOAT)(a1 / 3.0);
|
x[0] -= (KEYER_FLOAT)(a1 / 3.0);
|
||||||
|
|
||||||
assert(!ISNAN(x[0]));
|
assert(!std::isnan(x[0]));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
long KEYER_FLOAT v;
|
long KEYER_FLOAT v;
|
||||||
|
@ -602,7 +595,7 @@ void Cluster::computeCovariance() {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (; i < 9; ++i) {
|
for (; i < 9; ++i) {
|
||||||
statistic.covariance[i] = statistic.matrixR[i] - sumComponentsMatrix[i] / n;
|
statistic.covariance[i] = statistic.matrixR[i] - sumComponentsMatrix[i] / n;
|
||||||
assert(!ISNAN(statistic.matrixR[i]));
|
assert(!std::isnan(statistic.matrixR[i]));
|
||||||
// assert(statistic.covariance[i] >= 0.0);
|
// assert(statistic.covariance[i] >= 0.0);
|
||||||
// numerical instability???
|
// numerical instability???
|
||||||
if (statistic.covariance[i] < 0.0) statistic.covariance[i] = 0.0;
|
if (statistic.covariance[i] < 0.0) statistic.covariance[i] = 0.0;
|
||||||
|
|
|
@ -9,11 +9,6 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
#ifdef _MSC_VER
|
|
||||||
#define ISNAN _isnan
|
|
||||||
#else
|
|
||||||
#define ISNAN std::isnan
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -31,13 +26,13 @@ bool lineIntersection(const TPointD &P, const TPointD &R, const TPointD &Q,
|
||||||
double r;
|
double r;
|
||||||
if (u.y * v.x - u.x * v.y != 0) {
|
if (u.y * v.x - u.x * v.y != 0) {
|
||||||
r = (P.x * u.y - Q.x * u.y + u.x * (Q.y - P.y)) / (u.y * v.x - u.x * v.y);
|
r = (P.x * u.y - Q.x * u.y + u.x * (Q.y - P.y)) / (u.y * v.x - u.x * v.y);
|
||||||
assert(!ISNAN(r));
|
assert(!std::isnan(r));
|
||||||
ret = Q + v * r;
|
ret = Q + v * r;
|
||||||
assert(!ISNAN(ret.x) && !ISNAN(ret.y));
|
assert(!std::isnan(ret.x) && !std::isnan(ret.y));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
ret = P;
|
ret = P;
|
||||||
assert(!ISNAN(ret.x) && !ISNAN(ret.y));
|
assert(!std::isnan(ret.x) && !std::isnan(ret.y));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue