aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/DenseBase.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2017-01-10 14:25:30 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2017-01-10 14:25:30 +0100
commit87963f441c9abd8514b94b6b2c712652d646ed64 (patch)
tree9988b56b0a9d0692b76072d9298ddb488be2e660 /Eigen/src/Core/DenseBase.h
parenta98c7efb163a1183d61ae56cacc7d903057285f0 (diff)
Fallback to Block<> when possible (Index, all, seq with > increment).
This is important to take advantage of the optimized implementations (evaluator, products, etc.), and to support sparse matrices.
Diffstat (limited to 'Eigen/src/Core/DenseBase.h')
-rw-r--r--Eigen/src/Core/DenseBase.h27
1 files changed, 24 insertions, 3 deletions
diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h
index 07057ce69..7c01e9328 100644
--- a/Eigen/src/Core/DenseBase.h
+++ b/Eigen/src/Core/DenseBase.h
@@ -558,14 +558,35 @@ template<typename Derived> class DenseBase
EIGEN_DEVICE_FUNC void reverseInPlace();
template<typename RowIndices, typename ColIndices>
+ struct IndexedViewType {
+ typedef IndexedView<const Derived,typename internal::MakeIndexing<RowIndices>::type,typename internal::MakeIndexing<ColIndices>::type> type;
+ };
+
+ template<typename RowIndices, typename ColIndices>
typename internal::enable_if<
- !(internal::is_integral<RowIndices>::value && internal::is_integral<ColIndices>::value),
- IndexedView<const Derived,typename internal::MakeIndexing<RowIndices>::type,typename internal::MakeIndexing<ColIndices>::type> >::type
+ ! (internal::traits<typename IndexedViewType<RowIndices,ColIndices>::type>::IsBlockAlike
+ || (internal::is_integral<RowIndices>::value && internal::is_integral<ColIndices>::value)),
+ typename IndexedViewType<RowIndices,ColIndices>::type >::type
operator()(const RowIndices& rowIndices, const ColIndices& colIndices) const {
- return IndexedView<const Derived,typename internal::MakeIndexing<RowIndices>::type,typename internal::MakeIndexing<ColIndices>::type>(
+ return typename IndexedViewType<RowIndices,ColIndices>::type(
derived(), internal::make_indexing(rowIndices,derived().rows()), internal::make_indexing(colIndices,derived().cols()));
}
+ template<typename RowIndices, typename ColIndices>
+ typename internal::enable_if<
+ internal::traits<typename IndexedViewType<RowIndices,ColIndices>::type>::IsBlockAlike,
+ typename internal::traits<typename IndexedViewType<RowIndices,ColIndices>::type>::BlockType>::type
+ operator()(const RowIndices& rowIndices, const ColIndices& colIndices) const {
+ typedef typename internal::traits<typename IndexedViewType<RowIndices,ColIndices>::type>::BlockType BlockType;
+ typename internal::MakeIndexing<RowIndices>::type actualRowIndices = internal::make_indexing(rowIndices,derived().rows());
+ typename internal::MakeIndexing<ColIndices>::type actualColIndices = internal::make_indexing(colIndices,derived().cols());
+ return BlockType(derived(),
+ internal::first(actualRowIndices),
+ internal::first(actualColIndices),
+ internal::size(actualRowIndices),
+ internal::size(actualColIndices));
+ }
+
template<typename RowIndicesT, std::size_t RowIndicesN, typename ColIndices>
IndexedView<const Derived,const RowIndicesT (&)[RowIndicesN],typename internal::MakeIndexing<ColIndices>::type>
operator()(const RowIndicesT (&rowIndices)[RowIndicesN], const ColIndices& colIndices) const {