diff options
author | Benoit Steiner <benoit.steiner.goog@gmail.com> | 2015-11-05 13:39:48 -0800 |
---|---|---|
committer | Benoit Steiner <benoit.steiner.goog@gmail.com> | 2015-11-05 13:39:48 -0800 |
commit | ec5a81b45aeae230dcc7ec724935e5f9e3124d3f (patch) | |
tree | 958cf9b900da6f86967c5a2ff3631cf81fc9c7ea /unsupported | |
parent | beedd9630dd6e6044081e4c7dfc84f26a6d6193f (diff) |
Fixed a bug in the extraction of sizes of fixed sized tensors of rank 0
Diffstat (limited to 'unsupported')
-rw-r--r-- | unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h | 19 |
1 files changed, 11 insertions, 8 deletions
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<n>(dimensions) * mult + + const Index mult = (index == n-1) ? 1 : 0; + return array_get<n-1>(dimensions) * mult + fixed_size_tensor_index_extraction_helper<Index, n - 1>::run(index, dimensions); } }; @@ -85,13 +85,12 @@ template<typename Index> struct fixed_size_tensor_index_extraction_helper<Index, 0> { template <typename Dimensions> 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<std::ptrdiff_t, Indices...> { } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t operator[] (const std::size_t index) const { - return internal::fixed_size_tensor_index_extraction_helper<std::ptrdiff_t, Base::count - 1>::run(index, *this); + return internal::fixed_size_tensor_index_extraction_helper<std::ptrdiff_t, Base::count>::run(index, *this); } template <typename DenseIndex> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE @@ -386,6 +385,10 @@ static const std::ptrdiff_t value = Sizes<Indices...>::count; template <std::ptrdiff_t n, typename std::ptrdiff_t... Indices> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t array_get(const Sizes<Indices...>&) { return get<n, internal::numeric_list<std::size_t, Indices...> >::value; } +template <std::ptrdiff_t n> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t array_get(const Sizes<>&) { + eigen_assert(false && "should never be called"); + return -1; +} #else template <std::size_t V1, std::size_t V2, std::size_t V3, std::size_t V4, std::size_t V5> struct array_size<const Sizes<V1,V2,V3,V4,V5> > { static const size_t value = Sizes<V1,V2,V3,V4,V5>::count; |