From de1e9f29f4db2c837ffb354c90f9e9fb7df05e85 Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Thu, 15 Oct 2015 14:58:49 -0700 Subject: Updated the custom indexing code: we can now use any container that provides the [] operator to index a tensor. Added unit tests to validate the use of std::map and a few more types as valid custom index containers --- unsupported/Eigen/CXX11/src/Tensor/Tensor.h | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'unsupported/Eigen/CXX11/src/Tensor/Tensor.h') diff --git a/unsupported/Eigen/CXX11/src/Tensor/Tensor.h b/unsupported/Eigen/CXX11/src/Tensor/Tensor.h index 57d44baf9..3ac465d24 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/Tensor.h +++ b/unsupported/Eigen/CXX11/src/Tensor/Tensor.h @@ -91,7 +91,7 @@ class Tensor : public TensorBase struct isOfNormalIndex{ - static const bool is_array = internal::is_base_of, CustomIndices >::value; + static const bool is_array = internal::is_base_of, CustomIndices>::value; static const bool is_int = NumTraits::IsInteger; static const bool value = is_array | is_int; }; @@ -120,11 +120,8 @@ class Tensor : public TensorBase{{firstIndex, secondIndex, otherIndices...}}); } - - #endif - // normal indices EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar& coeff(const array& indices) const { @@ -137,7 +134,7 @@ class Tensor : public TensorBase::value) ) > - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar& coeff(const CustomIndices & indices) const + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar& coeff(CustomIndices& indices) const { return coeff(internal::customIndices2Array(indices)); } @@ -171,7 +168,7 @@ class Tensor : public TensorBase::value) ) > - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(const CustomIndices & indices) + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& coeffRef(CustomIndices& indices) { return coeffRef(internal::customIndices2Array(indices)); } @@ -219,7 +216,7 @@ class Tensor : public TensorBase::value) ) > - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar& operator()(const CustomIndices & indices) const + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar& operator()(CustomIndices& indices) const { return coeff(internal::customIndices2Array(indices)); } @@ -286,7 +283,7 @@ class Tensor : public TensorBase::value) ) > - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& operator()(const CustomIndices & indices) + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar& operator()(CustomIndices& indices) { return coeffRef(internal::customIndices2Array(indices)); } @@ -441,9 +438,9 @@ class Tensor : public TensorBase::value) ) > - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(const CustomDimension & dimensions) + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void resize(CustomDimension& dimensions) { - return coeffRef(internal::customIndices2Array(dimensions)); + resize(internal::customIndices2Array(dimensions)); } #endif -- cgit v1.2.3