libcruft-util/test/coord/simd.cpp

34 lines
828 B
C++

#include "coord/simd.hpp"
#include "tap.hpp"
int
main ()
{
util::TAP::logger tap;
{
const util::coord::simd a (1,2,3,4);
const util::coord::simd b (4,1,3,2);
const float res = dot (a, b);
tap.expect_eq (res, 4+2+9+8, "trivial dot product");
}
{
const util::coord::simd a (1, 2, 3, 4);
const util::coord::simd b (0, 3, 3, 9);
const auto lo = min (a, b);
const auto hi = max (a, b);
tap.expect_eq (lo, util::coord::simd {0,2,3,4}, "vector minimum");
tap.expect_eq (hi, util::coord::simd {1,3,3,9}, "vector maximum");
}
{
const util::coord::simd val { -INFINITY, INFINITY, 0, -9 };
tap.expect_eq (abs (val), util::coord::simd {INFINITY,INFINITY,0,9}, "absolute value");
}
return tap.status ();
}