Thu 17 Nov 2016 07:09:13 PM UTC, comment #2:
The optimization may be possible. The operators such as '+=' or '-=' use in-place optimization and are significantly faster.
It already appears that indexing in the normal case is in-place.
Thus, it is a question of whether there is a way to hook in to the operator based function or not.
|
Tue 03 May 2011 02:41:31 PM UTC, original submission:
*This seems to be rather a Matlab-internal, undocumented features*
In some of my code I've been making use of the undocumented feature that if a call to subsasgn (only on a built-in type!) does not have a LHS assignment, the assignment is done "in place" (speed gain):
The previous code actually alters 'r', which is, to my knowledge, NOT documented by Mathworks.
The reason to use this syntax is that there is no cost to keep another copy of the variable in memory (to allow error handling, etc.).
So the following two subsasgn calls in Matlab work (and produce the same result), but the first is instantaneous, whereas the second one takes quite a while and might even end with an out-of-memory error:
While this is not a big deal, it would be nice to also have this "speedup" available in Octave (particularly when working on large, full matrices, such as 4D datasets that require a large amount of memory).
In Octave, a "manual" call of subsasgn on a large array always requires a copy, whereas using
is instantaneous, which is a little "inconsistent", I guess...
|