5 template<
class ArgType,
class RowIndexType,
class ColIndexType>
6 class indexing_functor {
8 const RowIndexType &m_rowIndices;
9 const ColIndexType &m_colIndices;
12 RowIndexType::SizeAtCompileTime,
13 ColIndexType::SizeAtCompileTime,
15 RowIndexType::MaxSizeAtCompileTime,
16 ColIndexType::MaxSizeAtCompileTime>
MatrixType;
18 indexing_functor(
const ArgType&
arg,
const RowIndexType& row_indices,
const ColIndexType& col_indices)
19 : m_arg(
arg), m_rowIndices(row_indices), m_colIndices(col_indices)
23 return m_arg(m_rowIndices[
row], m_colIndices[
col]);
29 template <
class ArgType,
class RowIndexType,
class ColIndexType>
33 typedef indexing_functor<ArgType,RowIndexType,ColIndexType> Func;
35 return MatrixType::NullaryExpr(row_indices.size(), col_indices.size(), Func(
arg.derived(), row_indices, col_indices));
42 std::cout <<
"[main1]\n";
47 std::cout <<
"A =" << std::endl;
48 std::cout <<
A << std::endl << std::endl;
49 std::cout <<
"A([" << ri.
transpose() <<
"], [" << ci.
transpose() <<
"]) =" << std::endl;
50 std::cout <<
B << std::endl;
51 std::cout <<
"[main1]\n";
53 std::cout <<
"[main2]\n";
55 std::cout <<
"A(ri+1,ci) =" << std::endl;
56 std::cout <<
B << std::endl << std::endl;
58 std::cout <<
"A(ArrayXi::LinSpaced(13,0,12).unaryExpr([](int x){return x%4;}), ArrayXi::LinSpaced(4,0,3)) =" << std::endl;
59 std::cout <<
B << std::endl << std::endl;
60 std::cout <<
"[main2]\n";
const ArgReturnType arg() const
RowXpr row(Index i)
This is the const version of row(). */.
ColXpr col(Index i)
This is the const version of col().
const CwiseUnaryOp< CustomUnaryOp, const Derived > unaryExpr(const CustomUnaryOp &func=CustomUnaryOp()) const
Apply a unary operator coefficient-wise.
IndexedView_or_Block operator()(const RowIndices &rowIndices, const ColIndices &colIndices)
Matrix< float, 1, Dynamic > MatrixType
General-purpose arrays with easy API for coefficient-wise operations.
Generic expression of a matrix where all coefficients are defined by a functor.
static EIGEN_DEPRECATED const RandomAccessLinSpacedReturnType LinSpaced(Sequential_t, Index size, const Scalar &low, const Scalar &high)
TransposeReturnType transpose()
static const RandomReturnType Random()
Base class for all dense matrices, vectors, and expressions.
The matrix class, also used for vectors and row-vectors.
const unsigned int RowMajorBit
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Eigen::CwiseNullaryOp< indexing_functor< ArgType, RowIndexType, ColIndexType >, typename indexing_functor< ArgType, RowIndexType, ColIndexType >::MatrixType > mat_indexing(const Eigen::MatrixBase< ArgType > &arg, const RowIndexType &row_indices, const ColIndexType &col_indices)