[Rcpp-devel] rcpp overhead

Dirk Eddelbuettel edd at debian.org
Mon Mar 12 00:56:11 CET 2012


On 12 March 2012 at 00:43, Kaveh Vakili wrote:
| Dear Prof Bates,
| 
| i have started to account for the difference 
| in performances between the cpp only and the 
| rcpp. 
| 
| ctrl-f ing the rcpp docs does not give much 
| on manipulation of float. Is there a way, in 
| rcpp, to use the fact that some parts of the
|  algorithm are float-safe?
| 
| (....,SEXP R_x,....){
| const int n = Rcpp_x.nrow(); 
| const int p = Rcpp_x.ncol();
| NumericMatrix Rcpp_x(R_x);	
| Map<MatrixXd> x(Rcpp_x.begin(),n,p);
| MatrixXf x_cen = x.cast<float>();

R never uses float, so you /always/ have the cost of a full copy here.

Most people stopped caring about the float/double savings a long time ago. If
you are seriously constrained (embedded systems, GPUs, ...) it may make
sense.  Otherwise you may want to rethink the insistence on float.

Dirk

-- 
"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
dark to read." -- Groucho Marx


More information about the Rcpp-devel mailing list