on-internet
← Community

arma::mat division by const integer causes problems

Stack Overflow ·

I have a function I call from R using Rcpp. I pass an argument, which is a const unsigned integer, to this function. The integer is used to scale a matrix consisting of random draws. MWE: Rcpp::cppFunction(' auto testfun(const arma::uword n = 10) { arma::dmat W = floor(arma::randu(35, 35, arma::distr_param(0, 2))); return W / n; } ', depends = "RcppArmadillo", plugins = "cpp17") This MWE makes my R crash. My actual code, on the other hand, works but returns garbage. What am I missing here? It appears that the auto declaration is causing the problems. I don't understand why.

Comments

Sign in or sign up to comment and upvote.

No comments yet.