mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Clang-format tests, examples, libraries, benchmarks, etc.
This commit is contained in:
committed by
Rasmus Munk Larsen
parent
3252ecc7a4
commit
46e9cdb7fe
@@ -11,7 +11,6 @@
|
||||
|
||||
#include <Eigen/CXX11/Tensor>
|
||||
|
||||
|
||||
#if EIGEN_COMP_MSVC || !defined(__SIZEOF_INT128__)
|
||||
#define EIGEN_NO_INT128
|
||||
#else
|
||||
@@ -21,22 +20,19 @@ typedef __uint128_t uint128_t;
|
||||
// Only run the test on compilers that support 128bit integers natively
|
||||
#ifndef EIGEN_NO_INT128
|
||||
|
||||
using Eigen::internal::TensorUInt128;
|
||||
using Eigen::internal::static_val;
|
||||
using Eigen::internal::TensorUInt128;
|
||||
|
||||
void VERIFY_EQUAL(TensorUInt128<uint64_t, uint64_t> actual, uint128_t expected) {
|
||||
bool matchl = actual.lower() == static_cast<uint64_t>(expected);
|
||||
bool matchh = actual.upper() == static_cast<uint64_t>(expected >> 64);
|
||||
if (!matchl || !matchh) {
|
||||
const char* testname = g_test_stack.back().c_str();
|
||||
std::cerr << "Test " << testname << " failed in " << __FILE__
|
||||
<< " (" << __LINE__ << ")"
|
||||
<< std::endl;
|
||||
std::cerr << "Test " << testname << " failed in " << __FILE__ << " (" << __LINE__ << ")" << std::endl;
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void test_add() {
|
||||
uint64_t incr = internal::random<uint64_t>(1, 9999999999);
|
||||
for (uint64_t i1 = 0; i1 < 100; ++i1) {
|
||||
@@ -132,10 +128,13 @@ void test_misc2() {
|
||||
int64_t incr = internal::random<int64_t>(1, 100);
|
||||
for (int64_t log_div = 0; log_div < 63; ++log_div) {
|
||||
for (int64_t divider = 1; divider <= 1000000 * incr; divider += incr) {
|
||||
uint64_t expected = (static_cast<uint128_t>(1) << (64+log_div)) / static_cast<uint128_t>(divider) - (static_cast<uint128_t>(1) << 64) + 1;
|
||||
uint64_t expected = (static_cast<uint128_t>(1) << (64 + log_div)) / static_cast<uint128_t>(divider) -
|
||||
(static_cast<uint128_t>(1) << 64) + 1;
|
||||
uint64_t shift = 1ULL << log_div;
|
||||
|
||||
TensorUInt128<uint64_t, uint64_t> result = (TensorUInt128<uint64_t, static_val<0> >(shift, 0) / TensorUInt128<static_val<0>, uint64_t>(divider) - TensorUInt128<static_val<1>, static_val<0> >(1, 0) + TensorUInt128<static_val<0>, static_val<1> >(1));
|
||||
TensorUInt128<uint64_t, uint64_t> result =
|
||||
(TensorUInt128<uint64_t, static_val<0> >(shift, 0) / TensorUInt128<static_val<0>, uint64_t>(divider) -
|
||||
TensorUInt128<static_val<1>, static_val<0> >(1, 0) + TensorUInt128<static_val<0>, static_val<1> >(1));
|
||||
uint64_t actual = static_cast<uint64_t>(result);
|
||||
VERIFY_IS_EQUAL(actual, expected);
|
||||
}
|
||||
@@ -143,9 +142,7 @@ void test_misc2() {
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
EIGEN_DECLARE_TEST(cxx11_tensor_uint128)
|
||||
{
|
||||
EIGEN_DECLARE_TEST(cxx11_tensor_uint128) {
|
||||
#ifdef EIGEN_NO_INT128
|
||||
// Skip the test on compilers that don't support 128bit integers natively
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user