13 #include <Eigen/CXX11/Tensor> 21 ftensor = ftensor.random() * 100.f;
27 chartensor = ftensor.cast<
char>();
28 cplextensor = ftensor.cast<std::complex<float> >();
30 for (
int i = 0;
i < 20; ++
i) {
31 for (
int j = 0;
j < 30; ++
j) {
42 itensor = itensor.random() / 1000;
48 ftensor = itensor.cast<
float>();
49 dtensor = itensor.cast<
double>();
51 for (
int i = 0;
i < 20; ++
i) {
52 for (
int j = 0;
j < 30; ++
j) {
63 ftensor = ftensor.random() * 1000.0f;
65 dtensor = dtensor.random() * 1000.0;
70 for (
int i = 0;
i < 20; ++
i) {
71 for (
int j = 0;
j < 30; ++
j) {
84 ftensor = dtensor.cast<
float>();
86 for (
int i = 0;
i < 20; ++
i) {
87 for (
int j = 0;
j < 30; ++
j) {
99 dtensor = ftensor.cast<
double>();
101 for (
int i = 0;
i < 20; ++
i) {
102 for (
int j = 0;
j < 30; ++
j) {
108 template <
typename FromType,
typename ToType>
112 for (
int i = 0;
i < 100; ++
i) {
113 for (
int j = 0;
j < 200; ++
j) {
119 ttensor = ftensor.template cast<ToType>();
121 for (
int i = 0;
i < 100; ++
i) {
122 for (
int j = 0;
j < 200; ++
j) {
123 const ToType
ref = internal::cast<FromType,ToType>(ftensor(
i,
j));
129 template<
typename Scalar,
typename EnableIf =
void>
151 template<
typename Scalar>
EIGEN_DECLARE_TEST(cxx11_tensor_casts)
static void test_simple_cast()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor< Scalar_, NumIndices_, Options_, IndexType_ > & setRandom()
static void test_vectorized_cast()
static void test_small_to_big_type_cast()
#define VERIFY_IS_APPROX(a, b)
#define VERIFY_IS_EQUAL(a, b)
unsigned __int64 uint64_t
static void test_big_to_small_type_cast()
Reference counting helper.
static void test_float_to_int_cast()
#define CALL_SUBTEST(FUNC)
static void test_type_cast()