diff options
author | Gael Guennebaud <g.gael@free.fr> | 2017-01-10 22:58:58 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2017-01-10 22:58:58 +0100 |
commit | 1b5570988bd2d6f783874e2d4fd6b7be45c8ac3c (patch) | |
tree | 6fc5b18af801ea127f8373fdcd64de795bec84f9 /Eigen/src/plugins | |
parent | 17eac60446650dc31bde7156a4febe504ab347b7 (diff) |
Add doc to seq, seqN, ArithmeticSequence, operator(), etc.
Diffstat (limited to 'Eigen/src/plugins')
-rw-r--r-- | Eigen/src/plugins/IndexedViewMethods.h | 88 |
1 files changed, 70 insertions, 18 deletions
diff --git a/Eigen/src/plugins/IndexedViewMethods.h b/Eigen/src/plugins/IndexedViewMethods.h index 53eff093c..ea1aa6e2e 100644 --- a/Eigen/src/plugins/IndexedViewMethods.h +++ b/Eigen/src/plugins/IndexedViewMethods.h @@ -7,6 +7,7 @@ // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. +#ifndef EIGEN_PARSED_BY_DOXYGEN // This file is automatically included twice to generate const and non-const versions @@ -20,54 +21,67 @@ template<typename RowIndices, typename ColIndices> struct EIGEN_INDEXED_VIEW_METHOD_TYPE { - typedef IndexedView<EIGEN_INDEXED_VIEW_METHOD_CONST Derived,typename internal::MakeIndexing<RowIndices>::type,typename internal::MakeIndexing<ColIndices>::type> type; + typedef IndexedView<EIGEN_INDEXED_VIEW_METHOD_CONST Derived, + typename internal::MakeIndexing<RowIndices>::type, + typename internal::MakeIndexing<ColIndices>::type> type; }; +// This is the generic version + template<typename RowIndices, typename ColIndices> typename internal::enable_if< ! (internal::traits<typename EIGEN_INDEXED_VIEW_METHOD_TYPE<RowIndices,ColIndices>::type>::IsBlockAlike || (internal::is_integral<RowIndices>::value && internal::is_integral<ColIndices>::value)), typename EIGEN_INDEXED_VIEW_METHOD_TYPE<RowIndices,ColIndices>::type >::type -operator()(const RowIndices& rowIndices, const ColIndices& colIndices) EIGEN_INDEXED_VIEW_METHOD_CONST { - return typename EIGEN_INDEXED_VIEW_METHOD_TYPE<RowIndices,ColIndices>::type( - derived(), internal::make_indexing(rowIndices,derived().rows()), internal::make_indexing(colIndices,derived().cols())); +operator()(const RowIndices& rowIndices, const ColIndices& colIndices) EIGEN_INDEXED_VIEW_METHOD_CONST +{ + return typename EIGEN_INDEXED_VIEW_METHOD_TYPE<RowIndices,ColIndices>::type + (derived(), internal::make_indexing(rowIndices,derived().rows()), internal::make_indexing(colIndices,derived().cols())); } +// The folowing overload returns a Block<> object + template<typename RowIndices, typename ColIndices> typename internal::enable_if< internal::traits<typename EIGEN_INDEXED_VIEW_METHOD_TYPE<RowIndices,ColIndices>::type>::IsBlockAlike && !(internal::is_integral<RowIndices>::value && internal::is_integral<ColIndices>::value), typename internal::traits<typename EIGEN_INDEXED_VIEW_METHOD_TYPE<RowIndices,ColIndices>::type>::BlockType>::type -operator()(const RowIndices& rowIndices, const ColIndices& colIndices) EIGEN_INDEXED_VIEW_METHOD_CONST { +operator()(const RowIndices& rowIndices, const ColIndices& colIndices) EIGEN_INDEXED_VIEW_METHOD_CONST +{ typedef typename internal::traits<typename EIGEN_INDEXED_VIEW_METHOD_TYPE<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)); + internal::first(actualRowIndices), + internal::first(actualColIndices), + internal::size(actualRowIndices), + internal::size(actualColIndices)); } +// The folowing three overloads are needed to handle raw Index[N] arrays. + template<typename RowIndicesT, std::size_t RowIndicesN, typename ColIndices> IndexedView<EIGEN_INDEXED_VIEW_METHOD_CONST Derived,const RowIndicesT (&)[RowIndicesN],typename internal::MakeIndexing<ColIndices>::type> -operator()(const RowIndicesT (&rowIndices)[RowIndicesN], const ColIndices& colIndices) EIGEN_INDEXED_VIEW_METHOD_CONST { - return IndexedView<EIGEN_INDEXED_VIEW_METHOD_CONST Derived,const RowIndicesT (&)[RowIndicesN],typename internal::MakeIndexing<ColIndices>::type>( - derived(), rowIndices, internal::make_indexing(colIndices,derived().cols())); +operator()(const RowIndicesT (&rowIndices)[RowIndicesN], const ColIndices& colIndices) EIGEN_INDEXED_VIEW_METHOD_CONST +{ + return IndexedView<EIGEN_INDEXED_VIEW_METHOD_CONST 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<EIGEN_INDEXED_VIEW_METHOD_CONST Derived,typename internal::MakeIndexing<RowIndices>::type, const ColIndicesT (&)[ColIndicesN]> -operator()(const RowIndices& rowIndices, const ColIndicesT (&colIndices)[ColIndicesN]) EIGEN_INDEXED_VIEW_METHOD_CONST { - return IndexedView<EIGEN_INDEXED_VIEW_METHOD_CONST Derived,typename internal::MakeIndexing<RowIndices>::type,const ColIndicesT (&)[ColIndicesN]>( - derived(), internal::make_indexing(rowIndices,derived().rows()), colIndices); +operator()(const RowIndices& rowIndices, const ColIndicesT (&colIndices)[ColIndicesN]) EIGEN_INDEXED_VIEW_METHOD_CONST +{ + return IndexedView<EIGEN_INDEXED_VIEW_METHOD_CONST 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<EIGEN_INDEXED_VIEW_METHOD_CONST Derived,const RowIndicesT (&)[RowIndicesN], const ColIndicesT (&)[ColIndicesN]> -operator()(const RowIndicesT (&rowIndices)[RowIndicesN], const ColIndicesT (&colIndices)[ColIndicesN]) EIGEN_INDEXED_VIEW_METHOD_CONST { - return IndexedView<EIGEN_INDEXED_VIEW_METHOD_CONST Derived,const RowIndicesT (&)[RowIndicesN],const ColIndicesT (&)[ColIndicesN]>( - derived(), rowIndices, colIndices); +operator()(const RowIndicesT (&rowIndices)[RowIndicesN], const ColIndicesT (&colIndices)[ColIndicesN]) EIGEN_INDEXED_VIEW_METHOD_CONST +{ + return IndexedView<EIGEN_INDEXED_VIEW_METHOD_CONST Derived,const RowIndicesT (&)[RowIndicesN],const ColIndicesT (&)[ColIndicesN]> + (derived(), rowIndices, colIndices); } #undef EIGEN_INDEXED_VIEW_METHOD_CONST @@ -79,3 +93,41 @@ operator()(const RowIndicesT (&rowIndices)[RowIndicesN], const ColIndicesT (&col #undef EIGEN_INDEXED_VIEW_METHOD_2ND_PASS #endif +#else // EIGEN_PARSED_BY_DOXYGEN + +/** + * \returns a generic submatrix view defined by the rows and columns indexed \a rowIndices and \a colIndices respectively. + * + * Each parameter must either be: + * - An integer indexing a single row or column + * - Eigen::all indexing the full set of respective rows or columns in increasing order + * - An ArithemeticSequence as returned by the seq and seqN functions + * - Any %Eigen's vector/array of integers or expressions + * - Plain C arrays: \c int[N] + * - And more generally any type exposing the following two member functions: + * \code + * <integral type> operator[](<integral type>) const; + * <integral type> size() const; + * \endcode + * where \c <integral \c type> stands for any integer type compatible with Eigen::Index (i.e. \c std::ptrdiff_t). + * + * The last statement implies compatibility with \c std::vector, \c std::valarray, \c std::array, many of the Range-v3's ranges, etc. + * + * If the submatrix can be represented using a starting position \c (i,j) and positive sizes \c (rows,columns), then this + * method will returns a Block object after extraction of the relevant information from the passed arguments. This is the case + * when all arguments are either: + * - An integer + * - Eigen::all + * - An ArithemeticSequence with compile-time increment strictly equal to 1, as returned by seq(a,b), and seqN(a,N). + * + * Otherwise a more general IndexedView<Derived,RowIndices',ColIndices'> object will be returned, after conversion of the inputs + * to more suitable types \c RowIndices' and \c ColIndices'. + * + * \sa class Block, class IndexedView, DenseBase::block(Index,Index,Index,Index) + */ +template<typename RowIndices, typename ColIndices> +IndexedView_or_Block +operator()(const RowIndices& rowIndices, const ColIndices& colIndices); + +#endif // EIGEN_PARSED_BY_DOXYGEN + |