nullary_indexing.cpp File Reference

Go to the source code of this file.

Functions

int main ()
 
template<class ArgType , class RowIndexType , class ColIndexType >
Eigen::CwiseNullaryOp< indexing_functor< ArgType, RowIndexType, ColIndexType >, typename indexing_functor< ArgType, RowIndexType, ColIndexType >::MatrixTypemat_indexing (const Eigen::MatrixBase< ArgType > &arg, const RowIndexType &row_indices, const ColIndexType &col_indices)
 

Function Documentation

◆ main()

int main ( )

Definition at line 40 of file nullary_indexing.cpp.

41 {
42  std::cout << "[main1]\n";
44  Eigen::Array3i ri(1,2,1);
45  Eigen::ArrayXi ci(6); ci << 3,2,1,0,0,2;
46  Eigen::MatrixXi B = mat_indexing(A, ri, ci);
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";
52 
53  std::cout << "[main2]\n";
54  B = mat_indexing(A, ri+1, ci);
55  std::cout << "A(ri+1,ci) =" << std::endl;
56  std::cout << B << std::endl << std::endl;
57  B = mat_indexing(A, Eigen::ArrayXi::LinSpaced(13,0,12).unaryExpr([](int x){return x%4;}), Eigen::ArrayXi::LinSpaced(4,0,3));
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";
61 }
const CwiseUnaryOp< CustomUnaryOp, const Derived > unaryExpr(const CustomUnaryOp &func=CustomUnaryOp()) const
Apply a unary operator coefficient-wise.
MatrixXcf A
MatrixXf B
General-purpose arrays with easy API for coefficient-wise operations.
Definition: Array.h:49
static EIGEN_DEPRECATED const RandomAccessLinSpacedReturnType LinSpaced(Sequential_t, Index size, const Scalar &low, const Scalar &high)
static const RandomReturnType Random()
Definition: Random.h:114
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:182
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)

◆ mat_indexing()

template<class ArgType , class RowIndexType , class ColIndexType >
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 
)

Definition at line 31 of file nullary_indexing.cpp.

32 {
33  typedef indexing_functor<ArgType,RowIndexType,ColIndexType> Func;
34  typedef typename Func::MatrixType MatrixType;
35  return MatrixType::NullaryExpr(row_indices.size(), col_indices.size(), Func(arg.derived(), row_indices, col_indices));
36 }
const ArgReturnType arg() const
Matrix< float, 1, Dynamic > MatrixType