[Rcpp-devel] Delayed usage of auxiliary memory in RcppArmadillo

Simon Zehnder szehnder at uni-bonn.de
Mon Jun 10 23:07:18 CEST 2013


Dear Rcpp::Devels and Rcpp::Users,

I am temporarily experiencing with a delayed assignment of auxiliary memory in RcppArmadillo:

Declare a matrix from which you know you may need it

arma::mat maybeM;

(In C++ a declaration makes only known the type and name but allocates no storage yet).

Now you check a condition and if it is true, you will need the matrix, so you initialize it 

if(mycondition) {
	maybeM = arma::mat(aux_mem*, n_rows, n_cols, copy_aux_mem = false, strict = true) 
}

(for simplicity I only printed here the default constructor for using auxiliary memory; please assume that all values are presented)

The resulting matrix maybeM does not use the auxiliary memory. I tried to access in some way the 'mem' member in the Armadillo class, but this member is constant and can not be
manipulated after first construction. A primer declaration and later initialization is a very common pattern in C++, but it seems not be possible in case of reusing memory. 

I conclude, that a delayed assignment of auxiliary memory is not possible.


Best

Simon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20130610/c3718ec1/attachment-0001.html>


More information about the Rcpp-devel mailing list