From 6edae2d30d5a74a3234f6a91adb5ffdb1b86bbfc Mon Sep 17 00:00:00 2001 From: Gabriel Nützi Date: Fri, 9 Oct 2015 18:52:48 +0200 Subject: added CustomIndex capability only to Tensor and not yet to TensorBase. using Sfinae and is_base_of to select correct template which converts to array MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit user: Gabriel Nützi branch 'default' added unsupported/Eigen/CXX11/src/Tensor/TensorMetaMacros.h added unsupported/test/cxx11_tensor_customIndex.cpp changed unsupported/Eigen/CXX11/Tensor changed unsupported/Eigen/CXX11/src/Tensor/Tensor.h changed unsupported/Eigen/CXX11/src/Tensor/TensorMeta.h changed unsupported/test/CMakeLists.txt --- unsupported/Eigen/CXX11/src/Tensor/TensorMeta.h | 51 +++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'unsupported/Eigen/CXX11/src/Tensor/TensorMeta.h') diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorMeta.h b/unsupported/Eigen/CXX11/src/Tensor/TensorMeta.h index 7dfa04760..60a6c1469 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorMeta.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorMeta.h @@ -34,6 +34,9 @@ template <> struct max_n_1<0> { + + + #if defined(EIGEN_HAS_CONSTEXPR) #define EIGEN_CONSTEXPR constexpr #else @@ -83,6 +86,54 @@ bool operator!=(const Tuple& x, const Tuple& y) { return !(x == y); } + + + +namespace internal{ + + template + EIGEN_CONSTEXPR EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE + array customIndex2Array(const IndexType & idx, numeric_list) { + return { idx(Is)... }; + } + + /** Make an array (for index/dimensions) out of a custom index */ + template + EIGEN_CONSTEXPR EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE + array customIndex2Array(const IndexType & idx) { + return customIndex2Array(idx, typename gen_numeric_list::type{}); + } + + + template + struct is_base_of + { + + typedef char (&yes)[1]; + typedef char (&no)[2]; + + template + struct Host + { + operator BB*() const; + operator DD*(); + }; + + template + static yes check(D*, T); + static no check(B*, int); + + static const bool value = sizeof(check(Host(), int())) == sizeof(yes); + }; + +} + + + + + + + #undef EIGEN_CONSTEXPR } // namespace Eigen -- cgit v1.2.3