[Rcpp-devel] Returning an arma vec

2014-12-03 Thread Gabor Grothendieck
1. This returns a matrix rather than a vector: -- start of file teste.cpp --- #include // [[Rcpp::depends(RcppArmadillo)]] using namespace arma; using namespace Rcpp; // [[Rcpp::export]] NumericVector teste(const vec& x) { vec v = x.subvec(1, 2); // x return wrap(v); // x } /*** R teste(1:4) *

Re: [Rcpp-devel] Returning an arma vec

2014-12-03 Thread Dirk Eddelbuettel
This is known, documented / has been discussed before, and hard to change now given that 100 CRAN packages depend on RcppArmadillo and its existing interface. You could write your own converter to SEXP and use that. Dirk On 3 December 2014 at 11:59, Gabor Grothendieck wrote: | 1. This returns a

Re: [Rcpp-devel] Returning an arma vec

2014-12-03 Thread Romain Francois
Envoyé de mon iPhone > Le 3 déc. 2014 à 17:59, Gabor Grothendieck a écrit : > > 1. This returns a matrix rather than a vector: > > -- start of file teste.cpp --- > #include > // [[Rcpp::depends(RcppArmadillo)]] > > using namespace arma; > using namespace Rcpp; > > // [[Rcpp::export]] > Nume

Re: [Rcpp-devel] Returning an arma vec

2014-12-03 Thread Dirk Eddelbuettel
On 3 December 2014 at 11:14, Dirk Eddelbuettel wrote: | | This is known, documented / has been discussed before, and hard to change now | given that 100 CRAN packages depend on RcppArmadillo and its existing interface. | | You could write your own converter to SEXP and use that. That said, I a

Re: [Rcpp-devel] Returning an arma vec

2014-12-03 Thread Dirk Eddelbuettel
On 3 December 2014 at 18:30, Romain Francois wrote: | > 2. If we replace the lines marked // x with | > | > return wrap(x.subvec(1, 2)); | > | > then it fails with a compiler error. | > | > error: cannot convert 'const arma::subview_col' to 'SEXP' in | > initialization | | This should be

Re: [Rcpp-devel] Returning an arma vec

2014-12-03 Thread Martyn Plummer
You just need to put a new template specialization of "wrap" for the subview_col class in RcppArmadilloWrap.h based on the existing one for the subview class. And throw in one for subview_row for good measure. Martyn From: rcpp-devel-boun...@lists.r-forge