[Rcpp-devel] How to modifying the elements of a list in the global environment?

2012-10-19 Thread Christian Gunning
>> ### For the Rcpp part, set aside working space in the global environment >> workspace <- lapply(1:K, function(k) matrix(0.0, N, M)) > > Then I try to access the matrices in the 'workspace' list and modify them, > but so far I have had no success. The first attemp, bolow, does not compile... > >

[Rcpp-devel] How to modifying the elements of a list in the global environment?

2012-10-19 Thread Christian Gunning
> Giovanni, > > Anything you pass from R into your C++ routine should be considered > read-only. It's typically a bad idea to do in-place updates of the R > object you passed in as an argument. Really? I was under the impression that the ability of in-place modification was a conscious design dec

Re: [Rcpp-devel] How to modifying the elements of a list in the global environment?

2012-10-19 Thread Dirk Eddelbuettel
On 19 October 2012 at 01:19, Christian Gunning wrote: | > Anything you pass from R into your C++ routine should be considered | > read-only. It's typically a bad idea to do in-place updates of the R | > object you passed in as an argument. | | Really? I was under the impression that the ability

Re: [Rcpp-devel] How to modifying the elements of a list in the global environment?

2012-10-19 Thread Dirk Eddelbuettel
On 18 October 2012 at 21:54, Davor Cubranic wrote: | OK, 'sweep' is a fair bit (15x) slower than the Rcpp code Giovanni | wrote, but you still should be using the return value of the C++ | function to get the result back to R, rather than writing directly into | function arguments. | | Here is