[Rcpp-devel] Error still there

Avraham Adler avraham.adler at gmail.com
Wed Sep 14 16:52:38 CEST 2016


Amina and I continued the conversation off list, but for closure purposes,
the "multiple" version was tweaked a bit as there was comparison between
signed and unsigned ints which did not throw an error for me, but did for
Amina. Final multiple version posted below.

Thanks,

Avi


#include <RcppArmadillo.h>
using namespace Rcpp;
using namespace RcppArmadillo;
using namespace arma;
//[[Rcpp::depends(RcppArmadillo)]]

//[[Rcpp::export]]
vec Sample_Exp_Multi(size_t n, vec alpha, vec beta) {
  size_t m = alpha.size();
  vec answers(n);
  uvec2 S;
  for (size_t i = 0; i < n; ++i){
    do {
      S = randi<uvec>(2, distr_param(0, m - 1));
    } while (S(0) == S(1));
    answers(i) = exp(alpha(S(0)) + beta(S(1)));
  }
  return(answers);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20160914/4d30e381/attachment.html>


More information about the Rcpp-devel mailing list