I was not able to find this being specifically addressed previously,
so I thought I'd try starting a new thread:

I am dealing with a bunch of big matrices and basic mathematics, such as

x <- x + y * 3

where x and y are large matrices of the same dimension. I now realize
that when I perform the above expression, I am allocating two new
matrices of the same kind.
However, this expression

x[,] <- x[,] + y[,] * 3

seems do the operations in-place and thus should avoid additional
memory allocation (at least from what I gather using tracemem()).

Is this actually what is happening? Why is it that when I look at y
after performing the above expression, it hasn't changed?

I would greatly appreciate hearing any insights from experienced R
users or developers.
Also additional memory saving tricks would also be a great addition to
this thread.

Thanks.
-David

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to