12 #include <Eigen/CXX11/Tensor> 16 template<
int DataLayout>
21 array<ptrdiff_t, 4> strides;
28 no_stride = tensor.
stride(strides);
30 VERIFY_IS_EQUAL(no_stride.
dimension(0), 2);
31 VERIFY_IS_EQUAL(no_stride.
dimension(1), 3);
32 VERIFY_IS_EQUAL(no_stride.
dimension(2), 5);
33 VERIFY_IS_EQUAL(no_stride.
dimension(3), 7);
35 for (
int i = 0; i < 2; ++i) {
36 for (
int j = 0; j < 3; ++j) {
37 for (
int k = 0; k < 5; ++k) {
38 for (
int l = 0; l < 7; ++l) {
39 VERIFY_IS_EQUAL(tensor(i,j,k,l), no_stride(i,j,k,l));
50 stride = tensor.
stride(strides);
57 for (
int i = 0; i < 1; ++i) {
58 for (
int j = 0; j < 1; ++j) {
59 for (
int k = 0; k < 3; ++k) {
60 for (
int l = 0; l < 3; ++l) {
61 VERIFY_IS_EQUAL(tensor(2*i,4*j,2*k,3*l), stride(i,j,k,l));
69 template<
int DataLayout>
74 array<ptrdiff_t, 4> strides;
81 result.
stride(strides) = tensor;
83 for (
int i = 0; i < 2; ++i) {
84 for (
int j = 0; j < 3; ++j) {
85 for (
int k = 0; k < 5; ++k) {
86 for (
int l = 0; l < 7; ++l) {
87 VERIFY_IS_EQUAL(tensor(i,j,k,l), result(2*i,4*j,2*k,3*l));
93 array<ptrdiff_t, 4> no_strides;
101 for (
int i = 0; i < 2; ++i) {
102 for (
int j = 0; j < 3; ++j) {
103 for (
int k = 0; k < 5; ++k) {
104 for (
int l = 0; l < 7; ++l) {
105 VERIFY_IS_EQUAL(tensor(i,j,k,l), result2(2*i,4*j,2*k,3*l));
115 CALL_SUBTEST(test_simple_striding<ColMajor>());
116 CALL_SUBTEST(test_simple_striding<RowMajor>());
117 CALL_SUBTEST(test_striding_as_lvalue<ColMajor>());
118 CALL_SUBTEST(test_striding_as_lvalue<RowMajor>());
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index dimension(std::size_t n) const
static void test_striding_as_lvalue()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor< Scalar_, NumIndices_, Options_, IndexType_ > & setRandom()
static void test_simple_striding()
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const TensorStridingOp< const Strides, const Tensor< Scalar_, NumIndices_, Options_, IndexType_ > > stride(const Strides &strides) const
void test_cxx11_tensor_striding()