From 87963f441c9abd8514b94b6b2c712652d646ed64 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Tue, 10 Jan 2017 14:25:30 +0100 Subject: 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. --- Eigen/src/Core/DenseBase.h | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'Eigen/src/Core/DenseBase.h') 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 @@ -557,15 +557,36 @@ template class DenseBase } EIGEN_DEVICE_FUNC void reverseInPlace(); + template + struct IndexedViewType { + typedef IndexedView::type,typename internal::MakeIndexing::type> type; + }; + template typename internal::enable_if< - !(internal::is_integral::value && internal::is_integral::value), - IndexedView::type,typename internal::MakeIndexing::type> >::type + ! (internal::traits::type>::IsBlockAlike + || (internal::is_integral::value && internal::is_integral::value)), + typename IndexedViewType::type >::type operator()(const RowIndices& rowIndices, const ColIndices& colIndices) const { - return IndexedView::type,typename internal::MakeIndexing::type>( + return typename IndexedViewType::type( derived(), internal::make_indexing(rowIndices,derived().rows()), internal::make_indexing(colIndices,derived().cols())); } + template + typename internal::enable_if< + internal::traits::type>::IsBlockAlike, + typename internal::traits::type>::BlockType>::type + operator()(const RowIndices& rowIndices, const ColIndices& colIndices) const { + typedef typename internal::traits::type>::BlockType BlockType; + typename internal::MakeIndexing::type actualRowIndices = internal::make_indexing(rowIndices,derived().rows()); + typename internal::MakeIndexing::type actualColIndices = internal::make_indexing(colIndices,derived().cols()); + return BlockType(derived(), + internal::first(actualRowIndices), + internal::first(actualColIndices), + internal::size(actualRowIndices), + internal::size(actualColIndices)); + } + template IndexedView::type> operator()(const RowIndicesT (&rowIndices)[RowIndicesN], const ColIndices& colIndices) const { -- cgit v1.2.3