IndexedViewMethods.h File Reference

Go to the source code of this file.

Functions

template<typename Indices >
IndexedView_or_VectorBlock operator() (const Indices &indices)
 
template<typename RowIndices , typename ColIndices >
IndexedView_or_Block operator() (const RowIndices &rowIndices, const ColIndices &colIndices)
 

Function Documentation

◆ operator()() [1/2]

template<typename Indices >
IndexedView_or_VectorBlock operator() ( const Indices &  indices)

This is an overload of operator()(const RowIndices&, const ColIndices&) for 1D vectors or arrays

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

◆ operator()() [2/2]

template<typename RowIndices , typename ColIndices >
IndexedView_or_Block operator() ( const RowIndices &  rowIndices,
const ColIndices &  colIndices 
)
Returns
a generic submatrix view defined by the rows and columns indexed rowIndices and 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: int[N]
  • And more generally any type exposing the following two member functions:
    <integral type> operator[](<integral type>) const;
    <integral type> size() const;
    where <integral type> stands for any integer type compatible with Eigen::Index (i.e. std::ptrdiff_t).

The last statement implies compatibility with std::vector, std::valarray, std::array, many of the Range-v3's ranges, etc.

If the submatrix can be represented using a starting position (i,j) and positive sizes (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<Derived,RowIndices',ColIndices'> object will be returned, after conversion of the inputs to more suitable types RowIndices' and 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.

See also
operator()(const Indices&), class Block, class IndexedView, DenseBase::block(Index,Index,Index,Index)