Rcpp允許矢量化一些操作,這很好。但是對於pow
,只有基數可以是一個向量,而不是指數。通常情況下,在編譯:Rcpp中pow的矢量化指數
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
NumericVector puissancedCpp(NumericVector base, double exp){
return pow(base,exp);
}
作品,但不是:
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
NumericVector puissancedCpp(NumericVector base, NumericVector exp){
return pow(base,exp);
}
什麼是執行的推薦方式中的R這將是:在其他東西中間
c(0,1,2,3)^c(4,3,2,1)
在C完成?
非常好。 Rcpp的重點在於使這一切變得簡單。 –
太好了。它適用於我的Ubuntu 14.04盒 – cmbarbu
當然。我們通過插件支持C++ 11一段時間 - 也許是13.04或12.10。目前的g ++ 4.9。*很好。 –