mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-01-24 14:45:14 +08:00
Fix bug #859: pexp(NaN) returned Inf instead of NaN
This commit is contained in:
parent
a72eabec9b
commit
00ec1629ca
@ -166,7 +166,7 @@ Packet4f pexp<Packet4f>(const Packet4f& _x)
|
||||
emm0 = _mm_cvttps_epi32(fx);
|
||||
emm0 = _mm_add_epi32(emm0, p4i_0x7f);
|
||||
emm0 = _mm_slli_epi32(emm0, 23);
|
||||
return pmul(y, _mm_castsi128_ps(emm0));
|
||||
return pmax(pmul(y, Packet4f(_mm_castsi128_ps(emm0))), _x);
|
||||
}
|
||||
template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED
|
||||
Packet2d pexp<Packet2d>(const Packet2d& _x)
|
||||
|
20
test/main.h
20
test/main.h
@ -406,6 +406,26 @@ void randomPermutationVector(PermutationVectorType& v, typename PermutationVecto
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T> bool isNotNaN(const T& x)
|
||||
{
|
||||
return x==x;
|
||||
}
|
||||
|
||||
template<typename T> bool isNaN(const T& x)
|
||||
{
|
||||
return x!=x;
|
||||
}
|
||||
|
||||
template<typename T> bool isInf(const T& x)
|
||||
{
|
||||
return x > NumTraits<T>::highest();
|
||||
}
|
||||
|
||||
template<typename T> bool isMinusInf(const T& x)
|
||||
{
|
||||
return x < NumTraits<T>::lowest();
|
||||
}
|
||||
|
||||
} // end namespace Eigen
|
||||
|
||||
template<typename T> struct GetDifferentType;
|
||||
|
@ -239,6 +239,12 @@ template<typename Scalar> void packetmath_real()
|
||||
data2[i] = internal::random<Scalar>(-87,88);
|
||||
}
|
||||
CHECK_CWISE1_IF(internal::packet_traits<Scalar>::HasExp, std::exp, internal::pexp);
|
||||
{
|
||||
data1[0] = std::numeric_limits<Scalar>::quiet_NaN();
|
||||
packet_helper<internal::packet_traits<Scalar>::HasExp,Packet> h;
|
||||
h.store(data2, internal::pexp(h.load(data1)));
|
||||
VERIFY(isNaN(data2[0]));
|
||||
}
|
||||
|
||||
for (int i=0; i<size; ++i)
|
||||
{
|
||||
|
@ -9,11 +9,6 @@
|
||||
|
||||
#include "main.h"
|
||||
|
||||
template<typename T> bool isNotNaN(const T& x)
|
||||
{
|
||||
return x==x;
|
||||
}
|
||||
|
||||
// workaround aggressive optimization in ICC
|
||||
template<typename T> EIGEN_DONT_INLINE T sub(T a, T b) { return a - b; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user