aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/DenseBase.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2017-01-10 17:10:35 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2017-01-10 17:10:35 +0100
commitd072fc4b1432b193d24e44d70885b636d4132405 (patch)
treeac0f49261b49b0631b3d1377cf47b128b98b5962 /Eigen/src/Core/DenseBase.h
parentc9d5e5c6dac14fac1a4bc16b6e1570479daeacb8 (diff)
add writeable IndexedView
Diffstat (limited to 'Eigen/src/Core/DenseBase.h')
-rw-r--r--Eigen/src/Core/DenseBase.h66
1 files changed, 59 insertions, 7 deletions
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<typename Derived> class DenseBase
EIGEN_DEVICE_FUNC void reverseInPlace();
template<typename RowIndices, typename ColIndices>
- struct IndexedViewType {
+ struct ConstIndexedViewType {
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::traits<typename IndexedViewType<RowIndices,ColIndices>::type>::IsBlockAlike
+ ! (internal::traits<typename ConstIndexedViewType<RowIndices,ColIndices>::type>::IsBlockAlike
|| (internal::is_integral<RowIndices>::value && internal::is_integral<ColIndices>::value)),
- typename IndexedViewType<RowIndices,ColIndices>::type >::type
+ typename ConstIndexedViewType<RowIndices,ColIndices>::type >::type
operator()(const RowIndices& rowIndices, const ColIndices& colIndices) const {
- return typename IndexedViewType<RowIndices,ColIndices>::type(
+ return typename ConstIndexedViewType<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
+ internal::traits<typename ConstIndexedViewType<RowIndices,ColIndices>::type>::IsBlockAlike
&& !(internal::is_integral<RowIndices>::value && internal::is_integral<ColIndices>::value),
- typename internal::traits<typename IndexedViewType<RowIndices,ColIndices>::type>::BlockType>::type
+ typename internal::traits<typename ConstIndexedViewType<RowIndices,ColIndices>::type>::BlockType>::type
operator()(const RowIndices& rowIndices, const ColIndices& colIndices) const {
- typedef typename internal::traits<typename IndexedViewType<RowIndices,ColIndices>::type>::BlockType BlockType;
+ typedef typename internal::traits<typename ConstIndexedViewType<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(),
@@ -609,6 +609,58 @@ template<typename Derived> class DenseBase
derived(), rowIndices, colIndices);
}
+ template<typename RowIndices, typename ColIndices>
+ struct IndexedViewType {
+ typedef IndexedView<Derived,typename internal::MakeIndexing<RowIndices>::type,typename internal::MakeIndexing<ColIndices>::type> type;
+ };
+
+ template<typename RowIndices, typename ColIndices>
+ typename internal::enable_if<
+ ! (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) {
+ 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
+ && !(internal::is_integral<RowIndices>::value && internal::is_integral<ColIndices>::value),
+ typename internal::traits<typename IndexedViewType<RowIndices,ColIndices>::type>::BlockType>::type
+ operator()(const RowIndices& rowIndices, const ColIndices& colIndices) {
+ 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<Derived,const RowIndicesT (&)[RowIndicesN],typename internal::MakeIndexing<ColIndices>::type>
+ operator()(const RowIndicesT (&rowIndices)[RowIndicesN], const ColIndices& colIndices) {
+ return IndexedView<Derived,const RowIndicesT (&)[RowIndicesN],typename internal::MakeIndexing<ColIndices>::type>(
+ derived(), rowIndices, internal::make_indexing(colIndices,derived().cols()));
+ }
+
+ template<typename RowIndices, typename ColIndicesT, std::size_t ColIndicesN>
+ IndexedView<Derived,typename internal::MakeIndexing<RowIndices>::type, const ColIndicesT (&)[ColIndicesN]>
+ operator()(const RowIndices& rowIndices, const ColIndicesT (&colIndices)[ColIndicesN]) {
+ return IndexedView<Derived,typename internal::MakeIndexing<RowIndices>::type,const ColIndicesT (&)[ColIndicesN]>(
+ derived(), internal::make_indexing(rowIndices,derived().rows()), colIndices);
+ }
+
+ template<typename RowIndicesT, std::size_t RowIndicesN, typename ColIndicesT, std::size_t ColIndicesN>
+ IndexedView<Derived,const RowIndicesT (&)[RowIndicesN], const ColIndicesT (&)[ColIndicesN]>
+ operator()(const RowIndicesT (&rowIndices)[RowIndicesN], const ColIndicesT (&colIndices)[ColIndicesN]) {
+ return IndexedView<Derived,const RowIndicesT (&)[RowIndicesN],const ColIndicesT (&)[ColIndicesN]>(
+ 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)