Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple plugins in cxxfunction

Tags:

r

rcpp

I want to use RcppGSL and RcppArmadillo at the same time, is that possible to use multiple plugins in cxxfunction (of the inline CRAN package) ? I found a way to do:

plug.ArmaGSL <- Rcpp:::Rcpp.plugin.maker(include.before='#include <RcppArmadillo.h>
                                                     #include <RcppGSL.h>
                                                     #include <gsl/gsl_rng.h>',
                                     Depends=c("RcppGSL", "RcppArmadillo", "Rcpp"),
                                     LinkingTo=c("RcppGSL", "RcppArmadillo", "Rcpp"),
                                     libs="-lgsl -larmadillo")

registerPlugin("RcppArmaGSL", plug.ArmaGSL)

foo <- cxxfunction(signature(sM="numeric"), body=bodytxt, inc=inctxt, plugin="RcppArmaGSL")

but it seems not that intuitive.

like image 562
Gong-Yi Liao Avatar asked Jan 23 '12 21:01

Gong-Yi Liao


1 Answers

A simple way is to start from an existing plugin, say:

require(inline)
require(RcppArmadillo)
foo <- getPlugin("RcppArmadillo" )

and then mess with foo, and use it as the settings argument in the cxxfunction call. More on that in ?cxxfunction.

like image 111
Romain Francois Avatar answered Sep 28 '22 08:09

Romain Francois