mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
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
This commit is contained in:
@@ -82,15 +82,15 @@ namespace internal{
|
||||
|
||||
template<typename IndexType, Index... Is>
|
||||
EIGEN_CONSTEXPR EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||
array<Index,sizeof...(Is)> customIndices2Array(const IndexType & idx, numeric_list<Index,Is...>) {
|
||||
return { idx(Is)... };
|
||||
array<Index, sizeof...(Is)> customIndices2Array(IndexType& idx, numeric_list<Index, Is...>) {
|
||||
return { idx[Is]... };
|
||||
}
|
||||
|
||||
/** Make an array (for index/dimensions) out of a custom index */
|
||||
template<typename Index, int NumIndices, typename IndexType>
|
||||
EIGEN_CONSTEXPR EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||
array<Index,NumIndices> customIndices2Array(const IndexType & idx) {
|
||||
return customIndices2Array(idx, typename gen_numeric_list<Index,NumIndices>::type{});
|
||||
array<Index, NumIndices> customIndices2Array(IndexType& idx) {
|
||||
return customIndices2Array(idx, typename gen_numeric_list<Index, NumIndices>::type{});
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user