Rcpp::InternalFunction和LOAD_RCPP_MODULE在使用RInside的上下文中有什么区别?他们似乎有相同的目的,只是LOAD_RCPP_MODULE有一个额外的层。它们的用例是什么?什么时候我应该选择一个而不是另一个?
//example with LOAD_RCPP_MODULE
const char* hello( std::string who ){
std::string result( "hello " ) ;
result += who ;
return result.c_str() ;
}
RCPP_MODULE(bling){
using namespace Rcpp ;
function( "hello", &hello );
}
R["bling"] = LOAD_RCPP_MODULE(bling);下面是另一个例子
//example with Rcpp::InternalFunction
const char* hello( std::string who ){
std::string result( "hello " ) ;
result += who ;
return result.c_str() ;
}
R["hello"] = Rcpp::InternalFunction( &hello )发布于 2013-09-12 09:33:24
模块将允许您公开几个函数和类。InternalFunction一次只公开一个函数。
InternalFunction是一种好奇,我们在某种程度上加入了它来回答“我们能不能做到”这类问题。这是在Rcpp中存在的原因之一,因为它们曾经存在过,但这并没有得到我们太多的关注。它主要用于RInside,允许R代码调用c++函数。这是一种奇怪的模式,因为对于RInside,焦点是嵌入R的C++应用程序。
然而,模块确实得到了很多关注。我的建议是利用它们。
发布于 2013-09-01 14:12:47
“看情况而定。”
这些都是用于类似目的的不同工具。注意“内部”,这表明了一些东西。一般说来,模块对于Rcpp来说也是一个非常精细和强大的模块(有它们自己的微调),并且也可以通过RInside访问。
https://stackoverflow.com/questions/18552308
复制相似问题