10#ifndef EIGEN_CXX11_TENSOR_TENSOR_UINT128_H
11#define EIGEN_CXX11_TENSOR_TENSOR_UINT128_H
32template <
typename HIGH = u
int64_t,
typename LOW = u
int64_t>
38 template<
typename OTHER_HIGH,
typename OTHER_LOW>
45 template<
typename OTHER_HIGH,
typename OTHER_LOW>
77template <
typename HL,
typename LL,
typename HR,
typename LR>
81 return (lhs.high == rhs.high) & (lhs.low == rhs.low);
84template <
typename HL,
typename LL,
typename HR,
typename LR>
88 return (lhs.high != rhs.high) | (lhs.low != rhs.low);
91template <
typename HL,
typename LL,
typename HR,
typename LR>
95 if (lhs.high != rhs.high) {
96 return lhs.high > rhs.high;
98 return lhs.low >= rhs.low;
101template <
typename HL,
typename LL,
typename HR,
typename LR>
105 if (lhs.high != rhs.high) {
106 return lhs.high < rhs.high;
108 return lhs.low < rhs.low;
111template <
typename HL,
typename LL,
typename HR,
typename LR>
116 if (
result.low < rhs.low) {
122template <
typename HL,
typename LL,
typename HR,
typename LR>
127 if (
result.low > lhs.low) {
134template <
typename HL,
typename LL,
typename HR,
typename LR>
136TensorUInt128<uint64_t, uint64_t> operator * (
const TensorUInt128<HL, LL>& lhs,
const TensorUInt128<HR, LR>& rhs)
149 const uint64_t LOW = 0x00000000FFFFFFFFLL;
150 const uint64_t HIGH = 0xFFFFFFFF00000000LL;
152 uint64_t d = lhs.low & LOW;
153 uint64_t
c = (lhs.low & HIGH) >> 32LL;
154 uint64_t
b = lhs.high & LOW;
155 uint64_t
a = (lhs.high & HIGH) >> 32LL;
157 uint64_t h = rhs.low & LOW;
158 uint64_t g = (rhs.low & HIGH) >> 32LL;
159 uint64_t f = rhs.high & LOW;
160 uint64_t
e = (rhs.high & HIGH) >> 32LL;
163 uint64_t acc = d * h;
164 uint64_t low = acc & LOW;
168 uint64_t acc2 = acc +
c * h;
176 low |= (acc << 32LL);
180 acc2 = (acc >> 32LL) | (carry << 32LL);
198 acc2 = (acc >> 32LL) | (carry << 32LL);
204 high |= (acc2 << 32LL);
206 return TensorUInt128<uint64_t, uint64_t>(high, low);
209template <
typename HL,
typename LL,
typename HR,
typename LR>
211TensorUInt128<uint64_t, uint64_t> operator / (
const TensorUInt128<HL, LL>& lhs,
const TensorUInt128<HR, LR>& rhs)
213 if (rhs == TensorUInt128<static_val<0>, static_val<1> >(1)) {
214 return TensorUInt128<uint64_t, uint64_t>(lhs.high, lhs.low);
215 }
else if (lhs < rhs) {
216 return TensorUInt128<uint64_t, uint64_t>(0);
219 TensorUInt128<uint64_t, uint64_t> power2(1);
220 TensorUInt128<uint64_t, uint64_t> d(rhs);
221 TensorUInt128<uint64_t, uint64_t> tmp(lhs - d);
225 power2 = power2 + power2;
228 tmp = TensorUInt128<uint64_t, uint64_t>(lhs.high, lhs.low);
229 TensorUInt128<uint64_t, uint64_t> result(0);
230 while (power2 != TensorUInt128<static_val<0>, static_val<0> >(0)) {
233 result = result + power2;
236 power2 = TensorUInt128<uint64_t, uint64_t>(power2.high >> 1, (power2.low >> 1) | (power2.high << 63));
237 d = TensorUInt128<uint64_t, uint64_t>(d.high >> 1, (d.low >> 1) | (d.high << 63));
ArrayXXi a
Definition Array_initializer_list_23_cxx11.cpp:1
Array< int, Dynamic, 1 > v
Definition Array_initializer_list_vector_cxx11.cpp:1
int n
Definition BiCGSTAB_simple.cpp:1
EIGEN_DEVICE_FUNC const NegativeReturnType operator-() const
Definition CommonCwiseUnaryOps.h:45
Array< double, 1, 3 > e(1./3., 0.5, 2.)
#define EIGEN_ALWAYS_INLINE
Definition Macros.h:932
#define EIGEN_UNUSED_VARIABLE(var)
Definition Macros.h:1076
#define EIGEN_DEVICE_FUNC
Definition Macros.h:976
#define eigen_assert(x)
Definition Macros.h:1037
#define EIGEN_STRONG_INLINE
Definition Macros.h:917
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
Definition StaticAssert.h:127
Scalar Scalar * c
Definition benchVecAdd.cpp:17
Scalar * b
Definition benchVecAdd.cpp:17
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition gnuplot_common_settings.hh:12
const Scalar & y
Definition MathFunctions.h:821
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool operator<(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
Definition TensorUInt128.h:103
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE TensorUInt128< uint64_t, uint64_t > operator+(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
Definition TensorUInt128.h:113
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool operator!=(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
Definition TensorUInt128.h:86
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool operator>=(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
Definition TensorUInt128.h:93
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool operator==(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
Definition TensorUInt128.h:79
::uint64_t uint64_t
Definition Meta.h:58
Namespace containing all symbols from the Eigen library.
Definition bench_norm.cpp:85
Definition BandTriangularSolver.h:13
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition NumTraits.h:233
Definition TensorUInt128.h:34
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE HIGH upper() const
Definition TensorUInt128.h:71
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE TensorUInt128(const TensorUInt128< OTHER_HIGH, OTHER_LOW > &other)
Definition TensorUInt128.h:40
HIGH high
Definition TensorUInt128.h:35
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE TensorUInt128(HIGH y, LOW x)
Definition TensorUInt128.h:63
LOW low
Definition TensorUInt128.h:36
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE TensorUInt128(const T &x)
Definition TensorUInt128.h:57
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE LOW lower() const
Definition TensorUInt128.h:68
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE TensorUInt128 & operator=(const TensorUInt128< OTHER_HIGH, OTHER_LOW > &other)
Definition TensorUInt128.h:47
Definition TensorUInt128.h:18
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE static_val(const T &v)
Definition TensorUInt128.h:25
static const uint64_t value
Definition TensorUInt128.h:19
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE static_val()
Definition TensorUInt128.h:22
Definition ForwardDeclarations.h:17