Re: [Rcpp-devel] Returning an arma vec

2014-12-04 Thread Romain François
Something like this: 

template 
inline wrap( const arma::subview_col& x ){
return wrap( arma::Mat( 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  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-boun...@lists.r-forge.r-project.org 
> [rcpp-devel-boun...@lists.r-forge.r-project.org] on behalf of Dirk 
> Eddelbuettel [e...@debian.org]
> Sent: 03 December 2014 19:25
> To: Romain Francois
> Cc: rcpp-devel@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' 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 | e...@debian.org
> ___
> Rcpp-devel mailing list
> Rcpp-devel@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
> ---

___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

[Rcpp-devel] Rcpp and ExternalPtr

2014-12-04 Thread Jeroen Ooms
Does Rcpp provide some elegant way to let the R user manage persistent
c++ objects that have no R type (e.g. internal handles or sessions of
some sort)?

In C, I would use R_MakeExternalPtr to create a ptr SEXP that the user
can pass from one R function to another. This also makes it easy to
add a finalizer with R_RegisterCFinalizerEx so that the garbage
collector will automatically clean up the session/handle whenever user
deletes the R object.

Most Rcpp examples I have seen use function arguments with standard
data types that are automatically mapped to R types. Does Rcpp have
any special mechanics for managing external objects (pointers) from R
which do not map to a SEXP type? Or do I have to fall back on
Rinternals for this?
___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel