RcppArmadillo and C++ division issue
问题 A very simple question regarding RcppArmadillo. Trying to multiply a vector by a scalar, and getting different results depending on small changes in syntax. Any ideas? // [[Rcpp::depends("RcppArmadillo")]] // [[Rcpp::export]] arma::vec funtemp(arma::vec x) { // return(x/10); // this works // return((1/10)*x); // this does not work return(x*(1/10)); // this does not work } 回答1: Ahh, the good ol' integer vs. double division problem in C++. Before we begin, note that: arma::vec is by default a