Re: [Rcpp-devel] returning array from C

2013-06-11 Thread Steve Jaffe
On Tuesday, June 11, 2013 9:21 PM, Krzysztof Sakrejda wrote: > I think it's more useful to think of whether a limited subset of these > operations will work for your application and whether you can convey the > limits > of the class to the user---I'd hate to convince a user that something _is_

Re: [Rcpp-devel] returning array from C

2013-06-11 Thread Krzysztof Sakrejda
On Tue, Jun 11, 2013 at 4:10 PM, Steve Jaffe wrote: > On Tuesday, June 11, 2013 3:02 PM, Romain Francois wrote: >> Maintaining the idea that this external pointer acts as a numeric vector >> without being one. >> >> What happens then you want its mean, its quantile or whatever. You >> essentiall

Re: [Rcpp-devel] returning array from C

2013-06-11 Thread Romain Francois
Le 11 juin 2013 à 22:10, Steve Jaffe a écrit : > On Tuesday, June 11, 2013 3:02 PM, Romain Francois wrote: >> Maintaining the idea that this external pointer acts as a numeric vector >> without being one. >> >> What happens then you want its mean, its quantile or whatever. You >> essentially

Re: [Rcpp-devel] returning array from C

2013-06-11 Thread Steve Jaffe
On Tuesday, June 11, 2013 3:02 PM, Romain Francois wrote: > Maintaining the idea that this external pointer acts as a numeric vector > without being one. > > What happens then you want its mean, its quantile or whatever. You > essentially have to reimplement everything. > > So yes : can be do

Re: [Rcpp-devel] returning array from C

2013-06-11 Thread Hadley Wickham
>> I'm sure we could just write a wrapper factory function that generates >> all that code, it's just boilerplate until you get to the calls for >> calling methods for whatever the XPtr points to >> >> Krzysztof > > Maintaining the idea that this external pointer acts as a numeric vector > wit

Re: [Rcpp-devel] returning array from C

2013-06-11 Thread Romain Francois
Le 11 juin 2013 à 20:54, Krzysztof Sakrejda a écrit : > On Tue, Jun 11, 2013 at 2:49 PM, Romain Francois > wrote: >> >> Le 11 juin 2013 à 20:40, Steve Jaffe a écrit : >> >>> On Tuesday, June 11, 2013 2:37 PM, Krzysztof Sakrejda wrote: > Would you know of a simple example of writing a "re

Re: [Rcpp-devel] returning array from C

2013-06-11 Thread Krzysztof Sakrejda
On Tue, Jun 11, 2013 at 2:49 PM, Romain Francois wrote: > > Le 11 juin 2013 à 20:40, Steve Jaffe a écrit : > >> On Tuesday, June 11, 2013 2:37 PM, Krzysztof Sakrejda wrote: Would you know of a simple example of writing a "reference class" that looks to R like a numeric vector? >>>

Re: [Rcpp-devel] returning array from C

2013-06-11 Thread Romain Francois
Le 11 juin 2013 à 20:40, Steve Jaffe a écrit : > On Tuesday, June 11, 2013 2:37 PM, Krzysztof Sakrejda wrote: >>> Would you know of a simple example of writing a "reference class" that looks >>> to R like a numeric vector? >> >> I think all the examples I've written are too complicated to be us

Re: [Rcpp-devel] returning array from C

2013-06-11 Thread Romain Francois
Envoyé de mon iPhone Le 11 juin 2013 à 18:33, Steve Jaffe a écrit : >> On 11 June 2013, Dirk Eddelbuettel wrote: >> | On 11 June 2013, Steve Jaffe wrote: >> | Is there a way to 'wrap', say, an array of double allocated on the heap in >> C/C++ and return it to R without copying, ie as the data

Re: [Rcpp-devel] returning array from C

2013-06-11 Thread Steve Jaffe
On Tuesday, June 11, 2013 2:37 PM, Krzysztof Sakrejda wrote: > > Would you know of a simple example of writing a "reference class" that looks > > to R like a numeric vector? > > I think all the examples I've written are too complicated to be useful > but as a simple example break it into two probl

Re: [Rcpp-devel] returning array from C

2013-06-11 Thread Krzysztof Sakrejda
On Tue, Jun 11, 2013 at 2:12 PM, Steve Jaffe wrote: >> You can get what you want, but you'll have to use XPtr, then on the R side >> write a reference class and methods which make the object behave like a >> numeric vector. No copying necessary. > > > This did occur to me, and I looked to 'ff' as

Re: [Rcpp-devel] returning array from C

2013-06-11 Thread Steve Jaffe
On Jun 11, 2013 1:42 PM, Krzysztof Sakrejda [mailto:krzysztof.sakre...@gmail.com] wrote: > On Jun 11, 2013 12:33 PM, "Steve Jaffe" wrote: > > > > The problem with External Pointer is that R will not be able to use it as a > > numeric vector (sfaik). > > > > What I'm looking for -- and perhaps it

Re: [Rcpp-devel] returning array from C

2013-06-11 Thread Krzysztof Sakrejda
On Jun 11, 2013 12:33 PM, "Steve Jaffe" wrote: > > The problem with External Pointer is that R will not be able to use it as a numeric vector (sfaik). > > What I'm looking for -- and perhaps it is impossible -- would be a way to combine the memory semantics of External Pointer with the value seman

Re: [Rcpp-devel] returning array from C

2013-06-11 Thread Steve Jaffe
> On 11 June 2013, Dirk Eddelbuettel wrote: > | On 11 June 2013, Steve Jaffe wrote: > | Is there a way to 'wrap', say, an array of double allocated on the heap in > C/C++ and return it to R without copying, ie as the data inside a REALSXP? > | > | (Let's say for example that this array allocation

Re: [Rcpp-devel] returning array from C

2013-06-11 Thread Dirk Eddelbuettel
On 11 June 2013 at 10:51, Steve Jaffe wrote: | Is there a way to 'wrap', say, an array of double allocated on the heap in C/C++ and return it to R without copying, ie as the data inside a REALSXP? | | (Let's say for example that this array allocation is in a 3rd-party library which can't be mod

Re: [Rcpp-devel] returning array from C

2013-06-11 Thread Steve Jaffe
Thanks. It seems from my quick reading that there are ways around the GC issue, this is done for the "External Pointer" type as I understand it, so that might not be insurmountable. On the other hand, it might not be possible to separate GC from R lifetime for the vector type (ie REALSXP). Tha

Re: [Rcpp-devel] returning array from C

2013-06-11 Thread Douglas Bates
On Tue, Jun 11, 2013 at 10:51 AM, Steve Jaffe wrote: > Is there a way to 'wrap', say, an array of double allocated on the heap in > C/C++ and return it to R without copying, ie as the data inside a REALSXP? > I don't know of any way of doing that. R is very possessive about memory and expects t

[Rcpp-devel] returning array from C

2013-06-11 Thread Steve Jaffe
Is there a way to 'wrap', say, an array of double allocated on the heap in C/C++ and return it to R without copying, ie as the data inside a REALSXP? (Let's say for example that this array allocation is in a 3rd-party library which can't be modified) Looking at the 'wrap' code it appears that c

Re: [Rcpp-devel] Delayed usage of auxiliary memory in RcppArmadillo

2013-06-11 Thread Simon Zehnder
Hi Romain, thanks for refreshing my C++ basics As I am regrettably not privileged to spare the amount of time on C++ skill improvement I would like to, but have the assignment to construct stochastic models and implement them, I focus here on a solution and maybe someone can help me, with his e