Re: [Rcpp-devel] Passing XPtr between functions

2015-06-24 Thread Charles Determan
Thanks Hadley, much more concise :) On Wed, Jun 24, 2015 at 2:22 PM, Hadley Wickham wrote: > On Wed, Jun 24, 2015 at 11:08 AM, Charles Determan > wrote: > > Many thanks Krzysztof, your suggestion works. I can explicitly create a > > 'new' arma::mat object and pass the resulting XPtr between fu

Re: [Rcpp-devel] Passing XPtr between functions

2015-06-24 Thread Hadley Wickham
On Wed, Jun 24, 2015 at 11:08 AM, Charles Determan wrote: > Many thanks Krzysztof, your suggestion works. I can explicitly create a > 'new' arma::mat object and pass the resulting XPtr between functions. I > will work on making everything prettier and document for a submission to > Rcpp Gallery

Re: [Rcpp-devel] Passing XPtr between functions

2015-06-24 Thread Charles Determan
Many thanks Krzysztof, your suggestion works. I can explicitly create a 'new' arma::mat object and pass the resulting XPtr between functions. I will work on making everything prettier and document for a submission to Rcpp Gallery unless someone is aware of one that already exists that I somehow o

Re: [Rcpp-devel] Passing XPtr between functions

2015-06-24 Thread Krzysztof Sakrejda
Hi Charles, comments inline 2015-06-24 11:03 GMT-04:00 Charles Determan : > The fastLm examples are nice but they don't contain anything relating to > passing an XPtr between functions. Regarding your comment about making an > XPtr around arma::mat 'innards' I'm not sure I fully understand. I t

Re: [Rcpp-devel] Passing XPtr between functions

2015-06-24 Thread Charles Determan
The fastLm examples are nice but they don't contain anything relating to passing an XPtr between functions. Regarding your comment about making an XPtr around arma::mat 'innards' I'm not sure I fully understand. I tried creating an XPtr around a arma::mat but no success on passing the object betw

Re: [Rcpp-devel] Passing XPtr between functions

2015-06-24 Thread Dirk Eddelbuettel
On 24 June 2015 at 08:22, Charles Determan wrote: | Thank you John, | | I am familiar with bigmemory (I am one of the current developers actually).  | The project I am working on doesn't need the shared memory aspect so was | intending to avoid the dependency and just leverage the more familiar a

Re: [Rcpp-devel] Passing XPtr between functions

2015-06-24 Thread Charles Determan
Thank you John, I am familiar with bigmemory (I am one of the current developers actually). The project I am working on doesn't need the shared memory aspect so was intending to avoid the dependency and just leverage the more familiar and developed Armadillo library. However your response inform

Re: [Rcpp-devel] Passing XPtr between functions

2015-06-23 Thread John Buonagurio
Hi Charles, > SEXP testXptr(SEXP A) > { > arma::Mat armaMat = Rcpp::as >(A); > Rcpp::XPtr pMat(armaMat.memptr()); > return(pMat); > } armaMat is on the stack, so the Armadillo memptr is no longer valid when you return from the testXptr function. One simple solution in your case woul

Re: [Rcpp-devel] Passing XPtr between functions

2015-06-23 Thread Charles Determan
Hi Dirk, I was actually looking at that very page. However, I am still not sure what I am missing here. I am not passing any pointers to functions, just the data object. Like I said, I feel like I must be missing something obvious but cannot figure it out. I fail to see what is distinguishing

Re: [Rcpp-devel] Passing XPtr between functions

2015-06-23 Thread Dirk Eddelbuettel
Charles, Maybe a close look at this will help: http://gallery.rcpp.org/articles/passing-cpp-function-pointers/ Dirk -- http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org h

[Rcpp-devel] Passing XPtr between functions

2015-06-23 Thread Charles Determan
I am exploring the use of some XPtr objects. For example, I can create a pointer to an armadillo matrix. I can then create a copy of that matrix from the pointer within the same function. However, when I try to pass a pointer to a function and create a new copy from said pointer it fails (return