rrcpprcppparallel

How to select a row or column of RMatrix in RcppParallel


I need to work with RcppParallel::RMatrix. Previously I worked with Rcpp only. But now for RcppParallel I need a documention Like What Rcpp has.

For Example

I Rcpp::NumericMatrix We can select a row or column with placeholder "_" like this:

NumericMatrix new = OldMatrix(_,1);

But I want to know How Can Do same for RcppParallel::RMatrix?

Thank for any help.


Solution

  • RcppParallel is focused on iterators, and it offers the RMatrix::Column and RMatrix::Row classes that provide iterators for individual columns and rows:

    Rcpp::NumericMatrix foo = ...;
    RcppParallel::RMatrix<double> bar(foo);
    
    RcppParallel::RMatrix<double>::Column column = bar.column(0);
    // use any algorithm on column.begin() to column.end()
    
    RcppParallel::RMatrix<double>::Row row = bar.row(0);
    // use any algorithm on row.begin() to row.end()