[Rcpp-devel] return Colvec as vector
Dirk Eddelbuettel
edd at debian.org
Fri Jul 28 13:45:36 CEST 2017
On 27 July 2017 at 18:37, Serguei Sokol wrote:
| I can hear from here "Oh no, not again this question!" ;)
;-)
| But this time it is not a question it is a feature suggestion.
| What if we replace in RcppArmadilloWrap.h:64:
| template <typename T> SEXP wrap( const arma::Col<T>& data ){
| return RcppArmadillo::arma_wrap( data, Dimension( data.n_elem, 1) ) ;
| }
| by something like:
| template <typename T> SEXP wrap( const arma::Col<T>& data ){
| #ifdef RETURN_COLVEC_AS_VECTOR
| return RcppArmadillo::arma_wrap( data ) ;
| #else
| return RcppArmadillo::arma_wrap( data, Dimension( data.n_elem, 1) ) ;
| #endif
| }
|
| In this way, a legacy code relying on one column matrix is not impacted,
| while other users can define a macro RETURN_COLVEC_AS_VECTOR
| before "#include <Rcpp>" and enjoy a more intuitive behavior.
|
| Was it already proposed and rejected?
Don't think so, but I have thought about it too, and I was planning to bring
this up. I also find the 'always forced to be dimension one matrix' to be a
(very early) design decision I would not make again. And I have been
thinking along similar lines---we need an option to restore it / keep it as
the defaults, and a newer alternative to let this collapse to a dimless
vector. What you rprose could work (maybe by prefixing RCPP_ARMADILLO_ to
the #define though).
Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
More information about the Rcpp-devel
mailing list