Fixed the tensor shuffling test

This commit is contained in:
Benoit Steiner
2014-10-10 15:43:21 -07:00
parent a991f94c0e
commit 4b36c3591f
5 changed files with 141 additions and 13 deletions

View File

@@ -119,7 +119,7 @@ if(EIGEN_TEST_CXX11)
ei_add_test(cxx11_tensor_morphing "-std=c++0x")
ei_add_test(cxx11_tensor_padding "-std=c++0x")
ei_add_test(cxx11_tensor_reduction "-std=c++0x")
# ei_add_test(cxx11_tensor_shuffling "-std=c++0x")
ei_add_test(cxx11_tensor_shuffling "-std=c++0x")
ei_add_test(cxx11_tensor_striding "-std=c++0x")
# ei_add_test(cxx11_tensor_device "-std=c++0x")
ei_add_test(cxx11_tensor_thread_pool "-std=c++0x")

View File

@@ -179,7 +179,7 @@ static void test_array()
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 3; ++j) {
for (int k = 0; k < 7; ++k) {
VERIFY_IS_APPROX(mat3(array<ptrdiff_t, 3>(i,j,k)), powf(val, 3.5f));
VERIFY_IS_APPROX(mat3(i,j,k), powf(val, 3.5f));
val += 1.0;
}
}

View File

@@ -12,6 +12,7 @@
#include <Eigen/CXX11/Tensor>
using Eigen::Tensor;
using Eigen::array;
static void test_simple_shuffling()
{
@@ -80,10 +81,10 @@ static void test_expr_shuffling()
Tensor<float, 4> result(5,7,3,2);
array<int, 4> src_slice_dim(Eigen::array<int, 4>(2,3,1,7));
array<int, 4> src_slice_start(Eigen::array<int, 4>(0,0,0,0));
array<int, 4> dst_slice_dim(Eigen::array<int, 4>(1,7,3,2));
array<int, 4> dst_slice_start(Eigen::array<int, 4>(0,0,0,0));
array<int, 4> src_slice_dim{{2,3,1,7}};
array<int, 4> src_slice_start{{0,0,0,0}};
array<int, 4> dst_slice_dim{{1,7,3,2}};
array<int, 4> dst_slice_start{{0,0,0,0}};
for (int i = 0; i < 5; ++i) {
result.slice(dst_slice_start, dst_slice_dim) =