12 #include <Eigen/CXX11/Tensor>
15 #if EIGEN_COMP_MSVC || !defined(__SIZEOF_INT128__)
16 #define EIGEN_NO_INT128
18 typedef __uint128_t uint128_t;
22 #ifndef EIGEN_NO_INT128
27 void VERIFY_EQUAL(TensorUInt128<uint64_t, uint64_t> actual, uint128_t
expected) {
30 if (!matchl || !matchh) {
32 std::cerr <<
"Test " << testname <<
" failed in " << __FILE__
33 <<
" (" << __LINE__ <<
")"
41 uint64_t incr = internal::random<uint64_t>(1, 9999999999);
43 for (
uint64_t i2 = 1; i2 < 100 * incr; i2 += incr) {
44 TensorUInt128<uint64_t, uint64_t>
i(
i1, i2);
45 uint128_t
a = (
static_cast<uint128_t
>(
i1) << 64) +
static_cast<uint128_t
>(i2);
47 for (
uint64_t j2 = 1; j2 < 100 * incr; j2 += incr) {
48 TensorUInt128<uint64_t, uint64_t>
j(
j1, j2);
49 uint128_t
b = (
static_cast<uint128_t
>(
j1) << 64) +
static_cast<uint128_t
>(j2);
50 TensorUInt128<uint64_t, uint64_t> actual =
i +
j;
60 uint64_t incr = internal::random<uint64_t>(1, 9999999999);
62 for (
uint64_t i2 = 1; i2 < 100 * incr; i2 += incr) {
63 TensorUInt128<uint64_t, uint64_t>
i(
i1, i2);
64 uint128_t
a = (
static_cast<uint128_t
>(
i1) << 64) +
static_cast<uint128_t
>(i2);
66 for (
uint64_t j2 = 1; j2 < 100 * incr; j2 += incr) {
67 TensorUInt128<uint64_t, uint64_t>
j(
j1, j2);
68 uint128_t
b = (
static_cast<uint128_t
>(
j1) << 64) +
static_cast<uint128_t
>(j2);
69 TensorUInt128<uint64_t, uint64_t> actual =
i -
j;
79 uint64_t incr = internal::random<uint64_t>(1, 9999999999);
81 for (
uint64_t i2 = 1; i2 < 100 * incr; i2 += incr) {
82 TensorUInt128<uint64_t, uint64_t>
i(
i1, i2);
83 uint128_t
a = (
static_cast<uint128_t
>(
i1) << 64) +
static_cast<uint128_t
>(i2);
85 for (
uint64_t j2 = 1; j2 < 100 * incr; j2 += incr) {
86 TensorUInt128<uint64_t, uint64_t>
j(
j1, j2);
87 uint128_t
b = (
static_cast<uint128_t
>(
j1) << 64) +
static_cast<uint128_t
>(j2);
88 TensorUInt128<uint64_t, uint64_t> actual =
i *
j;
98 uint64_t incr = internal::random<uint64_t>(1, 9999999999);
100 for (
uint64_t i2 = 1; i2 < 100 * incr; i2 += incr) {
101 TensorUInt128<uint64_t, uint64_t>
i(
i1, i2);
102 uint128_t
a = (
static_cast<uint128_t
>(
i1) << 64) +
static_cast<uint128_t
>(i2);
104 for (
uint64_t j2 = 1; j2 < 100 * incr; j2 += incr) {
105 TensorUInt128<uint64_t, uint64_t>
j(
j1, j2);
106 uint128_t
b = (
static_cast<uint128_t
>(
j1) << 64) +
static_cast<uint128_t
>(j2);
107 TensorUInt128<uint64_t, uint64_t> actual =
i /
j;
117 uint64_t incr = internal::random<uint64_t>(1, 9999999999);
118 for (
uint64_t i2 = 1; i2 < 100 * incr; i2 += incr) {
119 TensorUInt128<static_val<0>,
uint64_t>
i(0, i2);
120 uint128_t
a =
static_cast<uint128_t
>(i2);
121 for (
uint64_t j2 = 1; j2 < 100 * incr; j2 += incr) {
122 TensorUInt128<static_val<0>,
uint64_t>
j(0, j2);
123 uint128_t
b =
static_cast<uint128_t
>(j2);
132 int64_t incr = internal::random<int64_t>(1, 100);
133 for (
int64_t log_div = 0; log_div < 63; ++log_div) {
134 for (
int64_t divider = 1; divider <= 1000000 * incr; divider += incr) {
135 uint64_t expected = (
static_cast<uint128_t
>(1) << (64+log_div)) /
static_cast<uint128_t
>(divider) - (
static_cast<uint128_t
>(1) << 64) + 1;
138 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));
149 #ifdef EIGEN_NO_INT128