5

我想同时使用 RcppGSL 和 RcppArmadillo,是否可以在 cxxfunction(内联 CRAN 包的)中使用多个插件?我找到了一种方法:

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")

但它似乎不是那么直观。

4

2 回答 2

4

一种简单的方法是从现有插件开始,例如:

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

然后与 foo 混淆,并将其用作 cxxfunction 调用中的设置参数。更多关于 ?cxxfunction 的内容。

于 2012-01-24T15:27:54.823 回答
3

好问题。(而且在 rcpp-devel 上会更好。)

我认为您需要编写自己的组合插件,有关详细信息,请参阅 Rcpp-FAQ 小插图的问题 3.6“我如何为内联包编写插件”。

于 2012-01-23T21:18:39.720 回答