37 d =
static_cast<typename Vec::EntryType
>(0);
39 const typename Vec::EntryType zero = 0;
48 typedef typename Vec::EntryType
T;
51 if (!(
a != b).isEmpty()) {
52 std::cerr <<
a <<
" != " << b <<
", (a != b) = " << (
a != b) <<
", (a == b) = " << (
a == b) << std::endl;
67 const T step = max / 200;
74 for (
int i = 0; i < 200; ++i, j += step) {
75 if(Vec(
Zero) >= Vec(j)) {
76 std::cout << j <<
" " << Vec(j) <<
" " << (Vec(
Zero) >= Vec(j)) << std::endl;
82 VERIFY(!static_cast<bool>(Vec(
Zero) >= Vec(j)));
83 VERIFY(!static_cast<bool>(Vec(j) <= Vec(
Zero)));
91 const T step = min /
T(-201);
93 for (
int i = 0; i < 200; ++i, j += step) {
112 VERIFY(!(a == a).isMix());
113 VERIFY(!(a != a).isMix());
115 VERIFY(!(a == b).isMix());
116 VERIFY(!(a != b).isMix());
117 VERIFY(!(a == c).isMix());
118 VERIFY(!(a != c).isMix());
119 VERIFY(!(a == a).isMix());
120 VERIFY(!(a != a).isMix());
153 for (
int i = 0; i < 10000; ++i) {
157 for (
int j = 0; j <
V::Size; ++j) {
161 reference[j] *= b[j];
163 COMPARE(a * b, reference) << a <<
" * " << b;
169 for (
unsigned int i = 0; i < 0xffff; ++i) {
170 const Vec i2(i * i + 1);
179 typedef typename Vec::EntryType
T;
180 for (
unsigned int i = 0; i < 0xffff; ++i) {
181 const T j =
static_cast<T
>(i);
190 typedef typename Vec::EntryType
T;
195 for (T divisor = 1; divisor < 5; ++divisor) {
198 Vec reference(scalar / divisor);
200 COMPARE(vector / divisor, reference) <<
'\n' << vector <<
" / " << divisor
201 <<
", reference: " << scalar <<
" / " << divisor <<
" = " << scalar / divisor;
215 const typename Vec::EntryType zero = 0;
216 COMPARE((c & 0x7ff0), Vec(zero));
221 typedef typename Vec::EntryType
T;
224 NShifts =
sizeof(
T) * 8
229 for (
size_t shift = 0; shift < NShifts; ++shift) {
230 const Vec rightShift = x >> shift;
231 const Vec leftShift = x << shift;
233 COMPARE(rightShift[k],
T(x[k] >> shift)) <<
", x[k] = " << x[k] <<
", shift = " << shift;
234 COMPARE(leftShift [k],
T(x[k] << shift)) <<
", x[k] = " << x[k] <<
", shift = " << shift;
249 for (
typename Vec::EntryType i = 0, x = 1; i <
Vec::Size; ++i, x <<= 1) {
261 for (
typename Vec::EntryType i = 0, x = 16; i < Vec::Size; ++i, x >>= 1) {
275 template<
typename T>
struct NegateRangeHelper
277 typedef int Iterator;
278 static const Iterator Start;
279 static const Iterator
End;
281 template<>
struct NegateRangeHelper<unsigned int> {
282 typedef unsigned int Iterator;
283 static const Iterator Start;
284 static const Iterator
End;
286 template<>
const int NegateRangeHelper<float>::Start = -0xffffff;
287 template<>
const int NegateRangeHelper<float>::End = 0xffffff - 133;
288 template<>
const int NegateRangeHelper<double>::Start = -0xffffff;
289 template<>
const int NegateRangeHelper<double>::End = 0xffffff - 133;
290 template<>
const int NegateRangeHelper<int>::Start = -0x7fffffff;
291 template<>
const int NegateRangeHelper<int>::End = 0x7fffffff - 0xee;
292 const unsigned int NegateRangeHelper<unsigned int>::Start = 0;
293 const unsigned int NegateRangeHelper<unsigned int>::End = 0xffffffff - 0xee;
294 template<>
const int NegateRangeHelper<short>::Start = -0x7fff;
295 template<>
const int NegateRangeHelper<short>::End = 0x7fff - 0xee;
296 template<>
const int NegateRangeHelper<unsigned short>::Start = 0;
297 template<>
const int NegateRangeHelper<unsigned short>::End = 0xffff - 0xee;
301 typedef typename Vec::EntryType
T;
302 typedef NegateRangeHelper<T>
Range;
303 for (
typename Range::Iterator i = Range::Start; i <
Range::End; i += 0xef) {
304 T i2 =
static_cast<T
>(i);
307 COMPARE(static_cast<Vec>(-a), Vec(-i2)) <<
" i2: " << i2;
313 typedef typename Vec::EntryType
T;
314 typedef typename Vec::Mask Mask;
315 typedef typename Vec::IndexType
I;
319 COMPARE(v.min(),
static_cast<T
>(0));
325 m = allMasks<Vec>(j++);
329 COMPARE(v.min(m),
static_cast<T
>(m.firstOne())) << m <<
v;
335 typedef typename Vec::EntryType
T;
336 typedef typename Vec::Mask Mask;
337 typedef typename Vec::IndexType
I;
348 m = allMasks<Vec>(j++);
358 typedef typename Vec::EntryType
T;
359 typedef typename Vec::Mask Mask;
361 for (
int i = 0; i < 10; ++i) {
362 T
x =
static_cast<T
>(i);
373 m = allMasks<Vec>(j++);
377 if (std::numeric_limits<T>::is_exact) {
379 for (
int k = m.count(); k > 1; --k) {
383 x2 =
static_cast<T
>(
pow(static_cast<double>(x), m.count()));
392 typedef typename Vec::EntryType
T;
393 typedef typename Vec::Mask Mask;
395 for (
int i = 0; i < 10; ++i) {
396 T
x =
static_cast<T
>(i);
403 m = allMasks<Vec>(j++);
404 COMPARE(v.sum(m), x * m.count()) << m << v;
405 }
while (!m.isEmpty());
409 template<
typename V>
void fma()
411 for (
int i = 0; i < 1000; ++i) {
415 const V reference = a * b +
c;
416 a.fusedMultiplyAdd(b, c);
417 COMPARE(a, reference) <<
", a = " << a <<
", b = " << b <<
", c = " <<
c;
430 a.fusedMultiplyAdd(b, c);
440 a.fusedMultiplyAdd(b, c);
453 a.fusedMultiplyAdd(b, c);
463 a.fusedMultiplyAdd(b, c);
472 a.fusedMultiplyAdd(b, c);
478 a.fusedMultiplyAdd(b, c);
482 int main(
int argc,
char **argv)
571 runTest(testOnesComplement<int_v>);
572 runTest(testOnesComplement<uint_v>);
573 runTest(testOnesComplement<short_v>);
574 runTest(testOnesComplement<ushort_v>);
Vector< sfloat > sfloat_v
VECTOR_NAMESPACE::sfloat_v sfloat_v
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
#define FUZZY_COMPARE(a, b)
void initTest(int argc, char **argv)
int main(int argc, char **argv)
void testOnesComplement()
static const double x2[5]
double pow(double, double)
#define testAllTypes(name)
#define Vc_buildDouble(sign, mantissa, exponent)
Vector< double > double_v
VECTOR_NAMESPACE::double_v double_v
#define Vc_buildFloat(sign, mantissa, exponent)
VECTOR_NAMESPACE::float_v float_v
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)