[Rcpp-devel] Inconsistent returns

Lovett, Mitch mitch.lovett at simon.rochester.edu
Tue Oct 19 19:53:58 CEST 2010


I am running into some strange behavior with Rcpp objects returned to R.
Specifically, I run a program that sets values on several large
matrices. I initialize these and pass the matrices back with the code
below (I don't include all the code to fill the matrix). So, I pass it
back as a list. Once in R, I summarize the list to find all the objects
of the right length. I try to get the dims on the objects and only some
of them return the correct dims some of the time, while all of them do
other times. In case it matters, these are running on MacOS and running
the previous version of Rcpp. Any help would be great.

 

Thanks,

Mitch

 

//initialize

Rcpp::NumericMatrix Res(n,nmcmc/keep);

Rcpp::NumericMatrix REs(n,nmcmc/keep);

Rcpp::NumericMatrix Rais(n,nmcmc/keep);

Rcpp::NumericMatrix Rbis(n,nmcmc/keep);

Rcpp::NumericMatrix Rthets(thet.n_rows,nmcmc/keep);

Rcpp::NumericMatrix RmovsE(n/2,mreport);

 

arma::mat Es(REs.begin(),n,nmcmc/keep,false);

arma::mat ais(Rais.begin(),n,nmcmc/keep,false);

arma::mat bis(Rbis.begin(),n,nmcmc/keep,false);

arma::mat es(Res.begin(),n,nmcmc/keep,false);  

arma::mat thets(Rthets.begin(),thet.n_rows,nmcmc/keep,false);

arma::colvec lls(nmcmc/keep); 

arma::mat movsE(RmovsE.begin(),n/2,mreport,false);

 

//return

Rcpp::List ret=Rcpp::List::create(Rcpp::Named("lls")=Rcpp::wrap(lls),


 
Rcpp::Named("thets")=Rcpp::wrap(thets),

 
Rcpp::Named("Es")=Rcpp::wrap(Es),

 
Rcpp::Named("es")=Rcpp::wrap(es),

 
Rcpp::Named("ais")=Rcpp::wrap(ais),

 
Rcpp::Named("bis")=Rcpp::wrap(bis),

 
Rcpp::Named("movsAB")=Rcpp::wrap(movsE)

                                                                );

return Rcpp::wrap(ret);

 

 

 

Mitchell J. Lovett

Assistant Professor of Marketing

Simon School of Business

University of Rochester

(585) 276-4020

mitch.lovett at simon.rochester.edu

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20101019/be47ad56/attachment.htm>


More information about the Rcpp-devel mailing list