mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-12 11:49:02 +08:00
Use lgamma_r if it is available (update check for glibc 2.19+)
This commit is contained in:
parent
b431024404
commit
2279f2c62f
@ -57,11 +57,23 @@ struct lgamma_retval {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if EIGEN_HAS_C99_MATH
|
#if EIGEN_HAS_C99_MATH
|
||||||
|
// Since glibc 2.19
|
||||||
|
#if defined(__GLIBC__) && ((__GLIBC__>=2 && __GLIBC_MINOR__ >= 19) || __GLIBC__>2) \
|
||||||
|
&& (defined(_DEFAULT_SOURCE) || defined(_BSD_SOURCE) || defined(_SVID_SOURCE))
|
||||||
|
#define HAS_LGAMMA_R
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Glibc versions before 2.19
|
||||||
|
#if defined(__GLIBC__) && ((__GLIBC__==2 && __GLIBC_MINOR__ < 19) || __GLIBC__<2) \
|
||||||
|
&& (defined(_BSD_SOURCE) || defined(_SVID_SOURCE))
|
||||||
|
#define HAS_LGAMMA_R
|
||||||
|
#endif
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct lgamma_impl<float> {
|
struct lgamma_impl<float> {
|
||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
static EIGEN_STRONG_INLINE float run(float x) {
|
static EIGEN_STRONG_INLINE float run(float x) {
|
||||||
#if !defined(EIGEN_GPU_COMPILE_PHASE) && (defined(_BSD_SOURCE) || defined(_SVID_SOURCE)) && !defined(__APPLE__)
|
#if !defined(EIGEN_GPU_COMPILE_PHASE) && defined (HAS_LGAMMA_R) && !defined(__APPLE__)
|
||||||
int dummy;
|
int dummy;
|
||||||
return ::lgammaf_r(x, &dummy);
|
return ::lgammaf_r(x, &dummy);
|
||||||
#elif defined(SYCL_DEVICE_ONLY)
|
#elif defined(SYCL_DEVICE_ONLY)
|
||||||
@ -76,7 +88,7 @@ template <>
|
|||||||
struct lgamma_impl<double> {
|
struct lgamma_impl<double> {
|
||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
static EIGEN_STRONG_INLINE double run(double x) {
|
static EIGEN_STRONG_INLINE double run(double x) {
|
||||||
#if !defined(EIGEN_GPU_COMPILE_PHASE) && (defined(_BSD_SOURCE) || defined(_SVID_SOURCE)) && !defined(__APPLE__)
|
#if !defined(EIGEN_GPU_COMPILE_PHASE) && defined(HAS_LGAMMA_R) && !defined(__APPLE__)
|
||||||
int dummy;
|
int dummy;
|
||||||
return ::lgamma_r(x, &dummy);
|
return ::lgamma_r(x, &dummy);
|
||||||
#elif defined(SYCL_DEVICE_ONLY)
|
#elif defined(SYCL_DEVICE_ONLY)
|
||||||
@ -86,6 +98,8 @@ struct lgamma_impl<double> {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#undef HAS_LGAMMA_R
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
Loading…
x
Reference in New Issue
Block a user