18 #define NUKLEI_RANGE_CHECK(value, low, high)\
20 if (! (low <= value && value <= high))\
22 NUKLEI_WARN("Range Error:" << NUKLEI_NVP((low <= value && value <= high))\
23 << "\n" << NUKLEI_NVP(high)\
24 << "\n" << NUKLEI_NVP(value)\
25 << "\n" << NUKLEI_NVP(low))\
29 template<
typename T> T ACos(T fValue)
31 if ( -(T)1.0 < fValue )
33 if ( fValue < (T)1.0 )
34 return (T)std::acos((
double)fValue);
44 template<
typename T> T FastACos(T fValue)
46 NUKLEI_FAST_ASSERT(-1-FLOATTOL < fValue && fValue < 1+FLOATTOL);
47 if (fValue >= 1)
return 0;
49 return nuklei_wmf::Math<coord_t>::FastInvCos0( fValue );
51 return M_PI - nuklei_wmf::Math<coord_t>::FastInvCos0( -fValue );
55 template<
typename T> T ASin(T fValue)
57 if ( -(T)1.0 < fValue )
59 if ( fValue < (T)1.0 )
60 return (T)std::asin((
double)fValue);
70 template<
typename T> T FastNegExp(T fValue)
72 NUKLEI_FAST_ASSERT(0-1e-6 < fValue);
73 if (fValue < 0) fValue = 0;
74 return nuklei_wmf::Math<coord_t>::FastNegExp3( fValue );
78 trivariateGaussian(
const Vector3 &x,
const Vector3 &m,
const Matrix3 &cov,
81 const Vector3 diff = x-m;
82 const Matrix3 inv = cov.Inverse();
83 const Vector3 tmp = inv * diff;
84 double val = diff.Dot(tmp);
85 double ret = std::exp(-.5 * val);
86 ret /= std::pow(2*M_PI, 3.0/2) * std::sqrt(cov.Determinant());
91 trivariateGaussianDistance(
const Vector3 &x,
const Vector3 &m,
95 const Vector3 diff = x-m;
96 const Matrix3 inv = cov.Inverse();
97 const Vector3 tmp = inv * diff;
98 double val = diff.Dot(tmp);
100 double ret = -.5 * val + std::log(w) - 3.0/2 * std::log(2*M_PI) -
101 .5 * std::log(cov.Determinant());
107 bool rfe(
const double a,
const double b,
double tol = 1e-6);
110 inline bool afe(
const double a,
const double b,
double tol = 1e-6)
113 return (std::fabs(a-b) <= tol);
118 T angularDistance(T a, T b)
120 T d = std::fabs( atan2( std::sin(a - b), std::cos(a - b) ) ) / M_PI;
123 NUKLEI_FAST_ASSERT(afe(d, 1));
129 double confluentHypergeometric1F1(
const double a,
const double b,
const double x);
130 double besselI1(
const double x);