From 9f721384e080067e05ee1fd165e33aa9c77f25b7 Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Mon, 26 Oct 2015 11:21:27 -0700 Subject: Added support for empty dimensions --- .../Eigen/CXX11/src/Tensor/TensorDimensions.h | 35 +++++++++++----------- 1 file changed, 17 insertions(+), 18 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 d6ec62a74..89e28bdb5 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h @@ -52,8 +52,8 @@ struct fixed_size_tensor_index_linearization_helper static inline Index run(array const& indices, const Dimensions& dimensions) { - return array_get(indices) + - dget::value * + return array_get(indices) + + dget::value * fixed_size_tensor_index_linearization_helper::run(indices, dimensions); } }; @@ -62,10 +62,9 @@ template struct fixed_size_tensor_index_linearization_helper { template EIGEN_DEVICE_FUNC - static inline Index run(array const& indices, - const Dimensions&) + static inline Index run(array const&, const Dimensions&) { - return array_get(indices); + return 0; } }; @@ -135,11 +134,11 @@ struct Sizes : internal::numeric_list { template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE size_t IndexOfColMajor(const array& indices) const { - return internal::fixed_size_tensor_index_linearization_helper::run(indices, *static_cast(this)); + return internal::fixed_size_tensor_index_linearization_helper::run(indices, *static_cast(this)); } template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE size_t IndexOfRowMajor(const array& indices) const { - return internal::fixed_size_tensor_index_linearization_helper::run(indices, *static_cast(this)); + return internal::fixed_size_tensor_index_linearization_helper::run(indices, *static_cast(this)); } }; @@ -222,11 +221,11 @@ template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE size_t IndexOfColMajor(const array& indices) const { - return internal::fixed_size_tensor_index_linearization_helper::run(indices, *reinterpret_cast(this)); + return internal::fixed_size_tensor_index_linearization_helper::run(indices, *reinterpret_cast(this)); } template EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE size_t IndexOfRowMajor(const array& indices) const { - return internal::fixed_size_tensor_index_linearization_helper::run(indices, *reinterpret_cast(this)); + return internal::fixed_size_tensor_index_linearization_helper::run(indices, *reinterpret_cast(this)); } }; @@ -402,22 +401,22 @@ template -struct sizes_match_up_to_dim { - static inline bool run(Dims1&, Dims2&) { +struct sizes_match_below_dim { + static inline bool run(Dims1& dims1, Dims2& dims2) { return false; } }; template -struct sizes_match_up_to_dim { +struct sizes_match_below_dim { static inline bool run(Dims1& dims1, Dims2& dims2) { - return (array_get(dims1) == array_get(dims2)) & - sizes_match_up_to_dim::run(dims1, dims2); + return (array_get(dims1) == array_get(dims2)) & + sizes_match_below_dim::run(dims1, dims2); } }; template -struct sizes_match_up_to_dim { - static inline bool run(Dims1& dims1, Dims2& dims2) { - return (array_get<0>(dims1) == array_get<0>(dims2)); +struct sizes_match_below_dim { + static inline bool run(Dims1&, Dims2&) { + return true; } }; @@ -426,7 +425,7 @@ struct sizes_match_up_to_dim { template bool dimensions_match(Dims1& dims1, Dims2& dims2) { - return internal::sizes_match_up_to_dim::value-1, internal::array_size::value-1>::run(dims1, dims2); + return internal::sizes_match_below_dim::value, internal::array_size::value>::run(dims1, dims2); } } // end namespace Eigen -- cgit v1.2.3