diff options
author | Benoit Steiner <benoit.steiner.goog@gmail.com> | 2015-03-30 14:55:54 -0700 |
---|---|---|
committer | Benoit Steiner <benoit.steiner.goog@gmail.com> | 2015-03-30 14:55:54 -0700 |
commit | 35722fa0222a7f99a8179d75244177a9801ea36b (patch) | |
tree | 151d3b1e7dac4b322afd00f719d5e0934dd542e1 /unsupported/Eigen/CXX11/src/Tensor/TensorTraits.h | |
parent | 71950f02e573bcffa589e83f188bc64b717af1c7 (diff) |
Made the index type a template parameter of the tensor class instead of encoding it in the options.
Diffstat (limited to 'unsupported/Eigen/CXX11/src/Tensor/TensorTraits.h')
-rw-r--r-- | unsupported/Eigen/CXX11/src/Tensor/TensorTraits.h | 71 |
1 files changed, 30 insertions, 41 deletions
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorTraits.h b/unsupported/Eigen/CXX11/src/Tensor/TensorTraits.h index 0745b1742..ba09298c3 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorTraits.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorTraits.h @@ -43,24 +43,13 @@ class compute_tensor_flags enum { ret = packet_access_bit | aligned_bit}; }; -template<bool force32bit> -struct compute_index_type { - typedef DenseIndex type; -}; - -template<> -struct compute_index_type<true> { - typedef int type; -}; - - -template<typename Scalar_, std::size_t NumIndices_, int Options_> -struct traits<Tensor<Scalar_, NumIndices_, Options_> > +template<typename Scalar_, std::size_t NumIndices_, int Options_, typename IndexType_> +struct traits<Tensor<Scalar_, NumIndices_, Options_, IndexType_> > { typedef Scalar_ Scalar; typedef Dense StorageKind; - typedef typename compute_index_type<static_cast<bool>(Options_&Index32Bit)>::type Index; + typedef IndexType_ Index; static const int NumDimensions = NumIndices_; static const int Layout = Options_ & RowMajor ? RowMajor : ColMajor; enum { @@ -70,12 +59,12 @@ struct traits<Tensor<Scalar_, NumIndices_, Options_> > }; -template<typename Scalar_, typename Dimensions, int Options_> -struct traits<TensorFixedSize<Scalar_, Dimensions, Options_> > +template<typename Scalar_, typename Dimensions, int Options_, typename IndexType_> +struct traits<TensorFixedSize<Scalar_, Dimensions, Options_, IndexType_> > { typedef Scalar_ Scalar; typedef Dense StorageKind; - typedef typename compute_index_type<static_cast<bool>(Options_&Index32Bit)>::type Index; + typedef IndexType_ Index; static const int NumDimensions = array_size<Dimensions>::value; static const int Layout = Options_ & RowMajor ? RowMajor : ColMajor; enum { @@ -118,28 +107,28 @@ struct traits<TensorRef<PlainObjectType> > }; -template<typename _Scalar, std::size_t NumIndices_, int Options> -struct eval<Tensor<_Scalar, NumIndices_, Options>, Eigen::Dense> +template<typename _Scalar, std::size_t NumIndices_, int Options, typename IndexType_> +struct eval<Tensor<_Scalar, NumIndices_, Options, IndexType_>, Eigen::Dense> { - typedef const Tensor<_Scalar, NumIndices_, Options>& type; + typedef const Tensor<_Scalar, NumIndices_, Options, IndexType_>& type; }; -template<typename _Scalar, std::size_t NumIndices_, int Options> -struct eval<const Tensor<_Scalar, NumIndices_, Options>, Eigen::Dense> +template<typename _Scalar, std::size_t NumIndices_, int Options, typename IndexType_> +struct eval<const Tensor<_Scalar, NumIndices_, Options, IndexType_>, Eigen::Dense> { - typedef const Tensor<_Scalar, NumIndices_, Options>& type; + typedef const Tensor<_Scalar, NumIndices_, Options, IndexType_>& type; }; -template<typename Scalar_, typename Dimensions, int Options> -struct eval<TensorFixedSize<Scalar_, Dimensions, Options>, Eigen::Dense> +template<typename Scalar_, typename Dimensions, int Options, typename IndexType_> +struct eval<TensorFixedSize<Scalar_, Dimensions, Options, IndexType_>, Eigen::Dense> { - typedef const TensorFixedSize<Scalar_, Dimensions, Options>& type; + typedef const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_>& type; }; -template<typename Scalar_, typename Dimensions, int Options> -struct eval<const TensorFixedSize<Scalar_, Dimensions, Options>, Eigen::Dense> +template<typename Scalar_, typename Dimensions, int Options, typename IndexType_> +struct eval<const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_>, Eigen::Dense> { - typedef const TensorFixedSize<Scalar_, Dimensions, Options>& type; + typedef const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_>& type; }; template<typename PlainObjectType, int Options> @@ -167,28 +156,28 @@ struct eval<const TensorRef<PlainObjectType>, Eigen::Dense> }; -template <typename Scalar_, std::size_t NumIndices_, int Options_> -struct nested<Tensor<Scalar_, NumIndices_, Options_> > +template <typename Scalar_, std::size_t NumIndices_, int Options_, typename IndexType_> +struct nested<Tensor<Scalar_, NumIndices_, Options_, IndexType_> > { - typedef const Tensor<Scalar_, NumIndices_, Options_>& type; + typedef const Tensor<Scalar_, NumIndices_, Options_, IndexType_>& type; }; -template <typename Scalar_, std::size_t NumIndices_, int Options_> -struct nested<const Tensor<Scalar_, NumIndices_, Options_> > +template <typename Scalar_, std::size_t NumIndices_, int Options_, typename IndexType_> +struct nested<const Tensor<Scalar_, NumIndices_, Options_, IndexType_> > { - typedef const Tensor<Scalar_, NumIndices_, Options_>& type; + typedef const Tensor<Scalar_, NumIndices_, Options_, IndexType_>& type; }; -template <typename Scalar_, typename Dimensions, int Options> -struct nested<TensorFixedSize<Scalar_, Dimensions, Options> > +template <typename Scalar_, typename Dimensions, int Options, typename IndexType_> +struct nested<TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> > { - typedef const TensorFixedSize<Scalar_, Dimensions, Options>& type; + typedef const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_>& type; }; -template <typename Scalar_, typename Dimensions, int Options> -struct nested<const TensorFixedSize<Scalar_, Dimensions, Options> > +template <typename Scalar_, typename Dimensions, int Options, typename IndexType_> +struct nested<const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_> > { - typedef const TensorFixedSize<Scalar_, Dimensions, Options>& type; + typedef const TensorFixedSize<Scalar_, Dimensions, Options, IndexType_>& type; }; |