MCPcopy Create free account
hub / github.com/PX4/eigen / packetmath

Function packetmath

test/packetmath.cpp:112–326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110#define REF_DIV(a,b) ((a)/(b))
111
112template<typename Scalar> void packetmath()
113{
114 using std::abs;
115 typedef internal::packet_traits<Scalar> PacketTraits;
116 typedef typename PacketTraits::type Packet;
117 const int PacketSize = PacketTraits::size;
118 typedef typename NumTraits<Scalar>::Real RealScalar;
119
120 const int max_size = PacketSize > 4 ? PacketSize : 4;
121 const int size = PacketSize*max_size;
122 EIGEN_ALIGN_MAX Scalar data1[size];
123 EIGEN_ALIGN_MAX Scalar data2[size];
124 EIGEN_ALIGN_MAX Packet packets[PacketSize*2];
125 EIGEN_ALIGN_MAX Scalar ref[size];
126 RealScalar refvalue = 0;
127 for (int i=0; i<size; ++i)
128 {
129 data1[i] = internal::random<Scalar>()/RealScalar(PacketSize);
130 data2[i] = internal::random<Scalar>()/RealScalar(PacketSize);
131 refvalue = (std::max)(refvalue,abs(data1[i]));
132 }
133
134 internal::pstore(data2, internal::pload<Packet>(data1));
135 VERIFY(areApprox(data1, data2, PacketSize) && "aligned load/store");
136
137 for (int offset=0; offset<PacketSize; ++offset)
138 {
139 internal::pstore(data2, internal::ploadu<Packet>(data1+offset));
140 VERIFY(areApprox(data1+offset, data2, PacketSize) && "internal::ploadu");
141 }
142
143 for (int offset=0; offset<PacketSize; ++offset)
144 {
145 internal::pstoreu(data2+offset, internal::pload<Packet>(data1));
146 VERIFY(areApprox(data1, data2+offset, PacketSize) && "internal::pstoreu");
147 }
148
149 for (int offset=0; offset<PacketSize; ++offset)
150 {
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]);
169 internal::pstore(data2, packets[0]);

Callers

nothing calls this directly

Calls 15

pstoreFunction · 0.85
areApproxFunction · 0.85
pstoreuFunction · 0.85
pfirstFunction · 0.85
isApproxAbsFunction · 0.85
preduxFunction · 0.85
predux_downto4Function · 0.85
predux_mulFunction · 0.85
preduxpFunction · 0.85
areApproxAbsFunction · 0.85
absFunction · 0.50
isApproxFunction · 0.50

Tested by

no test coverage detected