Quantcast
Channel: Convert std::vector to Rcpp matrix - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Convert std::vector to Rcpp matrix

$
0
0

This is an Rcpp conversion related Q. I'm looking to convert a long std::vector into a Rcpp matrix object, but want to know if there is an easy conversion format. Naturally, you could loop over each element and fill an empty Rcpp matrix, but this seems error prone and possibly needless if a more convenient approach is possible.

The reason I'm asking is I would like to utilize OpenMP in some existing C++ code, but storing element in the Rcpp matrix object directly in an OpenMP loop doesn't appear to work well (whereas loading a std::vector object and converting to a matrix after the OpenMP loop is complete seems to be a decent approach to the problem).

Any help would be greatly appreciated!


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles



Latest Images