C++ LOAD_RCPP_模块和RCPP::InternalFunction之间的差异
在使用RInside的情况下,C++ LOAD_RCPP_模块和RCPP::InternalFunction之间的差异,c++,rcpp,rinside,C++,Rcpp,Rinside,在使用RInside的情况下,Rcpp::InternalFunction和LOAD\u Rcpp\u MODULE之间有什么区别?它们似乎有相同的目的,只是LOAD\u RCPP\u模块有一个额外的层。它们的用例是什么?什么时候我应该选择其中一个而不是另一个 //example with LOAD_RCPP_MODULE const char* hello( std::string who ){ std::string result( "hello " ) ; result +
Rcpp::InternalFunction
和LOAD\u Rcpp\u MODULE
之间有什么区别?它们似乎有相同的目的,只是LOAD\u RCPP\u模块
有一个额外的层。它们的用例是什么?什么时候我应该选择其中一个而不是另一个
//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 )
“这要看情况。”
这些是用于类似目的的不同工具。注意“内部”虽然它表示某事。一般来说,模块对于Rcpp来说也是一个非常好和强大的工具(具有自己的渐晕图),也可以通过RInside访问。模块可以让您公开多个函数和类<代码>内部函数一次只公开一个函数
InternalFunction
有点奇怪,我们在某个时候添加了它来回答“我们能做到那一点”类型的问题。这是Rcpp中保留下来的东西之一,因为它们曾经是,但这并没有得到我们太多的关注。它主要用于<代码> RIN < /COD>允许R代码调用C++函数。这是一个奇怪的模式,因为<>代码> rnI>代码>焦点是一个嵌入R.< /P>的C++应用程序。
然而,模块确实得到了很多关注。我的建议是使用它们真的,我同意你的意见,有一些用例