diff options
author | Benoit Steiner <benoit.steiner.goog@gmail.com> | 2015-07-17 16:46:30 -0700 |
---|---|---|
committer | Benoit Steiner <benoit.steiner.goog@gmail.com> | 2015-07-17 16:46:30 -0700 |
commit | 7a39439904751f0269a4fe39805785a5353238b5 (patch) | |
tree | 114e6bc6170267fb083574e73810f502c57493a1 /unsupported/Eigen/CXX11/src | |
parent | e94f9eb637165ccb451dd5dd8ebc16058ca4b32b (diff) |
Rewrote Eigen::dimensions_match to prevent a static assertion when the rank of the tensors is different.
Diffstat (limited to 'unsupported/Eigen/CXX11/src')
-rw-r--r-- | unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h b/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h index 7a1d40d7d..2b5de4f55 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h @@ -401,15 +401,21 @@ template <std::size_t n, std::size_t V1, std::size_t V2, std::size_t V3, std::si #endif -template <typename Dims1, typename Dims2, size_t n> +template <typename Dims1, typename Dims2, size_t n, size_t m> struct sizes_match_up_to_dim { static inline bool run(Dims1& dims1, Dims2& dims2) { + return false; + } +}; +template <typename Dims1, typename Dims2, size_t n> +struct sizes_match_up_to_dim<Dims1, Dims2, n, n> { + static inline bool run(Dims1& dims1, Dims2& dims2) { return (array_get<n>(dims1) == array_get<n>(dims2)) & - sizes_match_up_to_dim<Dims1, Dims2, n-1>::run(dims1, dims2); + sizes_match_up_to_dim<Dims1, Dims2, n-1, n-1>::run(dims1, dims2); } }; template <typename Dims1, typename Dims2> -struct sizes_match_up_to_dim<Dims1, Dims2, 0> { +struct sizes_match_up_to_dim<Dims1, Dims2, 0, 0> { static inline bool run(Dims1& dims1, Dims2& dims2) { return (array_get<0>(dims1) == array_get<0>(dims2)); } @@ -420,10 +426,7 @@ struct sizes_match_up_to_dim<Dims1, Dims2, 0> { template <typename Dims1, typename Dims2> bool dimensions_match(Dims1& dims1, Dims2& dims2) { - if (static_cast<size_t>(internal::array_size<Dims1>::value) != static_cast<size_t>(internal::array_size<Dims2>::value)) { - return false; - } - return internal::sizes_match_up_to_dim<Dims1, Dims2, internal::array_size<Dims1>::value-1>::run(dims1, dims2); + return internal::sizes_match_up_to_dim<Dims1, Dims2, internal::array_size<Dims1>::value-1, internal::array_size<Dims2>::value-1>::run(dims1, dims2); } } // end namespace Eigen |