12 #include "unsupported/Eigen/SpecialFunctions" 14 #if defined __GNUC__ && __GNUC__>=6 15 #pragma GCC diagnostic ignored "-Wignored-attributes" 19 #ifdef EIGEN_VECTORIZE_SSE 64 #define CHECK_CWISE1(REFOP, POP) { \ 65 for (int i=0; i<PacketSize; ++i) \ 66 ref[i] = REFOP(data1[i]); \ 67 internal::pstore(data2, POP(internal::pload<Packet>(data1))); \ 68 VERIFY(areApprox(ref, data2, PacketSize) && #POP); \ 71 template<
bool Cond,
typename Packet>
75 inline Packet load(
const T* from)
const {
return internal::pload<Packet>(from); }
81 template<
typename Packet>
85 inline T load(
const T* from)
const {
return *from; }
88 inline void store(
T* to,
const T&
x)
const { *to =
x; }
91 #define CHECK_CWISE1_IF(COND, REFOP, POP) if(COND) { \ 92 packet_helper<COND,Packet> h; \ 93 for (int i=0; i<PacketSize; ++i) \ 94 ref[i] = REFOP(data1[i]); \ 95 h.store(data2, POP(h.load(data1))); \ 96 VERIFY(areApprox(ref, data2, PacketSize) && #POP); \ 99 #define CHECK_CWISE2_IF(COND, REFOP, POP) if(COND) { \ 100 packet_helper<COND,Packet> h; \ 101 for (int i=0; i<PacketSize; ++i) \ 102 ref[i] = REFOP(data1[i], data1[i+PacketSize]); \ 103 h.store(data2, POP(h.load(data1),h.load(data1+PacketSize))); \ 104 VERIFY(areApprox(ref, data2, PacketSize) && #POP); \ 107 #define REF_ADD(a,b) ((a)+(b)) 108 #define REF_SUB(a,b) ((a)-(b)) 109 #define REF_MUL(a,b) ((a)*(b)) 110 #define REF_DIV(a,b) ((a)/(b)) 115 typedef internal::packet_traits<Scalar> PacketTraits;
120 const int max_size = PacketSize > 4 ? PacketSize : 4;
121 const int size = PacketSize*max_size;
126 RealScalar refvalue = 0;
129 data1[
i] = internal::random<Scalar>()/
RealScalar(PacketSize);
130 data2[
i] = internal::random<Scalar>()/
RealScalar(PacketSize);
151 packets[0] = internal::pload<Packet>(data1);
152 packets[1] = internal::pload<Packet>(data1+PacketSize);
153 if (
offset==0) internal::palign<0>(packets[0], packets[1]);
154 else if (
offset==1) internal::palign<1>(packets[0], packets[1]);
155 else if (
offset==2) internal::palign<2>(packets[0], packets[1]);
156 else if (
offset==3) internal::palign<3>(packets[0], packets[1]);
157 else if (
offset==4) internal::palign<4>(packets[0], packets[1]);
158 else if (
offset==5) internal::palign<5>(packets[0], packets[1]);
159 else if (
offset==6) internal::palign<6>(packets[0], packets[1]);
160 else if (
offset==7) internal::palign<7>(packets[0], packets[1]);
161 else if (
offset==8) internal::palign<8>(packets[0], packets[1]);
162 else if (
offset==9) internal::palign<9>(packets[0], packets[1]);
163 else if (
offset==10) internal::palign<10>(packets[0], packets[1]);
164 else if (
offset==11) internal::palign<11>(packets[0], packets[1]);
165 else if (
offset==12) internal::palign<12>(packets[0], packets[1]);
166 else if (
offset==13) internal::palign<13>(packets[0], packets[1]);
167 else if (
offset==14) internal::palign<14>(packets[0], packets[1]);
168 else if (
offset==15) internal::palign<15>(packets[0], packets[1]);
171 for (
int i=0;
i<PacketSize; ++
i)
177 VERIFY((!PacketTraits::Vectorizable) || PacketTraits::HasAdd);
178 VERIFY((!PacketTraits::Vectorizable) || PacketTraits::HasSub);
179 VERIFY((!PacketTraits::Vectorizable) || PacketTraits::HasMul);
180 VERIFY((!PacketTraits::Vectorizable) || PacketTraits::HasNegate);
193 for (
int i=0;
i<PacketSize; ++
i)
200 for (
int i=0;
i<PacketSize*4; ++
i)
201 ref[
i] = data1[
i/PacketSize];
202 Packet A0, A1, A2, A3;
203 internal::pbroadcast4<Packet>(data1, A0, A1, A2, A3);
208 VERIFY(
areApprox(ref, data2, 4*PacketSize) &&
"internal::pbroadcast4");
212 for (
int i=0;
i<PacketSize*2; ++
i)
213 ref[
i] = data1[
i/PacketSize];
215 internal::pbroadcast2<Packet>(data1, A0, A1);
218 VERIFY(
areApprox(ref, data2, 2*PacketSize) &&
"internal::pbroadcast2");
227 for(
int i=0;
i<PacketSize/2;++
i)
228 ref[2*
i+0] = ref[2*
i+1] = data1[
offset+
i];
238 for(
int i=0;
i<PacketSize/4;++
i)
239 ref[4*
i+0] = ref[4*
i+1] = ref[4*
i+2] = ref[4*
i+3] = data1[
offset+
i];
246 for (
int i=0;
i<PacketSize; ++
i)
251 for (
int i=0;
i<4; ++
i)
253 for (
int i=0;
i<PacketSize; ++
i)
254 ref[
i%4] += data1[
i];
256 VERIFY(
areApprox(ref, data2, PacketSize>4?PacketSize/2:PacketSize) &&
"internal::predux_downto4");
260 for (
int i=0;
i<PacketSize; ++
i)
264 for (
int j=0;
j<PacketSize; ++
j)
267 for (
int i=0;
i<PacketSize; ++
i)
268 ref[
j] += data1[
i+
j*PacketSize];
269 packets[
j] = internal::pload<Packet>(data1+
j*PacketSize);
274 for (
int i=0;
i<PacketSize; ++
i)
275 ref[
i] = data1[PacketSize-
i-1];
279 internal::PacketBlock<Packet> kernel;
280 for (
int i=0;
i<PacketSize; ++
i) {
281 kernel.packet[
i] = internal::pload<Packet>(data1+
i*PacketSize);
284 for (
int i=0;
i<PacketSize; ++
i) {
286 for (
int j = 0;
j < PacketSize; ++
j) {
291 if (PacketTraits::HasBlend) {
292 Packet thenPacket = internal::pload<Packet>(data1);
293 Packet elsePacket = internal::pload<Packet>(data2);
295 for (
int i = 0;
i < PacketSize; ++
i) {
296 selector.select[
i] =
i;
302 for (
int i = 0;
i < PacketSize; ++
i) {
309 for (
int i=0;
i<PacketSize; ++
i)
311 Scalar s = internal::random<Scalar>();
319 for (
int i=0;
i<PacketSize; ++
i)
321 Scalar s = internal::random<Scalar>();
322 ref[PacketSize-1] =
s;
331 typedef internal::packet_traits<Scalar> PacketTraits;
335 const int size = PacketSize*4;
342 data1[
i] = internal::random<Scalar>(-1,1) *
std::pow(
Scalar(10), internal::random<Scalar>(-3,3));
343 data2[
i] = internal::random<Scalar>(-1,1) *
std::pow(
Scalar(10), internal::random<Scalar>(-3,3));
355 data1[
i] = internal::random<Scalar>(-1,1);
356 data2[
i] = internal::random<Scalar>(-1,1);
363 data1[
i] = internal::random<Scalar>(-87,88);
364 data2[
i] = internal::random<Scalar>(-87,88);
369 data1[
i] = internal::random<Scalar>(-1,1) *
std::pow(
Scalar(10), internal::random<Scalar>(-6,6));
370 data2[
i] = internal::random<Scalar>(-1,1) *
std::pow(
Scalar(10), internal::random<Scalar>(-6,6));
375 data1[0] = std::numeric_limits<Scalar>::quiet_NaN();
394 data1[0] = std::numeric_limits<Scalar>::denorm_min();
395 data1[1] = -std::numeric_limits<Scalar>::denorm_min();
401 if (PacketTraits::HasTanh) {
403 data1[0] = std::numeric_limits<Scalar>::quiet_NaN();
409 #if EIGEN_HAS_C99_MATH 411 data1[0] = std::numeric_limits<Scalar>::quiet_NaN();
417 data1[0] = std::numeric_limits<Scalar>::quiet_NaN();
423 data1[0] = std::numeric_limits<Scalar>::quiet_NaN();
428 #endif // EIGEN_HAS_C99_MATH 432 data1[
i] = internal::random<Scalar>(0,1) *
std::pow(
Scalar(10), internal::random<Scalar>(-6,6));
433 data2[
i] = internal::random<Scalar>(0,1) *
std::pow(
Scalar(10), internal::random<Scalar>(-6,6));
436 if(internal::random<float>(0,1)<0.1
f)
437 data1[internal::random<int>(0, PacketSize)] = 0;
440 #if EIGEN_HAS_C99_MATH && (__cplusplus > 199711L) 449 data1[0] = std::numeric_limits<Scalar>::quiet_NaN();
468 data1[0] = std::numeric_limits<Scalar>::denorm_min();
469 data1[1] = -std::numeric_limits<Scalar>::denorm_min();
486 typedef internal::packet_traits<Scalar> PacketTraits;
497 for (
int i=0;
i<PacketSize; ++
i)
501 VERIFY((!PacketTraits::Vectorizable) || PacketTraits::HasMin);
502 VERIFY((!PacketTraits::Vectorizable) || PacketTraits::HasMax);
509 for (
int i=0;
i<PacketSize; ++
i)
513 for (
int i=0;
i<PacketSize; ++
i)
521 typedef internal::packet_traits<Scalar> PacketTraits;
525 internal::conj_if<ConjLhs> cj0;
526 internal::conj_if<ConjRhs> cj1;
527 internal::conj_helper<Scalar,Scalar,ConjLhs,ConjRhs> cj;
528 internal::conj_helper<Packet,Packet,ConjLhs,ConjRhs> pcj;
530 for(
int i=0;
i<PacketSize;++
i)
532 ref[
i] = cj0(data1[
i]) * cj1(data2[i]);
535 internal::pstore(pval,pcj.pmul(internal::pload<Packet>(data1),internal::pload<Packet>(data2)));
538 for(
int i=0;
i<PacketSize;++
i)
541 ref[
i] += cj0(data1[
i]) * cj1(data2[i]);
544 internal::pstore(pval,pcj.pmadd(internal::pload<Packet>(data1),internal::pload<Packet>(data2),internal::pload<Packet>(pval)));
550 typedef internal::packet_traits<Scalar> PacketTraits;
554 const int size = PacketSize*4;
562 data1[
i] = internal::random<Scalar>() *
Scalar(1e2);
563 data2[
i] = internal::random<Scalar>() *
Scalar(1e2);
566 test_conj_helper<Scalar,false,false> (data1,data2,
ref,pval);
567 test_conj_helper<Scalar,false,true> (data1,data2,
ref,pval);
568 test_conj_helper<Scalar,true,false> (data1,data2,
ref,pval);
569 test_conj_helper<Scalar,true,true> (data1,data2,
ref,pval);
572 for(
int i=0;
i<PacketSize;++
i)
581 typedef internal::packet_traits<Scalar> PacketTraits;
586 RealScalar refvalue = 0;
587 for (
int i=0;
i<PacketSize; ++
i) {
588 data1[
i] = internal::random<Scalar>()/
RealScalar(PacketSize);
591 int stride = internal::random<int>(1,20);
594 memset(buffer, 0, 20*PacketSize*
sizeof(
Scalar));
595 Packet packet = internal::pload<Packet>(data1);
596 internal::pscatter<Scalar, Packet>(buffer, packet, stride);
598 for (
int i = 0;
i < PacketSize*20; ++
i) {
599 if ((
i%stride) == 0 &&
i<stride*PacketSize) {
606 for (
int i=0;
i<PacketSize*7; ++
i) {
607 buffer[
i] = internal::random<Scalar>()/
RealScalar(PacketSize);
609 packet = internal::pgather<Scalar, Packet>(buffer, 7);
611 for (
int i = 0;
i < PacketSize; ++
i) {
619 CALL_SUBTEST_1( packetmath<float>() );
620 CALL_SUBTEST_2( packetmath<double>() );
621 CALL_SUBTEST_3( packetmath<int>() );
622 CALL_SUBTEST_4(
packetmath<std::complex<float> >() );
623 CALL_SUBTEST_5(
packetmath<std::complex<double> >() );
625 CALL_SUBTEST_1( packetmath_notcomplex<float>() );
626 CALL_SUBTEST_2( packetmath_notcomplex<double>() );
627 CALL_SUBTEST_3( packetmath_notcomplex<int>() );
629 CALL_SUBTEST_1( packetmath_real<float>() );
630 CALL_SUBTEST_2( packetmath_real<double>() );
635 CALL_SUBTEST_1( packetmath_scatter_gather<float>() );
636 CALL_SUBTEST_2( packetmath_scatter_gather<double>() );
637 CALL_SUBTEST_3( packetmath_scatter_gather<int>() );
internal::packet_traits< Scalar >::type Packet
EIGEN_DEVICE_FUNC bool isMuchSmallerThan(const Scalar &x, const OtherScalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pasin(const Packet &a)
EIGEN_STRONG_INLINE Packet4cf pinsertfirst(const Packet4cf &a, std::complex< float > b)
EIGEN_DEVICE_FUNC const ErfReturnType erf() const
EIGEN_DEVICE_FUNC const ExpReturnType exp() const
EIGEN_DEVICE_FUNC unpacket_traits< Packet >::type predux_min(const Packet &a)
A matrix or vector expression mapping an existing array of data.
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet perf(const Packet &a)
EIGEN_DEVICE_FUNC unpacket_traits< Packet >::type predux_max(const Packet &a)
EIGEN_DEVICE_FUNC const TanhReturnType tanh() const
EIGEN_DEVICE_FUNC const LogReturnType log() const
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics set mxtics default set mytics default set mx2tics default set my2tics default set xtics border mirror norotate autofreq set ytics border mirror norotate autofreq set ztics border nomirror norotate autofreq set nox2tics set noy2tics set timestamp bottom norotate offset
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
Namespace containing all symbols from the Eigen library.
T load(const T *from) const
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet psqrt(const Packet &a)
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet ptanh(const Packet &a)
void packetmath_notcomplex()
EIGEN_DEVICE_FUNC unpacket_traits< Packet >::type predux(const Packet &a)
void test_conj_helper(Scalar *data1, Scalar *data2, Scalar *ref, Scalar *pval)
EIGEN_STRONG_INLINE Packet2cf pcplxflip(const Packet2cf &x)
#define EIGEN_DONT_INLINE
EIGEN_DEVICE_FUNC Packet preduxp(const Packet *vecs)
EIGEN_DEVICE_FUNC Packet padd(const Packet &a, const Packet &b)
EIGEN_DEVICE_FUNC T() ceil(const T &x)
EIGEN_DEVICE_FUNC Packet pmin(const Packet &a, const Packet &b)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pexp(const Packet &a)
EIGEN_DEVICE_FUNC const RoundReturnType round() const
EIGEN_DEVICE_FUNC const CosReturnType cos() const
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pceil(const Packet &a)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet ptan(const Packet &a)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet plog1p(const Packet &a)
EIGEN_DEVICE_FUNC void pstoreu(Scalar *to, const Packet &from)
#define VERIFY_IS_EQUAL(a, b)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet plgamma(const Packet &a)
EIGEN_DEVICE_FUNC const Log1pReturnType log1p() const
void store(T *to, const T &x) const
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pacos(const Packet &a)
#define CHECK_CWISE1_IF(COND, REFOP, POP)
bool areApprox(const Scalar *a, const Scalar *b, int size)
const bool g_vectorize_sse
EIGEN_STRONG_INLINE void ptranspose(PacketBlock< Packet2cf, 2 > &kernel)
bool areApproxAbs(const Scalar *a, const Scalar *b, int size, const typename NumTraits< Scalar >::Real &refvalue)
void packetmath_complex()
EIGEN_DEVICE_FUNC T() floor(const T &x)
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
EIGEN_DEVICE_FUNC unpacket_traits< Packet >::type pfirst(const Packet &a)
EIGEN_DEVICE_FUNC bool() isnan(const T &x)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet perfc(const Packet &a)
EIGEN_DEVICE_FUNC const TanReturnType tan() const
EIGEN_STRONG_INLINE Packet2cf pconj(const Packet2cf &a)
NumTraits< Scalar >::Real RealScalar
EIGEN_DEVICE_FUNC void pstore(Scalar *to, const Packet &from)
EIGEN_DEVICE_FUNC const ErfcReturnType erfc() const
EIGEN_DEVICE_FUNC const AcosReturnType acos() const
EIGEN_STRONG_INLINE Packet2cf pnegate(const Packet2cf &a)
EIGEN_DEVICE_FUNC Packet pdiv(const Packet &a, const Packet &b)
#define CHECK_CWISE2_IF(COND, REFOP, POP)
EIGEN_DONT_INLINE bool isApproxAbs(const Scalar &a, const Scalar &b, const typename NumTraits< Scalar >::Real &refvalue)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pfloor(const Packet &a)
EIGEN_DEVICE_FUNC unpacket_traits< Packet >::type predux_mul(const Packet &a)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet plog(const Packet &a)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pround(const Packet &a)
static ConstMapType Map(const Scalar *data)
EIGEN_DEVICE_FUNC Packet psub(const Packet &a, const Packet &b)
EIGEN_STRONG_INLINE Packet4cf pinsertlast(const Packet4cf &a, std::complex< float > b)
void packetmath_scatter_gather()
EIGEN_DEVICE_FUNC const ImagReturnType imag() const
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pcos(const Packet &a)
EIGEN_DEVICE_FUNC const SinReturnType sin() const
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet psin(const Packet &a)
void store(T *to, const Packet &x) const
Jet< T, N > pow(const Jet< T, N > &f, double g)
#define CHECK_CWISE1(REFOP, POP)
Packet load(const T *from) const
The matrix class, also used for vectors and row-vectors.
EIGEN_DEVICE_FUNC bool isApprox(const Scalar &x, const Scalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
EIGEN_DEVICE_FUNC Packet pmul(const Packet &a, const Packet &b)
EIGEN_DEVICE_FUNC const AsinReturnType asin() const
EIGEN_DEVICE_FUNC Packet pmax(const Packet &a, const Packet &b)
EIGEN_DEVICE_FUNC conditional<(unpacket_traits< Packet >::size%8)==0, typename unpacket_traits< Packet >::half, Packet >::type predux_downto4(const Packet &a)
EIGEN_STRONG_INLINE Packet4i pblend(const Selector< 4 > &ifPacket, const Packet4i &thenPacket, const Packet4i &elsePacket)
ScalarWithExceptions conj(const ScalarWithExceptions &x)
EIGEN_STRONG_INLINE Packet2cf preverse(const Packet2cf &a)
EIGEN_DEVICE_FUNC const LgammaReturnType lgamma() const
EIGEN_STRONG_INLINE Packet4f pabs(const Packet4f &a)