From 7a39439904751f0269a4fe39805785a5353238b5 Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Fri, 17 Jul 2015 16:46:30 -0700 Subject: Rewrote Eigen::dimensions_match to prevent a static assertion when the rank of the tensors is different. --- unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 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 7a1d40d7d..2b5de4f55 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorDimensions.h @@ -401,15 +401,21 @@ template +template struct sizes_match_up_to_dim { + static inline bool run(Dims1& dims1, Dims2& dims2) { + return false; + } +}; +template +struct sizes_match_up_to_dim { static inline bool run(Dims1& dims1, Dims2& dims2) { return (array_get(dims1) == array_get(dims2)) & - sizes_match_up_to_dim::run(dims1, dims2); + sizes_match_up_to_dim::run(dims1, dims2); } }; template -struct sizes_match_up_to_dim { +struct sizes_match_up_to_dim { 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 { template bool dimensions_match(Dims1& dims1, Dims2& dims2) { - if (static_cast(internal::array_size::value) != static_cast(internal::array_size::value)) { - return false; - } - return internal::sizes_match_up_to_dim::value-1>::run(dims1, dims2); + return internal::sizes_match_up_to_dim::value-1, internal::array_size::value-1>::run(dims1, dims2); } } // end namespace Eigen -- cgit v1.2.3