From 31afdcb4c2954f7b8c01b0f27fb39f607e94feca Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Thu, 17 Sep 2015 09:40:21 -0700 Subject: [PATCH] Fix return type for TensorEvaluator::data --- unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h | 4 ++-- unsupported/test/cxx11_tensor_morphing.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h b/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h index dad656313..bdc86e0fa 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h @@ -463,8 +463,8 @@ struct TensorEvaluator, Devi return m_impl.coeff(inputCoords); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType* data() const { - CoeffReturnType* result = m_impl.data(); + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar* data() const { + Scalar* result = m_impl.data(); if (result) { Index offset = 0; if (static_cast(Layout) == static_cast(ColMajor)) { diff --git a/unsupported/test/cxx11_tensor_morphing.cpp b/unsupported/test/cxx11_tensor_morphing.cpp index 733154543..eb3b891fd 100644 --- a/unsupported/test/cxx11_tensor_morphing.cpp +++ b/unsupported/test/cxx11_tensor_morphing.cpp @@ -114,6 +114,16 @@ static void test_simple_slice() } } +static void test_const_slice() +{ + const float b[1] = {42}; + TensorMap > m(b, 1); + DSizes offsets; + offsets[0] = 0; + TensorRef > slice_ref(m.slice(offsets, m.dimensions())); + VERIFY_IS_EQUAL(slice_ref(0), 42); +} + template static void test_slice_in_expr() { typedef Matrix Mtx; @@ -333,6 +343,7 @@ void test_cxx11_tensor_morphing() CALL_SUBTEST(test_simple_slice()); CALL_SUBTEST(test_simple_slice()); + CALL_SUBTEST(test_const_slice()); CALL_SUBTEST(test_slice_in_expr()); CALL_SUBTEST(test_slice_in_expr()); CALL_SUBTEST(test_slice_as_lvalue());