Re: [Rcpp-devel] Const correctness of NumericVector iterators

2014-11-27 Thread Romain Francois
This is probably related to this: template int RTYPE struct r_vector_const_iterator { typedef typename storage_typeRTYPE::type* type ; }; There should be a const there somewhere. FWIW, more modern implementations of R/C++ are more safe on that issue:

[Rcpp-devel] Indexing vector with x(i) and x[i] gives remarkable difference in computing time

2014-11-27 Thread Søren Højsgaard
Dear all, By accident I noticed that indexing with x(i) and x[i] gives remarkable difference in computing time. For example: library(Rcpp) cppFunction(' IntegerVector insert1 (int n){ IntegerVector z(n); for (int i=0; in; ++i) z(i) = i; // NOTICE: using () return z; }') cppFunction('

Re: [Rcpp-devel] Indexing vector with x(i) and x[i] gives remarkable difference in computing time

2014-11-27 Thread Romain Francois
Le 27 nov. 2014 à 13:22, Søren Højsgaard sor...@math.aau.dk a écrit : Dear all, By accident I noticed that indexing with x(i) and x[i] gives remarkable difference in computing time. For example: library(Rcpp) cppFunction(' IntegerVector insert1 (int n){ IntegerVector z(n); for