Add pinsertfirst function and implement pinsertlast for complex on SSE/AVX.

This commit is contained in:
Gael Guennebaud
2016-11-02 10:38:13 +01:00
parent e44519744e
commit 598de8b193
6 changed files with 100 additions and 2 deletions

View File

@@ -16,6 +16,12 @@
#endif
// using namespace Eigen;
#ifdef EIGEN_VECTORIZE_SSE
const bool g_vectorize_sse = true;
#else
const bool g_vectorize_sse = false;
#endif
namespace Eigen {
namespace internal {
template<typename T> T negate(const T& x) { return -x; }
@@ -290,7 +296,17 @@ template<typename Scalar> void packetmath()
}
}
if (PacketTraits::HasBlend) {
if (PacketTraits::HasBlend || g_vectorize_sse) {
// pinsertfirst
for (int i=0; i<PacketSize; ++i)
ref[i] = data1[i];
Scalar s = internal::random<Scalar>();
ref[0] = s;
internal::pstore(data2, internal::pinsertfirst(internal::pload<Packet>(data1),s));
VERIFY(areApprox(ref, data2, PacketSize) && "internal::pinsertfirst");
}
if (PacketTraits::HasBlend || g_vectorize_sse) {
// pinsertlast
for (int i=0; i<PacketSize; ++i)
ref[i] = data1[i];