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

Functions

static void test_simple_assign ()
 
static void test_assign_of_const_tensor ()
 
 EIGEN_DECLARE_TEST (cxx11_tensor_const)
 

Function Documentation

◆ EIGEN_DECLARE_TEST()

EIGEN_DECLARE_TEST ( cxx11_tensor_const  )
53  {
56 }
static void test_assign_of_const_tensor()
Definition: cxx11_tensor_const.cpp:32
static void test_simple_assign()
Definition: cxx11_tensor_const.cpp:15
#define CALL_SUBTEST(FUNC)
Definition: main.h:382

References CALL_SUBTEST, test_assign_of_const_tensor(), and test_simple_assign().

◆ test_assign_of_const_tensor()

static void test_assign_of_const_tensor ( )
static
32  {
33  Tensor<int, 3> random(2, 3, 7);
34  random.setRandom();
35 
36  TensorMap<Tensor<const int, 3> > constant1(random.data(), 2, 3, 7);
37  TensorMap<const Tensor<int, 3> > constant2(random.data(), 2, 3, 7);
38  const TensorMap<Tensor<int, 3> > constant3(random.data(), 2, 3, 7);
39 
40  Tensor<int, 2> result1 = constant1.chip(0, 2);
41  Tensor<int, 2> result2 = constant2.chip(0, 2);
42  Tensor<int, 2> result3 = constant3.chip(0, 2);
43 
44  for (int i = 0; i < 2; ++i) {
45  for (int j = 0; j < 3; ++j) {
46  VERIFY_IS_EQUAL((result1(i, j)), random(i, j, 0));
47  VERIFY_IS_EQUAL((result2(i, j)), random(i, j, 0));
48  VERIFY_IS_EQUAL((result3(i, j)), random(i, j, 0));
49  }
50  }
51 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TensorChippingOp< DimId, const Derived > chip(const Index offset) const
Definition: TensorBase.h:1141
A tensor expression mapping an existing array of data.
Definition: TensorMap.h:33
The tensor class.
Definition: Tensor.h:68
#define VERIFY_IS_EQUAL(a, b)
Definition: main.h:367
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References Eigen::TensorBase< Derived, AccessLevel >::chip(), Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::data(), i, j, Eigen::TensorBase< Derived, AccessLevel >::setRandom(), and VERIFY_IS_EQUAL.

Referenced by EIGEN_DECLARE_TEST().

◆ test_simple_assign()

static void test_simple_assign ( )
static
15  {
16  Tensor<int, 3> random(2, 3, 7);
17  random.setRandom();
18 
19  TensorMap<Tensor<const int, 3> > constant(random.data(), 2, 3, 7);
20  Tensor<int, 3> result(2, 3, 7);
21  result = constant;
22 
23  for (int i = 0; i < 2; ++i) {
24  for (int j = 0; j < 3; ++j) {
25  for (int k = 0; k < 7; ++k) {
26  VERIFY_IS_EQUAL((result(i, j, k)), random(i, j, k));
27  }
28  }
29  }
30 }
char char char int int * k
Definition: level2_impl.h:374

References Eigen::Tensor< Scalar_, NumIndices_, Options_, IndexType_ >::data(), i, j, k, Eigen::TensorBase< Derived, AccessLevel >::setRandom(), and VERIFY_IS_EQUAL.

Referenced by EIGEN_DECLARE_TEST().