10 #ifndef EIGEN_CXX11_TENSOR_TENSOR_UINT128_H
11 #define EIGEN_CXX11_TENSOR_TENSOR_UINT128_H
34 template <
typename HIGH = u
int64_t,
typename LOW = u
int64_t>
40 template<
typename OTHER_HIGH,
typename OTHER_LOW>
42 TensorUInt128(
const TensorUInt128<OTHER_HIGH, OTHER_LOW>& other) : high(other.high), low(other.low) {
47 template<
typename OTHER_HIGH,
typename OTHER_LOW>
49 TensorUInt128& operator = (
const TensorUInt128<OTHER_HIGH, OTHER_LOW>& other) {
59 explicit TensorUInt128(
const T&
x) : high(0), low(
x) {
65 TensorUInt128(HIGH
y, LOW
x) : high(
y), low(
x) { }
79 template <
typename HL,
typename LL,
typename HR,
typename LR>
81 bool operator == (
const TensorUInt128<HL, LL>& lhs,
const TensorUInt128<HR, LR>& rhs)
83 return (lhs.high == rhs.high) && (lhs.low == rhs.low);
86 template <
typename HL,
typename LL,
typename HR,
typename LR>
88 bool operator != (
const TensorUInt128<HL, LL>& lhs,
const TensorUInt128<HR, LR>& rhs)
90 return (lhs.high != rhs.high) || (lhs.low != rhs.low);
93 template <
typename HL,
typename LL,
typename HR,
typename LR>
95 bool operator >= (
const TensorUInt128<HL, LL>& lhs,
const TensorUInt128<HR, LR>& rhs)
97 if (lhs.high != rhs.high) {
98 return lhs.high > rhs.high;
100 return lhs.low >= rhs.low;
103 template <
typename HL,
typename LL,
typename HR,
typename LR>
105 bool operator < (
const TensorUInt128<HL, LL>& lhs,
const TensorUInt128<HR, LR>& rhs)
107 if (lhs.high != rhs.high) {
108 return lhs.high < rhs.high;
110 return lhs.low < rhs.low;
113 template <
typename HL,
typename LL,
typename HR,
typename LR>
115 TensorUInt128<uint64_t, uint64_t>
operator + (
const TensorUInt128<HL, LL>& lhs,
const TensorUInt128<HR, LR>& rhs)
117 TensorUInt128<uint64_t, uint64_t> result(lhs.high + rhs.high, lhs.low + rhs.low);
118 if (result.low < rhs.low) {
124 template <
typename HL,
typename LL,
typename HR,
typename LR>
126 TensorUInt128<uint64_t, uint64_t>
operator - (
const TensorUInt128<HL, LL>& lhs,
const TensorUInt128<HR, LR>& rhs)
128 TensorUInt128<uint64_t, uint64_t> result(lhs.high - rhs.high, lhs.low - rhs.low);
129 if (result.low > lhs.low) {
136 template <
typename HL,
typename LL,
typename HR,
typename LR>
138 TensorUInt128<uint64_t, uint64_t>
operator * (
const TensorUInt128<HL, LL>& lhs,
const TensorUInt128<HR, LR>& rhs)
151 const uint64_t LOW = 0x00000000FFFFFFFFLL;
152 const uint64_t HIGH = 0xFFFFFFFF00000000LL;
160 uint64_t g = (rhs.low & HIGH) >> 32LL;
178 low |= (acc << 32LL);
182 acc2 = (acc >> 32LL) | (carry << 32LL);
200 acc2 = (acc >> 32LL) | (carry << 32LL);
206 high |= (acc2 << 32LL);
208 return TensorUInt128<uint64_t, uint64_t>(high, low);
211 template <
typename HL,
typename LL,
typename HR,
typename LR>
213 TensorUInt128<uint64_t, uint64_t>
operator / (
const TensorUInt128<HL, LL>& lhs,
const TensorUInt128<HR, LR>& rhs)
215 if (rhs == TensorUInt128<static_val<0>, static_val<1> >(1)) {
216 return TensorUInt128<uint64_t, uint64_t>(lhs.high, lhs.low);
217 }
else if (lhs < rhs) {
218 return TensorUInt128<uint64_t, uint64_t>(0);
221 TensorUInt128<uint64_t, uint64_t> power2(1);
222 TensorUInt128<uint64_t, uint64_t> d(rhs);
223 TensorUInt128<uint64_t, uint64_t> tmp(lhs - d);
227 power2 = power2 + power2;
230 tmp = TensorUInt128<uint64_t, uint64_t>(lhs.high, lhs.low);
231 TensorUInt128<uint64_t, uint64_t> result(0);
232 while (power2 != TensorUInt128<static_val<0>, static_val<0> >(0)) {
235 result = result + power2;
238 power2 = TensorUInt128<uint64_t, uint64_t>(power2.high >> 1, (power2.low >> 1) | (power2.high << 63));
239 d = TensorUInt128<uint64_t, uint64_t>(d.high >> 1, (d.low >> 1) | (d.high << 63));
Array< double, 1, 3 > e(1./3., 0.5, 2.)
#define EIGEN_ALWAYS_INLINE
#define EIGEN_UNUSED_VARIABLE(var)
#define EIGEN_DEVICE_FUNC
#define EIGEN_STATIC_ASSERT(X, MSG)
EIGEN_ALWAYS_INLINE bool operator!=(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
T operator/(const T &numerator, const TensorIntDivisor< T, div_gt_one > &divisor)
EIGEN_ALWAYS_INLINE TensorUInt128< uint64_t, uint64_t > operator-(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
EIGEN_ALWAYS_INLINE TensorUInt128< uint64_t, uint64_t > operator+(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
static TensorUInt128< uint64_t, uint64_t > operator*(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
EIGEN_ALWAYS_INLINE bool operator<(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
EIGEN_ALWAYS_INLINE bool operator==(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
EIGEN_ALWAYS_INLINE bool operator>=(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
: TensorContractionSycl.h, provides various tensor contraction kernel for SYCL backend