From d072fc4b1432b193d24e44d70885b636d4132405 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Tue, 10 Jan 2017 17:10:35 +0100 Subject: add writeable IndexedView --- Eigen/src/Core/DenseBase.h | 66 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 7 deletions(-) (limited to 'Eigen/src/Core/DenseBase.h') diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h index 779cb4549..909fa0f12 100644 --- a/Eigen/src/Core/DenseBase.h +++ b/Eigen/src/Core/DenseBase.h @@ -558,27 +558,27 @@ template class DenseBase EIGEN_DEVICE_FUNC void reverseInPlace(); template - struct IndexedViewType { + struct ConstIndexedViewType { typedef IndexedView::type,typename internal::MakeIndexing::type> type; }; template typename internal::enable_if< - ! (internal::traits::type>::IsBlockAlike + ! (internal::traits::type>::IsBlockAlike || (internal::is_integral::value && internal::is_integral::value)), - typename IndexedViewType::type >::type + typename ConstIndexedViewType::type >::type operator()(const RowIndices& rowIndices, const ColIndices& colIndices) const { - return typename IndexedViewType::type( + return typename ConstIndexedViewType::type( derived(), internal::make_indexing(rowIndices,derived().rows()), internal::make_indexing(colIndices,derived().cols())); } template typename internal::enable_if< - internal::traits::type>::IsBlockAlike + internal::traits::type>::IsBlockAlike && !(internal::is_integral::value && internal::is_integral::value), - typename internal::traits::type>::BlockType>::type + typename internal::traits::type>::BlockType>::type operator()(const RowIndices& rowIndices, const ColIndices& colIndices) const { - typedef typename internal::traits::type>::BlockType BlockType; + 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(), @@ -609,6 +609,58 @@ template class DenseBase derived(), rowIndices, colIndices); } + template + struct IndexedViewType { + typedef IndexedView::type,typename internal::MakeIndexing::type> type; + }; + + template + typename internal::enable_if< + ! (internal::traits::type>::IsBlockAlike + || (internal::is_integral::value && internal::is_integral::value)), + typename IndexedViewType::type >::type + operator()(const RowIndices& rowIndices, const ColIndices& colIndices) { + 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 + && !(internal::is_integral::value && internal::is_integral::value), + typename internal::traits::type>::BlockType>::type + operator()(const RowIndices& rowIndices, const ColIndices& colIndices) { + 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) { + return IndexedView::type>( + derived(), rowIndices, internal::make_indexing(colIndices,derived().cols())); + } + + template + IndexedView::type, const ColIndicesT (&)[ColIndicesN]> + operator()(const RowIndices& rowIndices, const ColIndicesT (&colIndices)[ColIndicesN]) { + return IndexedView::type,const ColIndicesT (&)[ColIndicesN]>( + derived(), internal::make_indexing(rowIndices,derived().rows()), colIndices); + } + + template + IndexedView + operator()(const RowIndicesT (&rowIndices)[RowIndicesN], const ColIndicesT (&colIndices)[ColIndicesN]) { + return IndexedView( + derived(), rowIndices, colIndices); + } + #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::DenseBase #define EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL #define EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(COND) -- cgit v1.2.3