// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2017 Gael Guennebaud <[email protected]> // // This Source Code Form is subject to the terms of the Mozilla // 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_INDEXED_VIEW_H #define EIGEN_INDEXED_VIEW_H // IWYU pragma: private #include "./InternalHeaderCheck.h" namespace Eigen { namespace internal { traits<IndexedView<XprType, RowIndices, ColIndices>>; template <typename XprType, typename RowIndices, typename ColIndices, typename StorageKind, bool DirectAccess> class IndexedViewImpl; } // namespace internal /** \class IndexedView * \ingroup Core_Module * * \brief Expression of a non-sequential sub-matrix defined by arbitrary sequences of row and column indices * * \tparam XprType the type of the expression in which we are taking the intersections of sub-rows and sub-columns * \tparam RowIndices the type of the object defining the sequence of row indices * \tparam ColIndices the type of the object defining the sequence of column indices * * This class represents an expression of a sub-matrix (or sub-vector) defined as the intersection * of sub-sets of rows and columns, that are themself defined by generic sequences of row indices \f$ * \{r_0,r_1,..r_{m-1}\} \f$ and column indices \f$ \{c_0,c_1,..c_{n-1} \}\f$. Let \f$ A \f$ be the nested matrix, then * the resulting matrix \f$ B \f$ has \c m rows and \c n columns, and its entries are given by: \f$ B(i,j) = A(r_i,c_j) * \f$. * * The \c RowIndices and \c ColIndices types must be compatible with the following API: * \code * <integral type> operator[](Index) const; * Index size() const; * \endcode * * Typical supported types thus include: * - std::vector<int> * - std::valarray<int> * - std::array<int> * - Eigen::ArrayXi * - decltype(ArrayXi::LinSpaced(...)) * - Any view/expressions of the previous types * - Eigen::ArithmeticSequence * - Eigen::internal::AllRange (helper for Eigen::placeholders::all) * - Eigen::internal::SingleRange (helper for single index) * - etc. * * In typical usages of %Eigen, this class should never be used directly. It is the return type of * DenseBase::operator()(const RowIndices&, const ColIndices&). * * \sa class Block */ template <typename XprType, typename RowIndices, typename ColIndices> class IndexedView : public internal::IndexedViewImpl<XprType, RowIndices, ColIndices, typename internal::traits<XprType>::StorageKind, (internal::traits<IndexedView<XprType, RowIndices, ColIndices>>::Flags & DirectAccessBit) != 0> { … }; namespace internal { // Generic API dispatcher template <typename XprType, typename RowIndices, typename ColIndices, typename StorageKind, bool DirectAccess> class IndexedViewImpl : public internal::generic_xpr_base<IndexedView<XprType, RowIndices, ColIndices>>::type { … }; IndexedViewImpl<XprType, RowIndices, ColIndices, StorageKind, true>; unary_evaluator<IndexedView<ArgType, RowIndices, ColIndices>, IndexBased>; } // end namespace internal } // end namespace Eigen #endif // EIGEN_INDEXED_VIEW_H