[Rcpp-devel] Range constructor and memory allocation
gregor.kastner at wu.ac.at
Tue Feb 18 19:12:37 CET 2014
while writing an iterator hack for the problem encountered a few hours ago
and posted here:
I have noticed that the default behavior for the range constructor for e.g.
Rcpp::NumericVector seems to be to allocate fresh memory:
arma::mat obj1(5, 10, arma::fill::zeros);
Rcpp::NumericVector obj2(obj1.begin(), obj1.begin() + 5);
obj2 = 1.;
Rprintf("obj1: %f, obj2: %f\n", obj1(0,0), obj2(0));
yields that obj1 and obj2 differ.
Is there any way to tell the range constructor to reuse existing memory
similarly to the (Rcpp)Armadillo feature copy_aux_mem = false or am I
missing something more subtle?
Thanks in advance for any hints,
More information about the Rcpp-devel