mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-09-12 09:23:12 +08:00
Make EIGEN_HAS_C99_MATH user configurable
This commit is contained in:
parent
48bf5ec216
commit
1395056fc0
@ -116,7 +116,7 @@ struct lgamma_retval {
|
|||||||
typedef Scalar type;
|
typedef Scalar type;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef EIGEN_HAS_C99_MATH
|
#if EIGEN_HAS_C99_MATH
|
||||||
template <>
|
template <>
|
||||||
struct lgamma_impl<float> {
|
struct lgamma_impl<float> {
|
||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
@ -336,7 +336,7 @@ struct erf_retval {
|
|||||||
typedef Scalar type;
|
typedef Scalar type;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef EIGEN_HAS_C99_MATH
|
#if EIGEN_HAS_C99_MATH
|
||||||
template <>
|
template <>
|
||||||
struct erf_impl<float> {
|
struct erf_impl<float> {
|
||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
@ -369,7 +369,7 @@ struct erfc_retval {
|
|||||||
typedef Scalar type;
|
typedef Scalar type;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef EIGEN_HAS_C99_MATH
|
#if EIGEN_HAS_C99_MATH
|
||||||
template <>
|
template <>
|
||||||
struct erfc_impl<float> {
|
struct erfc_impl<float> {
|
||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
@ -426,7 +426,7 @@ struct igamma_helper<double> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef EIGEN_HAS_C99_MATH
|
#if !EIGEN_HAS_C99_MATH
|
||||||
|
|
||||||
template <typename Scalar>
|
template <typename Scalar>
|
||||||
struct igammac_impl {
|
struct igammac_impl {
|
||||||
@ -608,7 +608,7 @@ struct igamma_retval {
|
|||||||
typedef Scalar type;
|
typedef Scalar type;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef EIGEN_HAS_C99_MATH
|
#if !EIGEN_HAS_C99_MATH
|
||||||
|
|
||||||
template <typename Scalar>
|
template <typename Scalar>
|
||||||
struct igamma_impl {
|
struct igamma_impl {
|
||||||
@ -967,7 +967,7 @@ struct polygamma_retval {
|
|||||||
typedef Scalar type;
|
typedef Scalar type;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef EIGEN_HAS_C99_MATH
|
#if !EIGEN_HAS_C99_MATH
|
||||||
|
|
||||||
template <typename Scalar>
|
template <typename Scalar>
|
||||||
struct polygamma_impl {
|
struct polygamma_impl {
|
||||||
|
@ -466,7 +466,7 @@ template <> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half maxi(const Eigen::
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EIGEN_HAS_C99_MATH
|
#if EIGEN_HAS_C99_MATH
|
||||||
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half lgamma(const Eigen::half& a) {
|
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half lgamma(const Eigen::half& a) {
|
||||||
return Eigen::half(Eigen::numext::lgamma(static_cast<float>(a)));
|
return Eigen::half(Eigen::numext::lgamma(static_cast<float>(a)));
|
||||||
}
|
}
|
||||||
|
@ -360,11 +360,15 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Does the compiler support C99?
|
// Does the compiler support C99?
|
||||||
|
#ifndef EIGEN_HAS_C99_MATH
|
||||||
#if EIGEN_MAX_CPP_VER>=11 && \
|
#if EIGEN_MAX_CPP_VER>=11 && \
|
||||||
((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)) \
|
((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)) \
|
||||||
|| (defined(__GNUC__) && defined(_GLIBCXX_USE_C99)) \
|
|| (defined(__GNUC__) && defined(_GLIBCXX_USE_C99)) \
|
||||||
|| (defined(_LIBCPP_VERSION) && !defined(_MSC_VER)))
|
|| (defined(_LIBCPP_VERSION) && !defined(_MSC_VER)))
|
||||||
#define EIGEN_HAS_C99_MATH 1
|
#define EIGEN_HAS_C99_MATH 1
|
||||||
|
#else
|
||||||
|
#define EIGEN_HAS_C99_MATH 0
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Does the compiler support result_of?
|
// Does the compiler support result_of?
|
||||||
|
@ -217,7 +217,7 @@ template<typename ArrayType> void array_real(const ArrayType& m)
|
|||||||
VERIFY_IS_APPROX(m1.sinh(), sinh(m1));
|
VERIFY_IS_APPROX(m1.sinh(), sinh(m1));
|
||||||
VERIFY_IS_APPROX(m1.cosh(), cosh(m1));
|
VERIFY_IS_APPROX(m1.cosh(), cosh(m1));
|
||||||
VERIFY_IS_APPROX(m1.tanh(), tanh(m1));
|
VERIFY_IS_APPROX(m1.tanh(), tanh(m1));
|
||||||
#ifdef EIGEN_HAS_C99_MATH
|
#if EIGEN_HAS_C99_MATH
|
||||||
VERIFY_IS_APPROX(m1.lgamma(), lgamma(m1));
|
VERIFY_IS_APPROX(m1.lgamma(), lgamma(m1));
|
||||||
VERIFY_IS_APPROX(m1.digamma(), digamma(m1));
|
VERIFY_IS_APPROX(m1.digamma(), digamma(m1));
|
||||||
VERIFY_IS_APPROX(m1.erf(), erf(m1));
|
VERIFY_IS_APPROX(m1.erf(), erf(m1));
|
||||||
@ -312,7 +312,7 @@ template<typename ArrayType> void array_real(const ArrayType& m)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef EIGEN_HAS_C99_MATH
|
#if EIGEN_HAS_C99_MATH
|
||||||
// check special functions (comparing against numpy implementation)
|
// check special functions (comparing against numpy implementation)
|
||||||
if (!NumTraits<Scalar>::IsComplex)
|
if (!NumTraits<Scalar>::IsComplex)
|
||||||
{
|
{
|
||||||
@ -582,7 +582,7 @@ template<typename ArrayType> void array_special_functions()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef EIGEN_HAS_C99_MATH
|
#if EIGEN_HAS_C99_MATH
|
||||||
{
|
{
|
||||||
ArrayType n(11), x(11), res(11), ref(11);
|
ArrayType n(11), x(11), res(11), ref(11);
|
||||||
n << 1, 1, 1, 1.5, 17, 31, 28, 8, 42, 147, 170;
|
n << 1, 1, 1, 1.5, 17, 31, 28, 8, 42, 147, 170;
|
||||||
|
@ -367,7 +367,7 @@ template<typename Scalar> void packetmath_real()
|
|||||||
VERIFY((numext::isnan)(data2[0]));
|
VERIFY((numext::isnan)(data2[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EIGEN_HAS_C99_MATH
|
#if EIGEN_HAS_C99_MATH
|
||||||
{
|
{
|
||||||
data1[0] = std::numeric_limits<Scalar>::quiet_NaN();
|
data1[0] = std::numeric_limits<Scalar>::quiet_NaN();
|
||||||
packet_helper<internal::packet_traits<Scalar>::HasLGamma,Packet> h;
|
packet_helper<internal::packet_traits<Scalar>::HasLGamma,Packet> h;
|
||||||
@ -398,7 +398,7 @@ template<typename Scalar> void packetmath_real()
|
|||||||
data1[internal::random<int>(0, PacketSize)] = 0;
|
data1[internal::random<int>(0, PacketSize)] = 0;
|
||||||
CHECK_CWISE1_IF(PacketTraits::HasSqrt, std::sqrt, internal::psqrt);
|
CHECK_CWISE1_IF(PacketTraits::HasSqrt, std::sqrt, internal::psqrt);
|
||||||
CHECK_CWISE1_IF(PacketTraits::HasLog, std::log, internal::plog);
|
CHECK_CWISE1_IF(PacketTraits::HasLog, std::log, internal::plog);
|
||||||
#if defined(EIGEN_HAS_C99_MATH) && (__cplusplus > 199711L)
|
#if EIGEN_HAS_C99_MATH && (__cplusplus > 199711L)
|
||||||
CHECK_CWISE1_IF(internal::packet_traits<Scalar>::HasLGamma, std::lgamma, internal::plgamma);
|
CHECK_CWISE1_IF(internal::packet_traits<Scalar>::HasLGamma, std::lgamma, internal::plgamma);
|
||||||
CHECK_CWISE1_IF(internal::packet_traits<Scalar>::HasErf, std::erf, internal::perf);
|
CHECK_CWISE1_IF(internal::packet_traits<Scalar>::HasErf, std::erf, internal::perf);
|
||||||
CHECK_CWISE1_IF(internal::packet_traits<Scalar>::HasErfc, std::erfc, internal::perfc);
|
CHECK_CWISE1_IF(internal::packet_traits<Scalar>::HasErfc, std::erfc, internal::perfc);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user