12 #include <Eigen/CXX11/Tensor> 16 template<
int DataLayout>
21 array<ptrdiff_t, 4> strides;
29 no_stride = tensor.inflate(strides);
31 VERIFY_IS_EQUAL(no_stride.
dimension(0), 2);
32 VERIFY_IS_EQUAL(no_stride.
dimension(1), 3);
33 VERIFY_IS_EQUAL(no_stride.
dimension(2), 5);
34 VERIFY_IS_EQUAL(no_stride.
dimension(3), 7);
36 for (
int i = 0; i < 2; ++i) {
37 for (
int j = 0; j < 3; ++j) {
38 for (
int k = 0; k < 5; ++k) {
39 for (
int l = 0; l < 7; ++l) {
40 VERIFY_IS_EQUAL(tensor(i,j,k,l), no_stride(i,j,k,l));
51 inflated = tensor.inflate(strides);
53 VERIFY_IS_EQUAL(inflated.
dimension(0), 3);
54 VERIFY_IS_EQUAL(inflated.
dimension(1), 9);
55 VERIFY_IS_EQUAL(inflated.
dimension(2), 9);
56 VERIFY_IS_EQUAL(inflated.
dimension(3), 19);
58 for (
int i = 0; i < 3; ++i) {
59 for (
int j = 0; j < 9; ++j) {
60 for (
int k = 0; k < 9; ++k) {
61 for (
int l = 0; l < 19; ++l) {
66 VERIFY_IS_EQUAL(inflated(i,j,k,l),
67 tensor(i/2, j/4, k/2, l/3));
69 VERIFY_IS_EQUAL(0, inflated(i,j,k,l));
79 CALL_SUBTEST(test_simple_inflation<ColMajor>());
80 CALL_SUBTEST(test_simple_inflation<RowMajor>());
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index dimension(std::size_t n) const
void test_cxx11_tensor_inflation()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor< Scalar_, NumIndices_, Options_, IndexType_ > & setRandom()
static void test_simple_inflation()