32 return a > b ? a -
b : b -
a;
53 const T out =
static_cast<T>(frexp(x, &iexp));
54 exp =
static_cast<T>(iexp);
61 return static_cast<T>(ldexp(x, static_cast<int>(exp)));
65 template <
typename SrcPacket,
typename TgtPacket,
int SrcCoeffRatio,
int TgtCoeffRatio>
68 template <
typename SrcPacket,
typename TgtPacket,
int TgtCoeffRatio>
72 static void cast(
const SrcScalar* src,
size_t size, TgtScalar* dst) {
76 for (i = 0; i < size && i + SrcPacketSize <=
size; i += TgtPacketSize) {
77 internal::pstoreu(dst + i, internal::pcast<SrcPacket, TgtPacket>(internal::ploadu<SrcPacket>(src + i)));
80 for (; i <
size; ++
i) {
81 dst[
i] =
static_cast<TgtScalar
>(src[
i]);
86 template <
typename SrcPacket,
typename TgtPacket>
92 for (
size_t i = 0;
i <
size;
i += TgtPacketSize) {
93 SrcPacket
a = internal::ploadu<SrcPacket>(src +
i);
94 SrcPacket
b = internal::ploadu<SrcPacket>(src +
i + SrcPacketSize);
100 template <
typename SrcPacket,
typename TgtPacket>
106 for (
size_t i = 0;
i <
size;
i += TgtPacketSize) {
107 SrcPacket
a = internal::ploadu<SrcPacket>(src +
i);
108 SrcPacket
b = internal::ploadu<SrcPacket>(src +
i + SrcPacketSize);
109 SrcPacket
c = internal::ploadu<SrcPacket>(src +
i + 2 * SrcPacketSize);
110 SrcPacket
d = internal::ploadu<SrcPacket>(src +
i + 3 * SrcPacketSize);
116 template <
typename SrcPacket,
typename TgtPacket>
122 for (
size_t i = 0;
i <
size;
i += TgtPacketSize) {
123 SrcPacket
a = internal::ploadu<SrcPacket>(src +
i);
124 SrcPacket
b = internal::ploadu<SrcPacket>(src +
i + SrcPacketSize);
125 SrcPacket
c = internal::ploadu<SrcPacket>(src +
i + 2 * SrcPacketSize);
126 SrcPacket
d = internal::ploadu<SrcPacket>(src +
i + 3 * SrcPacketSize);
127 SrcPacket
e = internal::ploadu<SrcPacket>(src +
i + 4 * SrcPacketSize);
128 SrcPacket
f = internal::ploadu<SrcPacket>(src +
i + 5 * SrcPacketSize);
129 SrcPacket
g = internal::ploadu<SrcPacket>(src +
i + 6 * SrcPacketSize);
130 SrcPacket
h = internal::ploadu<SrcPacket>(src +
i + 7 * SrcPacketSize);
131 internal::pstoreu(dst +
i, internal::pcast<SrcPacket, TgtPacket>(a, b, c, d, e, f, g, h));
136 template <
typename SrcPacket,
typename TgtPacket,
int SrcCoeffRatio,
int TgtCoeffRatio,
bool CanCast = false>
139 template <
typename SrcPacket,
typename TgtPacket,
int SrcCoeffRatio,
int TgtCoeffRatio>
144 template <
typename SrcPacket,
typename TgtPacket,
int SrcCoeffRatio,
int TgtCoeffRatio>
151 static const int BlockSize = SrcPacketSize * SrcCoeffRatio;
152 eigen_assert(BlockSize == TgtPacketSize * TgtCoeffRatio &&
"Packet sizes and cast ratios are mismatched.");
154 static const int DataSize = 10 * BlockSize;
160 for (
int i = 0;
i < DataSize; ++
i) {
164 for (
int i = 0;
i < DataSize; ++
i) {
165 ref[
i] =
static_cast<const TgtScalar
>(data1[
i]);
174 template <
typename SrcPacket,
typename TgtPacket>
179 typedef typename internal::type_casting_traits<SrcScalar, TgtScalar> TypeCastingTraits;
180 static const int SrcCoeffRatio = TypeCastingTraits::SrcCoeffRatio;
181 static const int TgtCoeffRatio = TypeCastingTraits::TgtCoeffRatio;
184 static const bool HasCast =
185 internal::unpacket_traits<SrcPacket>::vectorizable && internal::unpacket_traits<TgtPacket>::vectorizable &&
186 TypeCastingTraits::VectorizedCast && (SrcPacketSize * SrcCoeffRatio == TgtPacketSize * TgtCoeffRatio);
191 template <
typename SrcPacket,
typename TgtScalar,
193 bool Vectorized = internal::packet_traits<TgtScalar>::Vectorizable,
194 bool HasHalf = !internal::is_same<typename internal::unpacket_traits<TgtPacket>::half, TgtPacket>
::value>
197 template <
typename SrcPacket,
typename TgtScalar,
typename TgtPacket>
202 template <
typename SrcPacket,
typename TgtScalar,
typename TgtPacket>
210 template <
typename SrcPacket,
typename TgtScalar,
typename TgtPacket>
215 template <
typename Scalar,
typename Packet,
typename EnableIf =
void>
237 template <
typename Scalar,
typename Packet>
247 template <
typename Scalar,
typename Packet>
250 const int size = 2 * PacketSize;
255 for (
int i = 0;
i <
size; ++
i) {
256 data1[
i] = internal::random<Scalar>();
260 for (
int i = 0;
i < PacketSize; ++
i) {
262 data1[
i + PacketSize] = internal::random<bool>() ? data1[
i] :
Scalar(0);
268 for (
int i = 0;
i < PacketSize; ++
i) {
270 data1[
i + PacketSize] = internal::random<bool>() ? data1[
i] :
Scalar(0);
275 for (
int i = 0;
i < PacketSize; ++
i) {
277 data1[
i + PacketSize] = internal::random<bool>() ? data1[
i] :
Scalar(0);
282 template <
typename Scalar,
typename Packet>
285 const int size = 2 * PacketSize;
290 for (
int i = 0;
i < PacketSize; ++
i) {
291 data1[
i] = internal::random<Scalar>();
292 data1[
i + PacketSize] = internal::random<bool>() ? data1[
i] :
Scalar(0);
298 for (
int i = 0;
i < PacketSize; ++
i) {
300 data1[
i + PacketSize] = internal::random<bool>() ? data1[
i] :
Scalar(0);
305 for (
int i = 0;
i < PacketSize; ++
i) {
307 data1[
i + PacketSize] = internal::random<bool>() ? data1[
i] :
Scalar(0);
312 template <
typename Scalar,
typename Packet>
315 const int size = 2 * PacketSize;
320 for (
int i = 0;
i < PacketSize; ++
i) {
321 data1[
i] = internal::random<Scalar>();
322 data1[
i + PacketSize] = internal::random<bool>() ? data1[
i] :
Scalar(0);
329 for (
int i = 0;
i < PacketSize; ++
i) {
331 data1[
i + PacketSize] = internal::random<bool>() ? data1[
i] :
Scalar(0);
337 for (
int i = 0;
i < PacketSize; ++
i) {
339 data1[
i + PacketSize] = internal::random<bool>() ? data1[
i] :
Scalar(0);
352 template <
typename Scalar,
typename Packet>
355 const int size = 2 * PacketSize;
360 for (
int i = 0;
i < PacketSize; ++
i) {
362 data1[
i + PacketSize] =
Scalar(-0.0);
371 template<
typename Packet,
typename EnableIf =
void>
376 template<
typename Packet>
378 !NumTraits<Packet>::IsComplex &&
379 !internal::is_same<Packet, Eigen::half>::value &&
380 !internal::is_same<Packet, Eigen::bfloat16>::value
384 Scalar
s = internal::random<Scalar>();
385 Packet barrier = internal::pset1<Packet>(
s);
391 template <
typename Scalar,
typename Packet>
393 typedef internal::packet_traits<Scalar> PacketTraits;
398 std::cerr <<
"=== Testing packet of type '" <<
typeid(
Packet).
name() <<
"' and scalar type '" 399 <<
typeid(
Scalar).
name() <<
"' and size '" << PacketSize <<
"' ===\n";
401 const int max_size = PacketSize > 4 ? PacketSize : 4;
402 const int size = PacketSize * max_size;
412 for (
int i = 0;
i <
size; ++
i) {
413 data1[
i] = internal::random<Scalar>() /
RealScalar(PacketSize);
414 data2[
i] = internal::random<Scalar>() /
RealScalar(PacketSize);
431 if (internal::unpacket_traits<Packet>::masked_load_available) {
432 test::packet_helper<internal::unpacket_traits<Packet>::masked_load_available,
Packet>
h;
433 unsigned long long max_umask = (0x1ull << PacketSize);
436 for (
unsigned long long umask = 0; umask < max_umask; ++umask) {
437 h.store(data2, h.load(data1 +
offset, umask));
438 for (
int k = 0; k < PacketSize; ++k) data3[k] = ((umask & (0x1ull << k)) >> k) ? data1[k +
offset] :
Scalar(0);
444 if (internal::unpacket_traits<Packet>::masked_store_available) {
445 test::packet_helper<internal::unpacket_traits<Packet>::masked_store_available,
Packet>
h;
446 unsigned long long max_umask = (0x1ull << PacketSize);
449 for (
unsigned long long umask = 0; umask < max_umask; ++umask) {
451 h.store(data2, h.loadu(data1 +
offset), umask);
452 for (
int k = 0; k < PacketSize; ++k) data3[k] = ((umask & (0x1ull << k)) >> k) ? data1[k +
offset] :
Scalar(0);
458 VERIFY((!PacketTraits::Vectorizable) || PacketTraits::HasAdd);
459 VERIFY((!PacketTraits::Vectorizable) || PacketTraits::HasSub);
460 VERIFY((!PacketTraits::Vectorizable) || PacketTraits::HasMul);
471 for (
int i = 0;
i < PacketSize; ++
i) ref[
i] = data1[
offset];
477 for (
int i = 0;
i < PacketSize * 4; ++
i) ref[
i] = data1[
i / PacketSize];
479 internal::pbroadcast4<Packet>(data1, A0,
A1, A2, A3);
488 for (
int i = 0;
i < PacketSize * 2; ++
i) ref[
i] = data1[
i / PacketSize];
490 internal::pbroadcast2<Packet>(data1, A0,
A1);
498 if (PacketSize > 1) {
501 for (
int i = 0;
i < PacketSize / 2; ++
i) ref[2 *
i + 0] = ref[2 *
i + 1] = data1[
offset +
i];
507 if (PacketSize > 2) {
510 for (
int i = 0;
i < PacketSize / 4; ++
i)
511 ref[4 *
i + 0] = ref[4 *
i + 1] = ref[4 *
i + 2] = ref[4 *
i + 3] = data1[
offset +
i];
518 for (
int i = 0;
i < PacketSize; ++
i) ref[0] += data1[
i];
522 int HalfPacketSize = PacketSize > 4 ? PacketSize / 2 : PacketSize;
523 for (
int i = 0;
i < HalfPacketSize; ++
i) ref[
i] =
Scalar(0);
524 for (
int i = 0;
i < PacketSize; ++
i) ref[
i % HalfPacketSize] += data1[
i];
530 for (
int i = 0;
i < PacketSize; ++
i) ref[0] =
REF_MUL(ref[0], data1[
i]);
533 for (
int i = 0; i < PacketSize; ++
i) ref[i] = data1[PacketSize - i - 1];
537 internal::PacketBlock<Packet> kernel;
538 for (
int i = 0; i < PacketSize; ++
i) {
539 kernel.packet[
i] = internal::pload<Packet>(data1 + i * PacketSize);
542 for (
int i = 0; i < PacketSize; ++
i) {
544 for (
int j = 0;
j < PacketSize; ++
j) {
550 if (PacketSize > 4 && PacketSize % 4 == 0) {
551 internal::PacketBlock<Packet, PacketSize%4==0?4:PacketSize> kernel2;
552 for (
int i = 0; i < 4; ++
i) {
553 kernel2.packet[
i] = internal::pload<Packet>(data1 + i * PacketSize);
556 int data_counter = 0;
557 for (
int i = 0; i < PacketSize; ++
i) {
558 for (
int j = 0;
j < 4; ++
j) {
559 data2[data_counter++] = data1[
j*PacketSize +
i];
562 for (
int i = 0; i < 4; ++
i) {
564 for (
int j = 0;
j < PacketSize; ++
j) {
570 if (PacketTraits::HasBlend) {
571 Packet thenPacket = internal::pload<Packet>(data1);
572 Packet elsePacket = internal::pload<Packet>(data2);
574 for (
int i = 0; i < PacketSize; ++
i) {
575 selector.select[
i] =
i;
581 for (
int i = 0; i < PacketSize; ++
i) {
587 for (
int i = 0; i < PacketSize; ++
i) {
589 unsigned char v = internal::random<bool>() ? 0xff : 0;
590 char*
bytes = (
char*)(data1 + i);
591 for (
int k = 0; k <
int(
sizeof(
Scalar)); ++k) {
595 data1[i + PacketSize] = internal::random<Scalar>();
597 data1[i + 2 * PacketSize] = internal::random<Scalar>();
602 for (
int i = 0; i <
size; ++
i) {
603 data1[
i] = internal::random<Scalar>();
610 packetmath_boolean_mask_ops<Scalar, Packet>();
612 packetmath_minus_zero_add<Scalar, Packet>();
614 for (
int i = 0; i <
size; ++
i) {
623 template <
typename Scalar>
628 template <
typename Scalar,
typename Packet>
630 typedef internal::packet_traits<Scalar> PacketTraits;
633 const int size = PacketSize * 4;
638 for (
int i = 0;
i <
size; ++
i) {
639 data1[
i] =
Scalar(internal::random<double>(0, 1) *
std::pow(10., internal::random<double>(-6, 6)));
640 data2[
i] =
Scalar(internal::random<double>(0, 1) *
std::pow(10., internal::random<double>(-6, 6)));
643 if (internal::random<float>(0, 1) < 0.1
f) data1[internal::random<int>(0, PacketSize)] =
Scalar(0);
649 for (
int i = 0;
i <
size; ++
i) {
650 data1[
i] =
Scalar(internal::random<double>(-1, 1) *
std::pow(10., internal::random<double>(-3, 3)));
651 data2[
i] =
Scalar(internal::random<double>(-1, 1) *
std::pow(10., internal::random<double>(-3, 3)));
662 packetmath_boolean_mask_ops_real<Scalar,Packet>();
665 if (PacketTraits::HasRound || PacketTraits::HasCeil || PacketTraits::HasFloor || PacketTraits::HasRint) {
671 std::vector<Scalar>
values;
672 while (val >
Scalar(0.25)) {
674 values.push_back(val);
675 values.push_back(val +
Scalar(0.3));
676 values.push_back(val +
Scalar(0.5));
677 values.push_back(val +
Scalar(0.8));
678 values.push_back(val +
Scalar(1));
679 values.push_back(val +
Scalar(1.3));
680 values.push_back(val +
Scalar(1.5));
681 values.push_back(val +
Scalar(1.8));
682 values.push_back(-val);
683 values.push_back(-val -
Scalar(0.3));
684 values.push_back(-val -
Scalar(0.5));
685 values.push_back(-val -
Scalar(0.8));
686 values.push_back(-val -
Scalar(1));
687 values.push_back(-val -
Scalar(1.3));
688 values.push_back(-val -
Scalar(1.5));
689 values.push_back(-val -
Scalar(1.8));
690 values.push_back(
Scalar(-1.5) + val);
697 for (
size_t k=0; k<values.size(); ++k) {
698 data1[0] = values[k];
706 for (
int i = 0;
i <
size; ++
i) {
707 data1[
i] =
Scalar(internal::random<double>(-1, 1));
708 data2[
i] =
Scalar(internal::random<double>(-1, 1));
713 for (
int i = 0;
i <
size; ++
i) {
714 data1[
i] =
Scalar(internal::random<double>(-87, 88));
715 data2[
i] =
Scalar(internal::random<double>(-87, 88));
720 if (PacketTraits::HasExp) {
722 for (
int j=0;
j<3; ++
j) {
725 data1[0] = -data1[0];
734 test::packet_helper<PacketTraits::HasExp,Packet>
h;
740 for (
int i=0;
i<3; ++
i) {
741 data1[0] = special[
i];
743 h.store(data2,
internal::pfrexp(h.load(data1), h.forward_reference(pout, sout)));
748 for (
int i = 0;
i < PacketSize; ++
i) {
749 data1[
i] =
Scalar(internal::random<double>(-1, 1));
750 data2[
i] =
Scalar(internal::random<double>(-1, 1));
752 for (
int i = 0;
i < PacketSize; ++
i) {
753 data1[
i+PacketSize] =
Scalar(internal::random<int>(-4, 4));
754 data2[
i+PacketSize] =
Scalar(internal::random<double>(-4, 4));
757 if (PacketTraits::HasExp) {
789 for (
int i = 0;
i <
size; ++
i) {
790 data1[
i] =
Scalar(internal::random<double>(-1, 1) *
std::pow(10., internal::random<double>(-6, 6)));
791 data2[
i] =
Scalar(internal::random<double>(-1, 1) *
std::pow(10., internal::random<double>(-6, 6)));
795 if (PacketTraits::HasExp && PacketSize >= 2) {
799 test::packet_helper<PacketTraits::HasExp, Packet>
h;
822 data1[0] = std::numeric_limits<Scalar>::denorm_min();
823 data1[1] = -std::numeric_limits<Scalar>::denorm_min();
829 if (PacketTraits::HasTanh) {
832 test::packet_helper<internal::packet_traits<Scalar>::HasTanh,
Packet>
h;
837 if (PacketTraits::HasExp) {
838 internal::scalar_logistic_op<Scalar>
logistic;
839 for (
int i = 0;
i <
size; ++
i) {
840 data1[
i] =
Scalar(internal::random<double>(-20, 20));
843 test::packet_helper<PacketTraits::HasExp, Packet>
h;
844 h.store(data2, logistic.packetOp(h.load(data1)));
845 for (
int i = 0;
i < PacketSize; ++
i) {
850 #if EIGEN_HAS_C99_MATH && (EIGEN_COMP_CXXVER >= 11) 859 if (PacketSize >= 2) {
862 if (PacketTraits::HasLog) {
863 test::packet_helper<PacketTraits::HasLog, Packet>
h;
888 if (std::numeric_limits<Scalar>::has_denorm == std::denorm_present) {
889 data1[0] = std::numeric_limits<Scalar>::denorm_min();
890 data1[1] = -std::numeric_limits<Scalar>::denorm_min();
906 if (PacketTraits::HasLog1p) {
907 test::packet_helper<PacketTraits::HasLog1p, Packet>
h;
914 if (PacketTraits::HasSqrt) {
915 test::packet_helper<PacketTraits::HasSqrt, Packet>
h;
917 if (std::numeric_limits<Scalar>::has_denorm == std::denorm_present) {
918 data1[1] = -std::numeric_limits<Scalar>::denorm_min();
927 if (PacketTraits::HasCos
930 test::packet_helper<PacketTraits::HasCos, Packet>
h;
932 for (
int k1 = 0; k1 <= 1; ++k1) {
933 data1[0] =
Scalar((2 *
double(k) + k1) *
double(
EIGEN_PI) / 2 * internal::random<double>(0.8, 1.2));
934 data1[1] =
Scalar((2 *
double(k) + 2 + k1) *
double(
EIGEN_PI) / 2 * internal::random<double>(0.8, 1.2));
977 #define CAST_CHECK_CWISE1_IF(COND, REFOP, POP, SCALAR, REFTYPE) if(COND) { \ 978 test::packet_helper<COND,Packet> h; \ 979 for (int i=0; i<PacketSize; ++i) \ 980 ref[i] = SCALAR(REFOP(static_cast<REFTYPE>(data1[i]))); \ 981 h.store(data2, POP(h.load(data1))); \ 982 VERIFY(test::areApprox(ref, data2, PacketSize) && #POP); \ 985 template <
typename Scalar>
992 template <
typename Scalar>
999 template <
typename Scalar>
1006 template <
typename Scalar>
1013 template <
typename Scalar,
typename Packet>
1015 typedef internal::packet_traits<Scalar> PacketTraits;
1024 VERIFY((!PacketTraits::Vectorizable) || PacketTraits::HasMin);
1025 VERIFY((!PacketTraits::Vectorizable) || PacketTraits::HasMax);
1039 for (
int i = 0; i < PacketSize; ++
i) ref[0] =
internal::pmax(ref[0], data1[i]);
1042 for (
int i = 0; i < PacketSize; ++
i) ref[i] = data1[0] +
Scalar(i);
1047 unsigned char* data1_bits =
reinterpret_cast<unsigned char*
>(data1);
1059 for (
unsigned int i = 0; i < PacketSize *
sizeof(
Scalar); ++
i) data1_bits[i] = 0
x0;
1061 for (
int k = 0; k < PacketSize; ++k) {
1062 for (
unsigned int i = 0; i <
sizeof(
Scalar); ++
i) data1_bits[k *
sizeof(
Scalar) +
i] = 0xff;
1064 for (
unsigned int i = 0; i <
sizeof(
Scalar); ++
i) data1_bits[k *
sizeof(
Scalar) +
i] = 0x00;
1073 for (
int i = 0; i < PacketSize; ++i) ref[0] = internal::pmin<PropagateNumbers>(ref[0], data1[
i]);
1074 VERIFY(
internal::isApprox(ref[0], internal::predux_min<PropagateNumbers>(internal::pload<Packet>(data1))) &&
"internal::predux_min<PropagateNumbers>");
1076 for (
int i = 0; i < PacketSize; ++i) ref[0] = internal::pmin<PropagateNaN>(ref[0], data1[
i]);
1077 VERIFY(
internal::isApprox(ref[0], internal::predux_min<PropagateNaN>(internal::pload<Packet>(data1))) &&
"internal::predux_min<PropagateNaN>");
1079 for (
int i = 0; i < PacketSize; ++i) ref[0] = internal::pmax<PropagateNumbers>(ref[0], data1[
i]);
1080 VERIFY(
internal::isApprox(ref[0], internal::predux_max<PropagateNumbers>(internal::pload<Packet>(data1))) &&
"internal::predux_max<PropagateNumbers>");
1082 for (
int i = 0; i < PacketSize; ++i) ref[0] = internal::pmax<PropagateNaN>(ref[0], data1[
i]);
1083 VERIFY(
internal::isApprox(ref[0], internal::predux_max<PropagateNaN>(internal::pload<Packet>(data1))) &&
"internal::predux_max<PropagateNumbers>");
1085 const size_t index = std::numeric_limits<size_t>::quiet_NaN() % PacketSize;
1087 VERIFY(PacketSize==1 || !(
numext::isnan)(internal::predux_min<PropagateNumbers>(internal::pload<Packet>(data1))));
1088 VERIFY((
numext::isnan)(internal::predux_min<PropagateNaN>(internal::pload<Packet>(data1))));
1089 VERIFY(PacketSize==1 || !(
numext::isnan)(internal::predux_max<PropagateNumbers>(internal::pload<Packet>(data1))));
1090 VERIFY((
numext::isnan)(internal::predux_max<PropagateNaN>(internal::pload<Packet>(data1))));
1092 for (
int i = 0; i < 4 * PacketSize; ++i) data1[i] = NumTraits<Scalar>::quiet_NaN();
1093 VERIFY((
numext::isnan)(internal::predux_min<PropagateNumbers>(internal::pload<Packet>(data1))));
1094 VERIFY((
numext::isnan)(internal::predux_min<PropagateNaN>(internal::pload<Packet>(data1))));
1095 VERIFY((
numext::isnan)(internal::predux_max<PropagateNumbers>(internal::pload<Packet>(data1))));
1096 VERIFY((
numext::isnan)(internal::predux_max<PropagateNaN>(internal::pload<Packet>(data1))));
1099 for (
int i = 0; i < PacketSize; ++
i) {
1110 packetmath_boolean_mask_ops_notcomplex<Scalar, Packet>();
1113 template <
typename Scalar,
typename Packet,
bool ConjLhs,
bool ConjRhs>
1117 internal::conj_if<ConjLhs> cj0;
1118 internal::conj_if<ConjRhs> cj1;
1119 internal::conj_helper<Scalar, Scalar, ConjLhs, ConjRhs> cj;
1120 internal::conj_helper<Packet, Packet, ConjLhs, ConjRhs> pcj;
1122 for (
int i = 0;
i < PacketSize; ++
i) {
1123 ref[
i] = cj0(data1[
i]) * cj1(data2[i]);
1126 internal::pstore(pval, pcj.pmul(internal::pload<Packet>(data1), internal::pload<Packet>(data2)));
1129 for (
int i = 0;
i < PacketSize; ++
i) {
1131 ref[
i] += cj0(data1[
i]) * cj1(data2[i]);
1135 pval, pcj.pmadd(internal::pload<Packet>(data1), internal::pload<Packet>(data2), internal::pload<Packet>(pval)));
1139 template <
typename Scalar,
typename Packet>
1141 typedef internal::packet_traits<Scalar> PacketTraits;
1142 typedef typename Scalar::value_type
RealScalar;
1145 const int size = PacketSize * 4;
1151 for (
int i = 0;
i <
size; ++
i) {
1152 data1[
i] = internal::random<Scalar>() *
Scalar(1e2);
1153 data2[
i] = internal::random<Scalar>() *
Scalar(1e2);
1156 test_conj_helper<Scalar, Packet, false, false>(data1, data2,
ref, pval);
1157 test_conj_helper<Scalar, Packet, false, true>(data1, data2,
ref, pval);
1158 test_conj_helper<Scalar, Packet, true, false>(data1, data2,
ref, pval);
1159 test_conj_helper<Scalar, Packet, true, true>(data1, data2,
ref, pval);
1168 if (PacketTraits::HasSqrt) {
1169 for (
int i = 0;
i <
size; ++
i) {
1170 data1[
i] =
Scalar(internal::random<RealScalar>(), internal::random<RealScalar>());
1177 const RealScalar
inf = std::numeric_limits<RealScalar>::infinity();
1178 const RealScalar nan = std::numeric_limits<RealScalar>::quiet_NaN();
1179 data1[0] =
Scalar(zero, zero);
1180 data1[1] =
Scalar(-zero, zero);
1181 data1[2] =
Scalar(one, zero);
1182 data1[3] =
Scalar(zero, one);
1184 data1[0] =
Scalar(-one, zero);
1185 data1[1] =
Scalar(zero, -one);
1186 data1[2] =
Scalar(one, one);
1187 data1[3] =
Scalar(-one, -one);
1189 data1[0] =
Scalar(inf, zero);
1190 data1[1] =
Scalar(zero, inf);
1191 data1[2] =
Scalar(-inf, zero);
1192 data1[3] =
Scalar(zero, -inf);
1194 data1[0] =
Scalar(inf, inf);
1195 data1[1] =
Scalar(-inf, inf);
1196 data1[2] =
Scalar(inf, -inf);
1197 data1[3] =
Scalar(-inf, -inf);
1199 data1[0] =
Scalar(nan, zero);
1200 data1[1] =
Scalar(zero, nan);
1201 data1[2] =
Scalar(nan, one);
1202 data1[3] =
Scalar(one, nan);
1204 data1[0] =
Scalar(nan, nan);
1205 data1[1] =
Scalar(inf, nan);
1206 data1[2] =
Scalar(nan, inf);
1207 data1[3] =
Scalar(-inf, nan);
1212 template <
typename Scalar,
typename Packet>
1218 for (
int i = 0;
i < PacketSize; ++
i) {
1219 data1[
i] = internal::random<Scalar>() /
RealScalar(PacketSize);
1222 int stride = internal::random<int>(1, 20);
1227 Packet packet = internal::pload<Packet>(data1);
1228 internal::pscatter<Scalar, Packet>(buffer, packet, stride);
1230 for (
int i = 0;
i < PacketSize * 20; ++
i) {
1231 if ((
i % stride) == 0 &&
i < stride * PacketSize) {
1238 for (
int i = 0;
i < PacketSize * 7; ++
i) {
1239 buffer[
i] = internal::random<Scalar>() /
RealScalar(PacketSize);
1241 packet = internal::pgather<Scalar, Packet>(buffer, 7);
1243 for (
int i = 0;
i < PacketSize; ++
i) {
1251 template <
typename Scalar,
typename PacketType>
1254 packetmath<Scalar, PacketType>();
1255 packetmath_scatter_gather<Scalar, PacketType>();
1256 packetmath_notcomplex<Scalar, PacketType>();
1257 packetmath_real<Scalar, PacketType>();
1261 template <
typename Scalar,
typename PacketType>
1264 packetmath<Scalar, PacketType>();
1265 packetmath_scatter_gather<Scalar, PacketType>();
1266 packetmath_notcomplex<Scalar, PacketType>();
1270 template <
typename Scalar,
typename PacketType>
1273 packetmath<Scalar, PacketType>();
1274 packetmath_scatter_gather<Scalar, PacketType>();
1275 packetmath_complex<Scalar, PacketType>();
EIGEN_DEVICE_FUNC const Log1pReturnType log1p() const
EIGEN_DONT_INLINE bool isApproxAbs(const Scalar &a, const Scalar &b, const typename NumTraits< Scalar >::Real &refvalue)
internal::packet_traits< Scalar >::type Packet
T REF_SUB(const T &a, const T &b)
Scalar propagate_nan_min(const Scalar &a, const Scalar &b)
#define CALL_SUBTEST_12(FUNC)
#define CHECK_CWISE3_IF(COND, REFOP, POP)
#define CALL_SUBTEST_9(FUNC)
#define CALL_SUBTEST_6(FUNC)
#define CALL_SUBTEST_4(FUNC)
EIGEN_STRONG_INLINE bool predux_any(const Packet4f &x)
Jet< T, N > cos(const Jet< T, N > &f)
internal::unpacket_traits< SrcPacket >::type SrcScalar
#define EIGEN_OPTIMIZATION_BARRIER(X)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pasin(const Packet &a)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet plog2(const Packet &a)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet4c predux_half_dowto4(const Packet8c &a)
void packetmath_minus_zero_add()
EIGEN_STRONG_INLINE Packet8h pandnot(const Packet8h &a, const Packet8h &b)
void packetmath_boolean_mask_ops()
EIGEN_DEVICE_FUNC unpacket_traits< Packet >::type predux_min(const Packet &a)
EIGEN_STRONG_INLINE Packet4f pcmp_le(const Packet4f &a, const Packet4f &b)
std::ofstream out("Result.txt")
#define CALL_SUBTEST_13(FUNC)
#define CALL_SUBTEST_3(FUNC)
internal::unpacket_traits< TgtPacket >::type TgtScalar
EIGEN_DONT_INLINE Scalar zero()
#define CALL_SUBTEST_7(FUNC)
EIGEN_STRONG_INLINE Packet8f pzero(const Packet8f &)
EIGEN_DEVICE_FUNC unpacket_traits< Packet >::type predux_max(const Packet &a)
Jet< T, N > acos(const Jet< T, N > &f)
EIGEN_DEVICE_FUNC const TanhReturnType tanh() const
#define CALL_SUBTEST_11(FUNC)
Jet< T, N > sin(const Jet< T, N > &f)
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
Namespace containing all symbols from the Eigen library.
#define CALL_SUBTEST_14(FUNC)
#define CHECK_CWISE1_BYREF1_IF(COND, REFOP, POP)
void packetmath_boolean_mask_ops_real()
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
EIGEN_STRONG_INLINE Packet4f print(const Packet4f &a)
EIGEN_STRONG_INLINE Packet8h pldexp(const Packet8h &a, const Packet8h &exponent)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet ptanh(const Packet &a)
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T maxi(const T &x, const T &y)
EIGEN_DEVICE_FUNC unpacket_traits< Packet >::type predux(const Packet &a)
EIGEN_STRONG_INLINE Packet8h pxor(const Packet8h &a, const Packet8h &b)
void test_conj_helper(Scalar *data1, Scalar *data2, Scalar *ref, Scalar *pval)
EIGEN_DEVICE_FUNC const LogReturnType log() const
static void cast(const typename internal::unpacket_traits< SrcPacket >::type *src, size_t size, typename internal::unpacket_traits< TgtPacket >::type *dst)
void g(const string &key, int i)
AnnoyingScalar conj(const AnnoyingScalar &x)
#define CALL_SUBTEST_10(FUNC)
EIGEN_STRONG_INLINE Packet4f pcmp_lt(const Packet4f &a, const Packet4f &b)
void packetmath_notcomplex()
T REF_LDEXP(const T &x, const T &exp)
EIGEN_DEVICE_FUNC Packet padd(const Packet &a, const Packet &b)
EIGEN_DEVICE_FUNC const ExpReturnType exp() const
#define CALL_SUBTEST_15(FUNC)
EIGEN_DEVICE_FUNC Packet pmin(const Packet &a, const Packet &b)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pexp(const Packet &a)
EIGEN_STRONG_INLINE Packet8h ptrue(const Packet8h &a)
EIGEN_DEVICE_FUNC const FloorReturnType floor() const
T REF_ADD(const T &a, const T &b)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pceil(const Packet &a)
EIGEN_STRONG_INLINE bfloat16 pfirst(const Packet8bf &a)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet ptan(const Packet &a)
#define VERIFY_IS_APPROX(a, b)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Abs2ReturnType abs2() const
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet plog1p(const Packet &a)
#define CHECK_CWISE1_IF(COND, REFOP, POP)
static void cast(const typename internal::unpacket_traits< SrcPacket >::type *src, size_t size, typename internal::unpacket_traits< TgtPacket >::type *dst)
EIGEN_STRONG_INLINE Packet8h pfrexp(const Packet8h &a, Packet8h &exponent)
EIGEN_DEVICE_FUNC void pstoreu(Scalar *to, const Packet &from)
#define VERIFY_IS_EQUAL(a, b)
static void cast(const SrcScalar *src, size_t size, TgtScalar *dst)
EIGEN_DEVICE_FUNC const Expm1ReturnType expm1() const
#define CHECK_CWISE1(REFOP, POP)
#define CALL_SUBTEST_1(FUNC)
EIGEN_DEVICE_FUNC Packet pabsdiff(const Packet &a, const Packet &b)
#define CHECK_CWISE1_N(REFOP, POP, N)
EIGEN_DEVICE_FUNC const RintReturnType rint() const
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pacos(const Packet &a)
EIGEN_STRONG_INLINE Packet2cf pcmp_eq(const Packet2cf &a, const Packet2cf &b)
EIGEN_STRONG_INLINE void ptranspose(PacketBlock< Packet2cf, 2 > &kernel)
T REF_FREXP(const T &x, T &exp)
Array< int, Dynamic, 1 > v
void packetmath_complex()
EIGEN_DEVICE_FUNC NewType cast(const OldType &x)
EIGEN_STRONG_INLINE Packet4f pcmp_lt_or_nan(const Packet4f &a, const Packet4f &b)
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
#define CALL_SUBTEST_8(FUNC)
bool areApprox(const Scalar *a, const Scalar *b, int size)
EIGEN_DECLARE_TEST(packetmath)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Scalar propagate_nan_max(const Scalar &a, const Scalar &b)
void packetmath_boolean_mask_ops_notcomplex()
EIGEN_STRONG_INLINE Packet8h pand(const Packet8h &a, const Packet8h &b)
EIGEN_STRONG_INLINE Packet2cf pconj(const Packet2cf &a)
NumTraits< Scalar >::Real RealScalar
static void cast(const typename internal::unpacket_traits< SrcPacket >::type *src, size_t size, typename internal::unpacket_traits< TgtPacket >::type *dst)
Reference counting helper.
EIGEN_DEVICE_FUNC const RsqrtReturnType rsqrt() const
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T mini(const T &x, const T &y)
void packetmath_scatter_gather()
#define CHECK_CWISE1_EXACT_IF(COND, REFOP, POP)
EIGEN_DEVICE_FUNC void pstore(Scalar *to, const Packet &from)
EIGEN_STRONG_INLINE Packet2cf pnegate(const Packet2cf &a)
EIGEN_DEVICE_FUNC Packet pdiv(const Packet &a, const Packet &b)
#define CALL_SUBTEST_5(FUNC)
T REF_DIV(const T &a, const T &b)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pfloor(const Packet &a)
#define EIGEN_USING_STD(FUNC)
T REF_ABS_DIFF(const T &a, const T &b)
EIGEN_DEVICE_FUNC unpacket_traits< Packet >::type predux_mul(const Packet &a)
EIGEN_DEVICE_FUNC const TanReturnType tan() const
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet plog(const Packet &a)
General-purpose arrays with easy API for coefficient-wise operations.
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pround(const Packet &a)
EIGEN_DEVICE_FUNC Packet psub(const Packet &a, const Packet &b)
EIGEN_STRONG_INLINE Packet1cd pcplxflip(const Packet1cd &x)
EIGEN_STRONG_INLINE Packet4f pselect(const Packet4f &mask, const Packet4f &a, const Packet4f &b)
EIGEN_DEVICE_FUNC const ImagReturnType imag() const
EIGEN_STRONG_INLINE Packet4f psqrt(const Packet4f &a)
T REF_MUL(const T &a, const T &b)
EIGEN_STRONG_INLINE Packet8h por(const Packet8h &a, const Packet8h &b)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pcos(const Packet &a)
#define CALL_SUBTEST_2(FUNC)
Jet< T, N > sqrt(const Jet< T, N > &f)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pexpm1(const Packet &a)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet psin(const Packet &a)
Jet< T, N > pow(const Jet< T, N > &f, double g)
EIGEN_STRONG_INLINE Packet4f prsqrt(const Packet4f &a)
EIGEN_DEVICE_FUNC const LogisticReturnType logistic() const
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 const AsinReturnType asin() const
#define CHECK_CWISE2_IF(COND, REFOP, POP)
Scalar propagate_number_max(const Scalar &a, const Scalar &b)
Derived & setRandom(Index size)
EIGEN_DEVICE_FUNC Packet pmul(const Packet &a, const Packet &b)
EIGEN_DEVICE_FUNC const CeilReturnType ceil() const
EIGEN_DEVICE_FUNC Packet pmax(const Packet &a, const Packet &b)
EIGEN_STRONG_INLINE Packet4i pblend(const Selector< 4 > &ifPacket, const Packet4i &thenPacket, const Packet4i &elsePacket)
EIGEN_STRONG_INLINE Packet2cf preverse(const Packet2cf &a)
EIGEN_STRONG_INLINE Packet4f pabs(const Packet4f &a)
EIGEN_DEVICE_FUNC const RoundReturnType round() const
Scalar propagate_number_min(const Scalar &a, const Scalar &b)