[R] Rcpp/RcppArmadillo - matrix manipulation
leblkarin at hotmail.com
Mon Jun 17 16:38:49 CEST 2013
I’ve been working with R for some years, but I am beginner to Rcpp (and have no experience with C++).
I am trying to set zeros in a matrix to Inf. In R I would do this:
My try with Rcpp and RcppArmadillo looked like this (as I do not know how it works with inf I just set it to 100 in a first step):
code <- '
arma::mat M0 = Rcpp::as<arma::mat>(a);
arma::mat M1 = Rcpp::as<arma::mat>(a);
arma::uvec xx = find (M1==0);
tf <- cxxfunction(signature(a="numeric"), code,plugin="RcppArmadillo")
But this just produces errors *… However, setting the index “manually” would work (changing M1(xx)=100 to M1(8)=100).
What do I have to change to make it work?
If I understood it correctly, it should be possible to use inf (http://arma.sourceforge.net/docs.html&constants). Can I do this simply by setting
Thanks to anyone who takes the time to answer my questions.
* They are long and (I think) not very informative. But I can provide them if requested.
More information about the R-help