Use threadsafe versions of lgamma and lgammaf if possible.

This commit is contained in:
Rasmus Munk Larsen 2016-10-27 16:17:12 -07:00
parent 530f20c21a
commit 2ebb314fa7

View File

@ -120,13 +120,27 @@ struct lgamma_retval {
template <> template <>
struct lgamma_impl<float> { struct lgamma_impl<float> {
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE float run(float x) { return ::lgammaf(x); } static EIGEN_STRONG_INLINE float run(float x) {
#ifdef _BSD_SOURCE || _SVID_SOURCE
int signgam;
return ::lgammaf_r(x, &signgam);
#else
return ::lgammaf(x);
#endif
}
}; };
template <> template <>
struct lgamma_impl<double> { struct lgamma_impl<double> {
EIGEN_DEVICE_FUNC EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE double run(double x) { return ::lgamma(x); } static EIGEN_STRONG_INLINE double run(double x) {
#ifdef _BSD_SOURCE || _SVID_SOURCE
int signgam;
return ::lgammaf_r(x, &signgam);
#else
return ::lgamma(x);
#endif
}
}; };
#endif #endif