cast_test_impl< SrcType, DstType, RowsAtCompileTime, ColsAtCompileTime > Struct Template Reference

Classes

struct  RandomOp
 

Public Types

using SrcArray = Array< SrcType, RowsAtCompileTime, ColsAtCompileTime >
 
using DstArray = Array< DstType, RowsAtCompileTime, ColsAtCompileTime >
 

Static Public Member Functions

static void run ()
 

Static Public Attributes

static constexpr int SrcPacketSize = internal::packet_traits<SrcType>::size
 
static constexpr int DstPacketSize = internal::packet_traits<DstType>::size
 
static constexpr int MaxPacketSize = internal::plain_enum_max(SrcPacketSize, DstPacketSize)
 

Member Typedef Documentation

◆ DstArray

template<typename SrcType , typename DstType , int RowsAtCompileTime, int ColsAtCompileTime>
using cast_test_impl< SrcType, DstType, RowsAtCompileTime, ColsAtCompileTime >::DstArray = Array<DstType, RowsAtCompileTime, ColsAtCompileTime>

◆ SrcArray

template<typename SrcType , typename DstType , int RowsAtCompileTime, int ColsAtCompileTime>
using cast_test_impl< SrcType, DstType, RowsAtCompileTime, ColsAtCompileTime >::SrcArray = Array<SrcType, RowsAtCompileTime, ColsAtCompileTime>

Member Function Documentation

◆ run()

template<typename SrcType , typename DstType , int RowsAtCompileTime, int ColsAtCompileTime>
static void cast_test_impl< SrcType, DstType, RowsAtCompileTime, ColsAtCompileTime >::run ( )
inlinestatic
1280  {
1281  const Index testRows = RowsAtCompileTime == Dynamic ? ((10 * MaxPacketSize) + 1) : RowsAtCompileTime;
1282  const Index testCols = ColsAtCompileTime == Dynamic ? ((10 * MaxPacketSize) + 1) : ColsAtCompileTime;
1283  const Index testSize = testRows * testCols;
1284  const Index minTestSize = 100;
1285  const Index repeats = numext::div_ceil(minTestSize, testSize);
1286 
1287  SrcArray src(testRows, testCols);
1288  DstArray dst(testRows, testCols);
1289 
1290  for (Index repeat = 0; repeat < repeats; repeat++) {
1291  src = src.unaryExpr(RandomOp());
1292  dst = src.template cast<DstType>();
1293 
1294  for (Index j = 0; j < testCols; j++)
1295  for (Index i = 0; i < testRows; i++) {
1296  SrcType srcVal = src(i, j);
1297  DstType refVal = internal::cast_impl<SrcType, DstType>::run(srcVal);
1298  DstType dstVal = dst(i, j);
1299  bool isApprox = verifyIsApprox(dstVal, refVal);
1300  if (!isApprox)
1301  std::cout << type_name(srcVal) << ": [" << +srcVal << "] to " << type_name(dstVal) << ": [" << +dstVal
1302  << "] != [" << +refVal << "]\n";
1303  VERIFY(isApprox);
1304  }
1305  }
1306  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
string type_name()
Definition: benchmark-blocking-sizes.cpp:226
#define VERIFY(a)
Definition: main.h:362
EIGEN_DEVICE_FUNC bool isApprox(const Scalar &x, const Scalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
Definition: MathFunctions.h:1923
constexpr array< t, n > repeat(t v)
Definition: MoreMeta.h:583
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE EIGEN_CONSTEXPR T div_ceil(T a, T b)
Definition: MathFunctions.h:1251
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
bool verifyIsApprox(const Type1 &a, const Type2 &b)
Definition: main.h:609
const int Dynamic
Definition: Constants.h:25
static constexpr int MaxPacketSize
Definition: array_cwise.cpp:1278
Array< DstType, RowsAtCompileTime, ColsAtCompileTime > DstArray
Definition: array_cwise.cpp:1269
Array< SrcType, RowsAtCompileTime, ColsAtCompileTime > SrcArray
Definition: array_cwise.cpp:1268
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
void run(const string &dir_name, LinearSolver *linear_solver_pt, const unsigned nel_1d, bool mess_up_order)
Definition: two_d_poisson_compare_solvers.cc:317

References Eigen::numext::div_ceil(), Eigen::Dynamic, i, Eigen::internal::isApprox(), j, cast_test_impl< SrcType, DstType, RowsAtCompileTime, ColsAtCompileTime >::MaxPacketSize, Eigen::internal::repeat(), run(), type_name(), VERIFY, and Eigen::verifyIsApprox().

Referenced by cast_tests_impl< RowsAtCompileTime, ColsAtCompileTime, ScalarTypes >::run().

Member Data Documentation

◆ DstPacketSize

template<typename SrcType , typename DstType , int RowsAtCompileTime, int ColsAtCompileTime>
constexpr int cast_test_impl< SrcType, DstType, RowsAtCompileTime, ColsAtCompileTime >::DstPacketSize = internal::packet_traits<DstType>::size
staticconstexpr

◆ MaxPacketSize

template<typename SrcType , typename DstType , int RowsAtCompileTime, int ColsAtCompileTime>
constexpr int cast_test_impl< SrcType, DstType, RowsAtCompileTime, ColsAtCompileTime >::MaxPacketSize = internal::plain_enum_max(SrcPacketSize, DstPacketSize)
staticconstexpr

◆ SrcPacketSize

template<typename SrcType , typename DstType , int RowsAtCompileTime, int ColsAtCompileTime>
constexpr int cast_test_impl< SrcType, DstType, RowsAtCompileTime, ColsAtCompileTime >::SrcPacketSize = internal::packet_traits<SrcType>::size
staticconstexpr

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