Questions tagged «rcpparmadillo»

1
更新R后,RcppArmadillo的sample()不明确
我通常使用一个简短的Rcpp函数作为输入矩阵,其中每行包含K个合计为1的概率。然后,该函数为每行随机采样1到K之间与提供的概率相对应的整数。这是功能: // [[Rcpp::depends(RcppArmadillo)]] #include <RcppArmadilloExtensions/sample.h> using namespace Rcpp; // [[Rcpp::export]] IntegerVector sample_matrix(NumericMatrix x, IntegerVector choice_set) { int n = x.nrow(); IntegerVector result(n); for ( int i = 0; i < n; ++i ) { result[i] = RcppArmadillo::sample(choice_set, 1, false, x(i, _))[0]; } return result; } 我最近更新了R和所有软件包。现在,我无法再编译此函数。我不清楚原因。跑步 library(Rcpp) library(RcppArmadillo) Rcpp::sourceCpp("sample_matrix.cpp") 引发以下错误: …
9 r  rcpp  rcpparmadillo 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.