How to select a row or column of RMatrix in RcppParallel

492 Views Asked by At

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.

1

There are 1 best solutions below

0
On BEST ANSWER

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