ADD: added other eigen lib

This commit is contained in:
Henry Winkel
2022-12-21 16:19:04 +01:00
parent a570766dc6
commit 9e56c7f2c0
832 changed files with 36586 additions and 20006 deletions

View File

@@ -11,7 +11,7 @@
template<typename T, typename U>
bool check_if_equal_or_nans(const T& actual, const U& expected) {
return ((actual == expected) || ((numext::isnan)(actual) && (numext::isnan)(expected)));
return (numext::equal_strict(actual, expected) || ((numext::isnan)(actual) && (numext::isnan)(expected)));
}
template<typename T, typename U>
@@ -239,6 +239,63 @@ void check_rsqrt() {
check_rsqrt_impl<T>::run();
}
template <typename T>
struct check_signbit_impl {
static void run() {
T true_mask;
std::memset(static_cast<void*>(&true_mask), 0xff, sizeof(T));
T false_mask;
std::memset(static_cast<void*>(&false_mask), 0x00, sizeof(T));
std::vector<T> negative_values;
std::vector<T> non_negative_values;
if (NumTraits<T>::IsInteger) {
negative_values = {static_cast<T>(-1),
static_cast<T>(NumTraits<T>::lowest())};
non_negative_values = {static_cast<T>(0), static_cast<T>(1),
static_cast<T>(NumTraits<T>::highest())};
} else {
// has sign bit
const T neg_zero = static_cast<T>(-0.0);
const T neg_one = static_cast<T>(-1.0);
const T neg_inf = -std::numeric_limits<T>::infinity();
const T neg_nan = -std::numeric_limits<T>::quiet_NaN();
// does not have sign bit
const T pos_zero = static_cast<T>(0.0);
const T pos_one = static_cast<T>(1.0);
const T pos_inf = std::numeric_limits<T>::infinity();
const T pos_nan = std::numeric_limits<T>::quiet_NaN();
negative_values = {neg_zero, neg_one, neg_inf, neg_nan};
non_negative_values = {pos_zero, pos_one, pos_inf, pos_nan};
}
auto check_all = [](auto values, auto expected) {
bool all_pass = true;
for (T val : values) {
const T numext_val = numext::signbit(val);
bool not_same = internal::predux_any(
internal::bitwise_helper<T>::bitwise_xor(expected, numext_val));
all_pass = all_pass && !not_same;
if (not_same)
std::cout << "signbit(" << val << ") = " << numext_val
<< " != " << expected << std::endl;
}
return all_pass;
};
bool all_pass = check_all(non_negative_values, false_mask);
all_pass = all_pass && check_all(negative_values, (NumTraits<T>::IsSigned ? true_mask : false_mask));
VERIFY(all_pass);
}
};
template <typename T>
void check_signbit() {
check_signbit_impl<T>::run();
}
EIGEN_DECLARE_TEST(numext) {
for(int k=0; k<g_repeat; ++k)
{
@@ -266,10 +323,25 @@ EIGEN_DECLARE_TEST(numext) {
CALL_SUBTEST( check_sqrt<double>() );
CALL_SUBTEST( check_sqrt<std::complex<float> >() );
CALL_SUBTEST( check_sqrt<std::complex<double> >() );
CALL_SUBTEST( check_rsqrt<float>() );
CALL_SUBTEST( check_rsqrt<double>() );
CALL_SUBTEST( check_rsqrt<std::complex<float> >() );
CALL_SUBTEST( check_rsqrt<std::complex<double> >() );
CALL_SUBTEST( check_signbit<half>());
CALL_SUBTEST( check_signbit<bfloat16>());
CALL_SUBTEST( check_signbit<float>());
CALL_SUBTEST( check_signbit<double>());
CALL_SUBTEST( check_signbit<uint8_t>());
CALL_SUBTEST( check_signbit<uint16_t>());
CALL_SUBTEST( check_signbit<uint32_t>());
CALL_SUBTEST( check_signbit<uint64_t>());
CALL_SUBTEST( check_signbit<int8_t>());
CALL_SUBTEST( check_signbit<int16_t>());
CALL_SUBTEST( check_signbit<int32_t>());
CALL_SUBTEST( check_signbit<int64_t>());
}
}