aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2016-08-26 15:30:55 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2016-08-26 15:30:55 +0200
commit68d1897e8a07f1ebef24221dbcc4a42fdabae1a0 (patch)
treeebb1a0e87caffd898227ef8e5ff853b9f749c526 /Eigen/src/Core
parentfe60856fed798f8ba358c112aa09a21e206bfced (diff)
Make sure that our log1p implementation is called as a last resort only.
Diffstat (limited to 'Eigen/src/Core')
-rw-r--r--Eigen/src/Core/MathFunctions.h21
1 files changed, 12 insertions, 9 deletions
diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h
index 256dc8e94..a18b79408 100644
--- a/Eigen/src/Core/MathFunctions.h
+++ b/Eigen/src/Core/MathFunctions.h
@@ -459,30 +459,33 @@ struct arg_retval
/****************************************************************************
* Implementation of log1p *
****************************************************************************/
-template<typename Scalar, bool isComplex = NumTraits<Scalar>::IsComplex >
-struct log1p_impl
-{
- static EIGEN_DEVICE_FUNC inline Scalar run(const Scalar& x)
- {
+
+namespace std_fallback {
+ // fallback log1p implementation in case there is no log1p(Scalar) function in namespace of Scalar,
+ // or that there is no suitable std::log1p function available
+ template<typename Scalar>
+ EIGEN_DEVICE_FUNC inline Scalar log1p(const Scalar& x) {
EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar)
typedef typename NumTraits<Scalar>::Real RealScalar;
EIGEN_USING_STD_MATH(log);
Scalar x1p = RealScalar(1) + x;
return ( x1p == Scalar(1) ) ? x : x * ( log(x1p) / (x1p - RealScalar(1)) );
}
-};
+}
-#if EIGEN_HAS_CXX11_MATH && !defined(__CUDACC__)
template<typename Scalar>
-struct log1p_impl<Scalar, false> {
+struct log1p_impl {
static inline Scalar run(const Scalar& x)
{
EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar)
+ #if EIGEN_HAS_CXX11_MATH
using std::log1p;
+ #endif
+ using std_fallback::log1p;
return log1p(x);
}
};
-#endif
+
template<typename Scalar>
struct log1p_retval