// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2017 Gael Guennebaud // // 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/. #if !defined(EIGEN_PARSED_BY_DOXYGEN) public: // SFINAE dummy types template using EnableOverload = std::enable_if_t< internal::valid_indexed_view_overload::value && internal::is_lvalue::value, bool>; template using EnableConstOverload = std::enable_if_t::value, bool>; template using EnableVectorOverload = std::enable_if_t::value && internal::is_lvalue::value, bool>; template using EnableConstVectorOverload = std::enable_if_t::value, bool>; public: // Public API for 2D matrices/arrays // non-const versions template using IndexedViewType = typename internal::IndexedViewSelector::ReturnType; template = true> IndexedViewType operator()(const RowIndices& rowIndices, const ColIndices& colIndices) { return internal::IndexedViewSelector::run(derived(), rowIndices, colIndices); } template , EnableOverload = true> IndexedViewType operator()(const RowType (&rowIndices)[RowSize], const ColIndices& colIndices) { return internal::IndexedViewSelector::run(derived(), RowIndices{rowIndices}, colIndices); } template , EnableOverload = true> IndexedViewType operator()(const RowIndices& rowIndices, const ColType (&colIndices)[ColSize]) { return internal::IndexedViewSelector::run(derived(), rowIndices, ColIndices{colIndices}); } template , typename ColIndices = Array, EnableOverload = true> IndexedViewType operator()(const RowType (&rowIndices)[RowSize], const ColType (&colIndices)[ColSize]) { return internal::IndexedViewSelector::run(derived(), RowIndices{rowIndices}, ColIndices{colIndices}); } // const versions template using ConstIndexedViewType = typename internal::IndexedViewSelector::ConstReturnType; template = true> ConstIndexedViewType operator()(const RowIndices& rowIndices, const ColIndices& colIndices) const { return internal::IndexedViewSelector::run(derived(), rowIndices, colIndices); } template , EnableConstOverload = true> ConstIndexedViewType operator()(const RowType (&rowIndices)[RowSize], const ColIndices& colIndices) const { return internal::IndexedViewSelector::run(derived(), RowIndices{rowIndices}, colIndices); } template , EnableConstOverload = true> ConstIndexedViewType operator()(const RowIndices& rowIndices, const ColType (&colIndices)[ColSize]) const { return internal::IndexedViewSelector::run(derived(), rowIndices, ColIndices{colIndices}); } template , typename ColIndices = Array, EnableConstOverload = true> ConstIndexedViewType operator()(const RowType (&rowIndices)[RowSize], const ColType (&colIndices)[ColSize]) const { return internal::IndexedViewSelector::run(derived(), RowIndices{rowIndices}, ColIndices{colIndices}); } // Public API for 1D vectors/arrays // non-const versions template using VectorIndexedViewType = typename internal::VectorIndexedViewSelector::ReturnType; template = true> VectorIndexedViewType operator()(const Indices& indices) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) return internal::VectorIndexedViewSelector::run(derived(), indices); } template , EnableVectorOverload = true> VectorIndexedViewType operator()(const IndexType (&indices)[Size]) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) return internal::VectorIndexedViewSelector::run(derived(), Indices{indices}); } // const versions template using ConstVectorIndexedViewType = typename internal::VectorIndexedViewSelector::ConstReturnType; template = true> ConstVectorIndexedViewType operator()(const Indices& indices) const { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) return internal::VectorIndexedViewSelector::run(derived(), indices); } template , EnableConstVectorOverload = true> ConstVectorIndexedViewType operator()(const IndexType (&indices)[Size]) const { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) return internal::VectorIndexedViewSelector::run(derived(), Indices{indices}); } #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::placeholders::all indexing the full set of respective rows or columns in increasing order * - An ArithmeticSequence as returned by the Eigen::seq and Eigen::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 * operator[]() const; * size() const; * \endcode * where \c 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::placeholders::all * - An ArithmeticSequence with compile-time increment strictly equal to 1, as returned by Eigen::seq(a,b), and * Eigen::seqN(a,N). * * Otherwise a more general IndexedView object will be returned, after conversion of * the inputs to more suitable types \c RowIndices' and \c ColIndices'. * * For 1D vectors and arrays, you better use the operator()(const Indices&) overload, which behave the same way but * taking a single parameter. * * See also this question * and its answer for an example of how to duplicate coefficients. * * \sa operator()(const Indices&), class Block, class IndexedView, DenseBase::block(Index,Index,Index,Index) */ template IndexedView_or_Block operator()(const RowIndices& rowIndices, const ColIndices& colIndices); /** This is an overload of operator()(const RowIndices&, const ColIndices&) for 1D vectors or arrays * * \only_for_vectors */ template IndexedView_or_VectorBlock operator()(const Indices& indices); #endif // EIGEN_PARSED_BY_DOXYGEN