aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Christoph Hertzberg <chtz@informatik.uni-bremen.de>2014-10-20 13:13:43 +0200
committerGravatar Christoph Hertzberg <chtz@informatik.uni-bremen.de>2014-10-20 13:13:43 +0200
commit84aaa03182f6e31fa251d93730d628975c44207c (patch)
tree0581bd83d36b1c08e2e032e44ac85e07714b5287
parentaa5f79206fb632d141c3555338f89f59d1bb4633 (diff)
Addendum to bug #859: pexp(NaN) for double did not return NaN, also, plog(NaN) did not return NaN.
psqrt(NaN) and psqrt(-1) shall return NaN if EIGEN_FAST_MATH==0
-rw-r--r--Eigen/src/Core/arch/SSE/MathFunctions.h4
-rw-r--r--test/packetmath.cpp16
2 files changed, 17 insertions, 3 deletions
diff --git a/Eigen/src/Core/arch/SSE/MathFunctions.h b/Eigen/src/Core/arch/SSE/MathFunctions.h
index b549e4870..9ffba5b41 100644
--- a/Eigen/src/Core/arch/SSE/MathFunctions.h
+++ b/Eigen/src/Core/arch/SSE/MathFunctions.h
@@ -52,7 +52,7 @@ Packet4f plog<Packet4f>(const Packet4f& _x)
Packet4i emm0;
- Packet4f invalid_mask = _mm_cmplt_ps(x, _mm_setzero_ps());
+ Packet4f invalid_mask = _mm_cmpnge_ps(x, _mm_setzero_ps()); // not greater equal is true if x is NaN
Packet4f iszero_mask = _mm_cmpeq_ps(x, _mm_setzero_ps());
x = pmax(x, p4f_min_norm_pos); /* cut off denormalized stuff */
@@ -241,7 +241,7 @@ Packet2d pexp<Packet2d>(const Packet2d& _x)
emm0 = _mm_add_epi32(emm0, p4i_1023_0);
emm0 = _mm_slli_epi32(emm0, 20);
emm0 = _mm_shuffle_epi32(emm0, _MM_SHUFFLE(1,2,0,3));
- return pmul(x, Packet2d(_mm_castsi128_pd(emm0)));
+ return pmax(pmul(x, Packet2d(_mm_castsi128_pd(emm0))), _x);
}
/* evaluation of 4 sines at onces, using SSE2 intrinsics.
diff --git a/test/packetmath.cpp b/test/packetmath.cpp
index a4166d868..ee0502f69 100644
--- a/test/packetmath.cpp
+++ b/test/packetmath.cpp
@@ -311,8 +311,22 @@ template<typename Scalar> void packetmath_real()
}
if(internal::random<float>(0,1)<0.1)
data1[internal::random<int>(0, PacketSize)] = 0;
- CHECK_CWISE1_IF(internal::packet_traits<Scalar>::HasLog, std::log, internal::plog);
CHECK_CWISE1_IF(internal::packet_traits<Scalar>::HasSqrt, std::sqrt, internal::psqrt);
+ CHECK_CWISE1_IF(internal::packet_traits<Scalar>::HasLog, std::log, internal::plog);
+ {
+ data1[0] = std::numeric_limits<Scalar>::quiet_NaN();
+ packet_helper<internal::packet_traits<Scalar>::HasLog,Packet> h;
+ h.store(data2, internal::plog(h.load(data1)));
+ VERIFY(isNaN(data2[0]));
+ data1[0] = -1.0f;
+ h.store(data2, internal::plog(h.load(data1)));
+ VERIFY(isNaN(data2[0]));
+#if !EIGEN_FAST_MATH
+ h.store(data2, internal::psqrt(h.load(data1)));
+ VERIFY(isNaN(data2[0]));
+ VERIFY(isNaN(data2[1]));
+#endif
+ }
}
template<typename Scalar> void packetmath_notcomplex()