Fix unit testing of predux_downto4 (bad name), and add unit testing of prsqrt

This commit is contained in:
Gael Guennebaud 2018-04-03 14:14:00 +02:00
parent 7b0630315f
commit d43b2f01f4

View File

@ -248,12 +248,13 @@ template<typename Scalar> void packetmath()
VERIFY(isApproxAbs(ref[0], internal::predux(internal::pload<Packet>(data1)), refvalue) && "internal::predux");
{
for (int i=0; i<4; ++i)
int HalfPacketSize = PacketSize>4 ? PacketSize/2 : PacketSize;
for (int i=0; i<HalfPacketSize; ++i)
ref[i] = 0;
for (int i=0; i<PacketSize; ++i)
ref[i%4] += data1[i];
ref[i%HalfPacketSize] += data1[i];
internal::pstore(data2, internal::predux_downto4(internal::pload<Packet>(data1)));
VERIFY(areApprox(ref, data2, PacketSize>4?PacketSize/2:PacketSize) && "internal::predux_downto4");
VERIFY(areApprox(ref, data2, HalfPacketSize) && "internal::predux_downto4");
}
ref[0] = 1;
@ -436,6 +437,7 @@ template<typename Scalar> void packetmath_real()
if(internal::random<float>(0,1)<0.1f)
data1[internal::random<int>(0, PacketSize)] = 0;
CHECK_CWISE1_IF(PacketTraits::HasSqrt, std::sqrt, internal::psqrt);
CHECK_CWISE1_IF(PacketTraits::HasSqrt, Scalar(1)/std::sqrt, internal::prsqrt);
CHECK_CWISE1_IF(PacketTraits::HasLog, std::log, internal::plog);
#if EIGEN_HAS_C99_MATH && (__cplusplus > 199711L)
CHECK_CWISE1_IF(PacketTraits::HasExpm1, std::expm1, internal::pexpm1);