cxx11_tensor_casts.cpp File Reference
#include "main.h"
#include "random_without_cast_overflow.h"
#include <Eigen/CXX11/Tensor>

Classes

struct  test_cast_runner< Scalar, EnableIf >
 
struct  test_cast_runner< Scalar, std::enable_if_t< NumTraits< Scalar >::IsComplex > >
 

Functions

template<typename FromType , typename ToType >
static void test_type_cast ()
 
 EIGEN_DECLARE_TEST (cxx11_tensor_casts)
 

Function Documentation

◆ EIGEN_DECLARE_TEST()

EIGEN_DECLARE_TEST ( cxx11_tensor_casts  )
71  {
85  CALL_SUBTEST(test_cast_runner<std::complex<float>>::run());
86  CALL_SUBTEST(test_cast_runner<std::complex<double>>::run());
87 }
#define CALL_SUBTEST(FUNC)
Definition: main.h:382
Definition: cxx11_tensor_casts.cpp:40
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 CALL_SUBTEST, and run().

◆ test_type_cast()

template<typename FromType , typename ToType >
static void test_type_cast ( )
static
19  {
20  Tensor<FromType, 2> ftensor(101, 201);
21  // Generate random values for a valid cast.
22  for (int i = 0; i < 101; ++i) {
23  for (int j = 0; j < 201; ++j) {
25  }
26  }
27 
28  Tensor<ToType, 2> ttensor(101, 201);
29  ttensor = ftensor.template cast<ToType>();
30 
31  for (int i = 0; i < 101; ++i) {
32  for (int j = 0; j < 201; ++j) {
33  const ToType ref = internal::cast<FromType, ToType>(ftensor(i, j));
34  VERIFY_IS_EQUAL(ttensor(i, j), ref);
35  }
36  }
37 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
The tensor class.
Definition: Tensor.h:68
#define VERIFY_IS_EQUAL(a, b)
Definition: main.h:367
squared absolute value
Definition: GlobalFunctions.h:87
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References i, j, Eigen::value, and VERIFY_IS_EQUAL.