Skip to content
Prev 6020 / 10988 Next

[Rcpp-devel] Integer matrices in Rcpp and Armadillo

Le 07/06/13 15:14, Simon Zehnder a ?crit :
What you get from doing parL["lambda"] is an object of class NameProxy, 
it will be converted to the appropioate class later. NameProxy have no 
.begin method.

Do this:

NumericVector tmp = parL["lambda"] ;
arma::mat armaPar(tmp.begin(), 10, 2, false, true);

This will not make copies of the data.

If thius feels like too much to type, just stuff this into a function:

inline arma::mat convert( SEXP x ){
    NumericVector tmp = parL["lambda"] ;
    return arma::mat(tmp.begin(), 10, 2, false, true);
}

and call :

arma::mat armaPar = convert( parL["lambda"] ) ;

There is a chance convert won't make a copy thanks to RVO.
 
                               ^

  
    

Thread (24 messages)

Simon Zehnder Integer matrices in Rcpp and Armadillo Jun 6 Dirk Eddelbuettel Integer matrices in Rcpp and Armadillo Jun 6 Romain Francois Integer matrices in Rcpp and Armadillo Jun 6 Simon Zehnder Integer matrices in Rcpp and Armadillo Jun 6 Romain Francois Integer matrices in Rcpp and Armadillo Jun 6 Dirk Eddelbuettel Integer matrices in Rcpp and Armadillo Jun 6 Simon Zehnder Integer matrices in Rcpp and Armadillo Jun 6 Simon Zehnder Integer matrices in Rcpp and Armadillo Jun 6 Romain Francois Integer matrices in Rcpp and Armadillo Jun 6 Dirk Eddelbuettel Integer matrices in Rcpp and Armadillo Jun 6 Dirk Eddelbuettel Integer matrices in Rcpp and Armadillo Jun 6 Simon Zehnder Integer matrices in Rcpp and Armadillo Jun 7 Romain Francois Integer matrices in Rcpp and Armadillo Jun 7 Simon Zehnder Integer matrices in Rcpp and Armadillo Jun 7 Simon Zehnder Integer matrices in Rcpp and Armadillo Jun 7 Romain Francois Integer matrices in Rcpp and Armadillo Jun 7 Simon Zehnder Integer matrices in Rcpp and Armadillo Jun 7 Romain Francois Integer matrices in Rcpp and Armadillo Jun 7 Simon Zehnder Integer matrices in Rcpp and Armadillo Jun 8 Kevin Ushey Integer matrices in Rcpp and Armadillo Jun 8 Dirk Eddelbuettel Integer matrices in Rcpp and Armadillo Jun 8 Dirk Eddelbuettel Integer matrices in Rcpp and Armadillo Jun 8 Simon Zehnder Integer matrices in Rcpp and Armadillo Jun 9 Simon Zehnder Integer matrices in Rcpp and Armadillo Jun 9