[Rcpp-devel] Returning an arma vec
Romain François
romain at r-enthusiasts.com
Thu Dec 4 17:57:31 CET 2014
Something like this:
template <typename T>
inline wrap( const arma::subview_col<double>& x ){
return wrap( arma::Mat<T>( x ) ) ;
}
(untested)
This would still wrap it as a matrix though as this is what subview_col conceptually gives.
The only downside is that this is somewhat inefficient as it would have to allocate memory for a arma::mat first and then copy that across to an Rcpp::Matrix …
Romain
> Le 3 déc. 2014 à 22:41, Martyn Plummer <plummerM at iarc.fr> a écrit :
>
> 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-bounces at lists.r-forge.r-project.org [rcpp-devel-bounces at lists.r-forge.r-project.org] on behalf of Dirk Eddelbuettel [edd at debian.org]
> Sent: 03 December 2014 19:25
> To: Romain Francois
> Cc: rcpp-devel at lists.r-forge.r-project.org
> Subject: Re: [Rcpp-devel] Returning an arma vec
>
> 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<double>' to 'SEXP' in
> | > initialization
> |
> | This should be easy/trivial to fix for someone with the right skills.
>
> Sure. Maybe Gabor wants to give it a try.
>
> Dirk
>
> --
> http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
> _______________________________________________
> 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
> -----------------------------------------------------------------------
> This message and its attachments are strictly confidential. If you are
> not the intended recipient of this message, please immediately notify
> the sender and delete it. Since its integrity cannot be guaranteed,
> its content cannot involve the sender's responsibility. Any misuse,
> any disclosure or publication of its content, either whole or partial,
> is prohibited, exception made of formally approved use
> -----------------------------------------------------------------------
More information about the Rcpp-devel
mailing list