[Rcpp-devel] trying to insert a number as first element of already existing vector

Dirk Eddelbuettel edd at debian.org
Mon Dec 10 13:15:08 CET 2018


On 10 December 2018 at 13:04, Jan van der Laan wrote:
| Small addendum: A large part of the performance gain in my example comes 
| from using NumericVector instead of std::vector<double>. Which avoids a 
| conversion. An example using std::copy with Numeric vector runs in the 
| same time as the version using memcpy.

+1

That sounds reasonable and matches my experience: std::memcpy is good yet
std::copy may itself be implemented with using it.  And ussing care with the
interface is important: std::vector<> has its own memory allocation scheme so
we cannot do without a copy which we notice here in the timings.

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list