mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
Only implement the lgamma, erf, and erfc functions when using a compiler compliant with the C99 specification.
This commit is contained in:
parent
53b196aa5f
commit
48877a6933
@ -28,6 +28,13 @@ struct lgamma_impl
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename Scalar>
|
||||||
|
struct lgamma_retval
|
||||||
|
{
|
||||||
|
typedef Scalar type;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef EIGEN_HAS_C99_MATH
|
||||||
template<>
|
template<>
|
||||||
struct lgamma_impl<float>
|
struct lgamma_impl<float>
|
||||||
{
|
{
|
||||||
@ -41,12 +48,7 @@ struct lgamma_impl<double>
|
|||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
static EIGEN_STRONG_INLINE double run(const double& x) { return ::lgamma(x); }
|
static EIGEN_STRONG_INLINE double run(const double& x) { return ::lgamma(x); }
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
template<typename Scalar>
|
|
||||||
struct lgamma_retval
|
|
||||||
{
|
|
||||||
typedef Scalar type;
|
|
||||||
};
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Implementation of erf *
|
* Implementation of erf *
|
||||||
@ -63,6 +65,13 @@ struct erf_impl
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename Scalar>
|
||||||
|
struct erf_retval
|
||||||
|
{
|
||||||
|
typedef Scalar type;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef EIGEN_HAS_C99_MATH
|
||||||
template<>
|
template<>
|
||||||
struct erf_impl<float>
|
struct erf_impl<float>
|
||||||
{
|
{
|
||||||
@ -76,12 +85,7 @@ struct erf_impl<double>
|
|||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
static EIGEN_STRONG_INLINE double run(const double& x) { return ::erf(x); }
|
static EIGEN_STRONG_INLINE double run(const double& x) { return ::erf(x); }
|
||||||
};
|
};
|
||||||
|
#endif // EIGEN_HAS_C99_MATH
|
||||||
template<typename Scalar>
|
|
||||||
struct erf_retval
|
|
||||||
{
|
|
||||||
typedef Scalar type;
|
|
||||||
};
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Implementation of erfc *
|
* Implementation of erfc *
|
||||||
@ -98,6 +102,13 @@ struct erfc_impl
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename Scalar>
|
||||||
|
struct erfc_retval
|
||||||
|
{
|
||||||
|
typedef Scalar type;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef EIGEN_HAS_C99_MATH
|
||||||
template<>
|
template<>
|
||||||
struct erfc_impl<float>
|
struct erfc_impl<float>
|
||||||
{
|
{
|
||||||
@ -111,15 +122,11 @@ struct erfc_impl<double>
|
|||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
static EIGEN_STRONG_INLINE double run(const double x) { return ::erfc(x); }
|
static EIGEN_STRONG_INLINE double run(const double x) { return ::erfc(x); }
|
||||||
};
|
};
|
||||||
|
#endif // EIGEN_HAS_C99_MATH
|
||||||
template<typename Scalar>
|
|
||||||
struct erfc_retval
|
|
||||||
{
|
|
||||||
typedef Scalar type;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
|
|
||||||
namespace numext {
|
namespace numext {
|
||||||
|
|
||||||
template<typename Scalar>
|
template<typename Scalar>
|
||||||
|
@ -351,6 +351,7 @@ template<typename Scalar> void packetmath_real()
|
|||||||
VERIFY_IS_EQUAL(std::exp(-std::numeric_limits<Scalar>::denorm_min()), data2[1]);
|
VERIFY_IS_EQUAL(std::exp(-std::numeric_limits<Scalar>::denorm_min()), data2[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef 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;
|
||||||
@ -369,6 +370,7 @@ template<typename Scalar> void packetmath_real()
|
|||||||
h.store(data2, internal::perfc(h.load(data1)));
|
h.store(data2, internal::perfc(h.load(data1)));
|
||||||
VERIFY((numext::isnan)(data2[0]));
|
VERIFY((numext::isnan)(data2[0]));
|
||||||
}
|
}
|
||||||
|
#endif // EIGEN_HAS_C99_MATH
|
||||||
|
|
||||||
for (int i=0; i<size; ++i)
|
for (int i=0; i<size; ++i)
|
||||||
{
|
{
|
||||||
@ -380,7 +382,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 __cplusplus > 199711L
|
#if defined(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