Multiple plugins in cxxfunction

牧云@^-^@ 提交于 2019-12-12 09:40:51

问题


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.


回答1:


Nice question. (And would have been even better on rcpp-devel.)

I think you need to write your own combined plugin, see Question 3.6 'How do I write a plugin for the inline package' of the Rcpp-FAQ vignette for details.




回答2:


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.



来源:https://stackoverflow.com/questions/8978636/multiple-plugins-in-cxxfunction

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!