Eigen::internal::TensorIntDivisor< T, div_gt_one > Struct Template Reference

#include <TensorIntDiv.h>

Public Member Functions

EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorIntDivisor ()
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorIntDivisor (const T divider)
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T divide (const T numerator) const
 

Private Types

typedef DividerTraits< T >::type UnsignedType
 

Private Attributes

UnsignedType multiplier
 
int32_t shift1
 
int32_t shift2
 

Member Typedef Documentation

◆ UnsignedType

template<typename T , bool div_gt_one = false>
typedef DividerTraits<T>::type Eigen::internal::TensorIntDivisor< T, div_gt_one >::UnsignedType
private

Constructor & Destructor Documentation

◆ TensorIntDivisor() [1/2]

template<typename T , bool div_gt_one = false>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Eigen::internal::TensorIntDivisor< T, div_gt_one >::TensorIntDivisor ( )
inline
142  {
143  multiplier = 0;
144  shift1 = 0;
145  shift2 = 0;
146  }
int32_t shift2
Definition: TensorIntDiv.h:184
int32_t shift1
Definition: TensorIntDiv.h:183
UnsignedType multiplier
Definition: TensorIntDiv.h:182

References Eigen::internal::TensorIntDivisor< T, div_gt_one >::multiplier, Eigen::internal::TensorIntDivisor< T, div_gt_one >::shift1, and Eigen::internal::TensorIntDivisor< T, div_gt_one >::shift2.

◆ TensorIntDivisor() [2/2]

template<typename T , bool div_gt_one = false>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Eigen::internal::TensorIntDivisor< T, div_gt_one >::TensorIntDivisor ( const T  divider)
inline
151  {
152  const int N = DividerTraits<T>::N;
153  eigen_assert(static_cast<typename UnsignedTraits<T>::type>(divider) < NumTraits<UnsignedType>::highest() / 2);
154  eigen_assert(divider > 0);
155 
156  // fast ln2
157  const int leading_zeros = count_leading_zeros(static_cast<UnsignedType>(divider));
158  int log_div = N - leading_zeros;
159  // if divider is a power of two then log_div is 1 more than it should be.
160  if ((static_cast<typename UnsignedTraits<T>::type>(1) << (log_div - 1)) ==
161  static_cast<typename UnsignedTraits<T>::type>(divider))
162  log_div--;
163 
165  shift1 = log_div > 1 ? 1 : log_div;
166  shift2 = log_div > 1 ? log_div - 1 : 0;
167  }
#define eigen_assert(x)
Definition: Macros.h:910
@ N
Definition: constructor.cpp:22
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE std::enable_if_t< sizeof(T)==4, int > count_leading_zeros(const T val)
Definition: TensorIntDiv.h:35
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE uint32_t computeMultiplier(const int log_div, const T divider)
Definition: TensorIntDiv.h:116
static constexpr int N
Definition: TensorIntDiv.h:84
DividerTraits< T >::type UnsignedType
Definition: TensorIntDiv.h:181
std::conditional_t< sizeof(T)==8, uint64_t, uint32_t > type
Definition: TensorIntDiv.h:78

References Eigen::internal::DividerHelper< N, T >::computeMultiplier(), Eigen::internal::count_leading_zeros(), eigen_assert, Eigen::internal::TensorIntDivisor< T, div_gt_one >::multiplier, N, Eigen::internal::TensorIntDivisor< T, div_gt_one >::shift1, and Eigen::internal::TensorIntDivisor< T, div_gt_one >::shift2.

Member Function Documentation

◆ divide()

template<typename T , bool div_gt_one = false>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T Eigen::internal::TensorIntDivisor< T, div_gt_one >::divide ( const T  numerator) const
inline
171  {
172  eigen_assert(static_cast<typename UnsignedTraits<T>::type>(numerator) < NumTraits<UnsignedType>::highest() / 2);
173  // eigen_assert(numerator >= 0); // this is implicitly asserted by the line above
174 
175  UnsignedType t1 = muluh(multiplier, numerator);
176  UnsignedType t = (static_cast<UnsignedType>(numerator) - t1) >> shift1;
177  return (t1 + t) >> shift2;
178  }
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE uint32_t muluh(const uint32_t a, const T b)
Definition: TensorIntDiv.h:88
t
Definition: plotPSD.py:36

References eigen_assert, Eigen::internal::TensorIntDivisor< T, div_gt_one >::multiplier, Eigen::internal::muluh(), Eigen::internal::TensorIntDivisor< T, div_gt_one >::shift1, Eigen::internal::TensorIntDivisor< T, div_gt_one >::shift2, and plotPSD::t.

Referenced by Eigen::internal::operator/(), test_powers_32bit(), test_powers_64bit(), and test_specific().

Member Data Documentation

◆ multiplier

◆ shift1

template<typename T , bool div_gt_one = false>
int32_t Eigen::internal::TensorIntDivisor< T, div_gt_one >::shift1
private

◆ shift2

template<typename T , bool div_gt_one = false>
int32_t Eigen::internal::TensorIntDivisor< T, div_gt_one >::shift2
private

The documentation for this struct was generated from the following file: