[Rcpp-devel] Conversion of Rcpp::Vector Rcpp::List and Rcpp::Matrix to std objects - OpenMP

Dirk Eddelbuettel edd at debian.org
Fri May 31 19:37:30 CEST 2013


On 31 May 2013 at 18:00, Asis Hallab wrote:
| Dear Rcpp Experts,
| 
| in my current project I wanted to make use of OpenMP.

That works.

| Unfortunately it seems Rcpp Objects cannot be used inside a block
| executed in parallel.

I think if you're careful it may work.  You definitely do not want to call
back or invoke R from multiple threads.  But using Rcpp::NumericVector et al
as "containers" may work.  

| Seg fault errors are the consequence, according to Dirk's reply in this thread
| http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2012-February/003398.html
| 
| Hence the need to convert
| Rcpp::Vector to std::vector,
| Rcpp::Matrix to std::vector< std::vector >, and
| Rcpp::List to std::map< std::string, … >
| 
| If I am not mistaken there's only support for the first conversion,
| using the "as<> wrapper";
| is this correct?
| What would be the most efficient way of converting
| Rcpp::Matrix and Rcpp::List to the above types?
| And how to efficiently convert them back into Rcpp-Objects?

See above.  Not clear that you "must" convert.  And you could use Armadillo
types as well. That gives you matrix types. 

As for Rcpp::List conversions it depends on what the actual list elements
are. You can always write yourself custom converter functions to get started.

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list