nullary_indexing.cpp File Reference
#include <Eigen/Core>
#include <iostream>

Classes

class  indexing_functor< ArgType, RowIndexType, ColIndexType >
 

Functions

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)
 
int main ()
 

Function Documentation

◆ main()

int main ( )
37  {
38  std::cout << "[main1]\n";
39  Eigen::MatrixXi A = Eigen::MatrixXi::Random(4, 4);
40  Eigen::Array3i ri(1, 2, 1);
41  Eigen::ArrayXi ci(6);
42  ci << 3, 2, 1, 0, 0, 2;
43  Eigen::MatrixXi B = mat_indexing(A, ri, ci);
44  std::cout << "A =" << std::endl;
45  std::cout << A << std::endl << std::endl;
46  std::cout << "A([" << ri.transpose() << "], [" << ci.transpose() << "]) =" << std::endl;
47  std::cout << B << std::endl;
48  std::cout << "[main1]\n";
49 
50  std::cout << "[main2]\n";
51  B = mat_indexing(A, ri + 1, ci);
52  std::cout << "A(ri+1,ci) =" << std::endl;
53  std::cout << B << std::endl << std::endl;
54  B = mat_indexing(A, Eigen::ArrayXi::LinSpaced(13, 0, 12).unaryExpr([](int x) { return x % 4; }),
55  Eigen::ArrayXi::LinSpaced(4, 0, 3));
56  std::cout << "A(ArrayXi::LinSpaced(13,0,12).unaryExpr([](int x){return x%4;}), ArrayXi::LinSpaced(4,0,3)) ="
57  << std::endl;
58  std::cout << B << std::endl << std::endl;
59  std::cout << "[main2]\n";
60 }
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:47
Definition: matrices.h:74
list x
Definition: plotDoE.py:28
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: nullary_indexing.cpp:30

References mat_indexing(), and plotDoE::x.

◆ 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 
)
30  {
32  typedef typename Func::MatrixType MatrixType;
33  return MatrixType::NullaryExpr(row_indices.size(), col_indices.size(), Func(arg.derived(), row_indices, col_indices));
34 }
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
Definition: nullary_indexing.cpp:6

Referenced by main().