Re: [Rcpp-devel] Forcing a shallow versus deep copy

2013-09-13 Thread JJ Allaire
Is it a big deal that we would cheat on chat reference passing means ? If you want to implement these sort of semantics I think at a _minimum_ the type should be const (otherwise it looks like you are going to actually modify the matrix in place which would appear to bypass the implicit

Re: [Rcpp-devel] Forcing a shallow versus deep copy

2013-09-13 Thread Romain Francois
Le 13/09/13 14:00, JJ Allaire a écrit : Is it a big deal that we would cheat on chat reference passing means ? If you want to implement these sort of semantics I think at a _minimum_ the type should be const (otherwise it looks like you are going to actually modify the matrix in place

Re: [Rcpp-devel] Forcing a shallow versus deep copy

2013-09-13 Thread Romain Francois
Le 13/09/13 14:15, Romain Francois a écrit : But I realize this might be a strech and we can definitely only have const references. Which is easier to implement anyway and we would not need the reference counting stuff I was talking about before. spoke too soon. We would need it otherwise we

Re: [Rcpp-devel] Forcing a shallow versus deep copy

2013-09-13 Thread Romain Francois
Le 13/09/13 14:00, JJ Allaire a écrit : Is it a big deal that we would cheat on chat reference passing means ? If you want to implement these sort of semantics I think at a _minimum_ the type should be const (otherwise it looks like you are going to actually modify the matrix in place

Re: [Rcpp-devel] Forcing a shallow versus deep copy

2013-09-13 Thread Dirk Eddelbuettel
On 13 September 2013 at 17:56, Romain Francois wrote: | Here is where I am now. To wrap up this function: [...] | This is simple and elegant. And now we can pass down references and | const references of armadillo matrices from R without performance penalty. | | This makes using RcppArmadillo

Re: [Rcpp-devel] Forcing a shallow versus deep copy

2013-07-12 Thread Gabor Grothendieck
On Fri, Jul 12, 2013 at 1:42 AM, Dirk Eddelbuettel e...@debian.org wrote: On 11 July 2013 at 19:21, Gabor Grothendieck wrote: | 1. Just to be clear what we have been discussing here is not just how to | avoid copying but how to avoid copying while using as and wrap | or approaches that

Re: [Rcpp-devel] Forcing a shallow versus deep copy

2013-07-12 Thread Changi Han
I apologize if my emails were badly phrased, or disrespectful. No intention of saying anything was broken, suspicious or wrong. I second Gabor. His described use case matches mine. The outer loop is an optimization routine coming from other libraries. Rcpp is used to speed up the objective,

Re: [Rcpp-devel] Forcing a shallow versus deep copy

2013-07-11 Thread baptiste auguie
Hi, That's great, thanks for considering this! Following this discussion, I went to browse through my code looking for wrap() and as() statements that could benefit from a speed-up of memory reuse. Of course I didn't find any. I switched to using Modules when they were introduced, the code being

Re: [Rcpp-devel] Forcing a shallow versus deep copy

2013-07-11 Thread Changi Han
I am sure there are better ways to achieve the goal. I would suggest that these two be similar if possible. I think the naive expectation is for them to be consistent. // [[Rcpp::export]] stuff function(Rcpp::stuff) { } // [[Rcpp::export]] stuff function(arma::stuff) { } Thank you again.

Re: [Rcpp-devel] Forcing a shallow versus deep copy

2013-07-11 Thread romain
These __are__ similar. The difference is in the classes themselves. Rcpp classes are proxy classes so C++ copy mechanism does not apply to them. arma classes are proper c++ classes, so C++ semantics apply. I'm at useR right now, so I can't really work on this. I'll submit at least ideas

Re: [Rcpp-devel] Forcing a shallow versus deep copy

2013-07-11 Thread Dirk Eddelbuettel
On 11 July 2013 at 10:33, baptiste auguie wrote: | Hi, | | That's great, thanks for considering this! | | Following this discussion, I went to browse through my code looking for wrap() | and as() statements that could benefit from a speed-up of memory reuse. Of | course I didn't find any.  | I

Re: [Rcpp-devel] Forcing a shallow versus deep copy

2013-07-11 Thread Dirk Eddelbuettel
Everybody has this existing example in their copy of Armadillo. I am running it here from SVN rather than the installed directory, but this should not make a difference. Machine is my not-overly-powerful thinkpad used for traveling: edd@don:~/svn/rcpp/pkg/RcppArmadillo/inst/examples$ r

Re: [Rcpp-devel] Forcing a shallow versus deep copy

2013-07-11 Thread Dirk Eddelbuettel
On 11 July 2013 at 19:21, Gabor Grothendieck wrote: | 1. Just to be clear what we have been discussing here is not just how to | avoid copying but how to avoid copying while using as and wrap | or approaches that automatically generate as and wrap. I was already | aware of how to avoid copying