From ec5a81b45aeae230dcc7ec724935e5f9e3124d3f Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Thu, 5 Nov 2015 13:39:48 -0800 Subject: Fixed a bug in the extraction of sizes of fixed sized tensors of rank 0 --- unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h') diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h b/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h index 145ca0d64..ae02d15a2 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h @@ -75,8 +75,8 @@ struct fixed_size_tensor_index_extraction_helper static inline Index run(const Index index, const Dimensions& dimensions) { - const Index mult = (index == n) ? 1 : 0; - return array_get(dimensions) * mult + + const Index mult = (index == n-1) ? 1 : 0; + return array_get(dimensions) * mult + fixed_size_tensor_index_extraction_helper::run(index, dimensions); } }; @@ -85,13 +85,12 @@ template struct fixed_size_tensor_index_extraction_helper { template EIGEN_DEVICE_FUNC - static inline Index run(const Index index, - const Dimensions& dimensions) + static inline Index run(const Index, + const Dimensions&) { - const Index mult = (index == 0) ? 1 : 0; - return array_get<0>(dimensions) * mult; + return 0; } -}; + }; } // end namespace internal @@ -129,7 +128,7 @@ struct Sizes : internal::numeric_list { } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t operator[] (const std::size_t index) const { - return internal::fixed_size_tensor_index_extraction_helper::run(index, *this); + return internal::fixed_size_tensor_index_extraction_helper::run(index, *this); } template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE @@ -386,6 +385,10 @@ static const std::ptrdiff_t value = Sizes::count; template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t array_get(const Sizes&) { return get >::value; } +template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t array_get(const Sizes<>&) { + eigen_assert(false && "should never be called"); + return -1; +} #else template struct array_size > { static const size_t value = Sizes::count; -- cgit v1.2.3