Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 906
SirSaleh Avatar asked Sep 06 '17 22:09

SirSaleh


1 Answers

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()
like image 193
Ralf Stubner Avatar answered Nov 15 '22 05:11

Ralf Stubner