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?
Best,
Serguei.
[Rcpp-devel] return Colvec as vector
7 messages · Serguei Sokol, Qiang Kou, Dirk Eddelbuettel
Can you give more information on why we need this or what problem people are facing now? Best, KK On Thu, Jul 27, 2017 at 9:37 AM, Serguei Sokol <serguei.sokol at gmail.com> 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?
Best,
Serguei.
_______________________________________________ Rcpp-devel mailing list Rcpp-devel at lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Qiang Kou qkou at umail.iu.edu School of Informatics and Computing, Indiana University -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20170727/e588f848/attachment.html>
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
Le 28/07/2017 ? 13:45, Dirk Eddelbuettel a ?crit :
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).
Cool. Then to be complete, we can think about a full set of options, smth. like: RCPP_ARMADILLO_RETURN_COLVEC_AS_VECTOR RCPP_ARMADILLO_RETURN_ROWVEC_AS_VECTOR RCPP_ARMADILLO_RETURN_ANYVEC_AS_VECTOR Serguei.
On 28 July 2017 at 14:59, Serguei Sokol wrote:
| Le 28/07/2017 ? 13:45, Dirk Eddelbuettel a ?crit : | > 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). | Cool. Then to be complete, we can think about a full set of options, smth. like: | RCPP_ARMADILLO_RETURN_COLVEC_AS_VECTOR | RCPP_ARMADILLO_RETURN_ROWVEC_AS_VECTOR | RCPP_ARMADILLO_RETURN_ANYVEC_AS_VECTOR Thumbs up! Do you want to sketch a pull request, or shall we take this offline? Dirk
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
Dirk Eddelbuettel has written at Fri, 28 Jul 2017 17:28:11 -0500
On 28 July 2017 at 14:59, Serguei Sokol wrote: | Le 28/07/2017 ? 13:45, Dirk Eddelbuettel a ?crit : | > 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). | Cool. Then to be complete, we can think about a full set of options, smth. like: | RCPP_ARMADILLO_RETURN_COLVEC_AS_VECTOR | RCPP_ARMADILLO_RETURN_ROWVEC_AS_VECTOR | RCPP_ARMADILLO_RETURN_ANYVEC_AS_VECTOR Thumbs up! Do you want to sketch a pull request, or shall we take this offline?
A pull request #151 is awaiting your exam. Serguei. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20170729/5592687d/attachment.html>
On 29 July 2017 at 01:47, Sokol Serguei wrote:
| Dirk Eddelbuettel has written at Fri, 28 Jul 2017 17:28:11 -0500
| > On 28 July 2017 at 14:59, Serguei Sokol wrote:
| > | Le 28/07/2017 ? 13:45, Dirk Eddelbuettel a ?crit : | > | > 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). | > | Cool. Then to be complete, we can think about a full set of options, smth. like: | > | RCPP_ARMADILLO_RETURN_COLVEC_AS_VECTOR | > | RCPP_ARMADILLO_RETURN_ROWVEC_AS_VECTOR | > | RCPP_ARMADILLO_RETURN_ANYVEC_AS_VECTOR | > | > Thumbs up! | > | > Do you want to sketch a pull request, or shall we take this offline? | A pull request #151 is awaiting your exam. Thanks for getting it started. It is a little bare as it stands right now but we can get there. If other wants to chime in: https://github.com/RcppCore/RcppArmadillo/pull/151 Dirk
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org