[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #33221] subsasgn without LHS assignment Matlab
From: |
anonymous |
Subject: |
[Octave-bug-tracker] [bug #33221] subsasgn without LHS assignment Matlab incompatibility |
Date: |
Tue, 03 May 2011 14:41:32 +0000 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1 |
URL:
<http://savannah.gnu.org/bugs/?33221>
Summary: subsasgn without LHS assignment Matlab
incompatibility
Project: GNU Octave
Submitted by: None
Submitted on: Tue 03 May 2011 02:41:31 PM UTC
Category: None
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Other
Status: None
Assigned to: None
Originator Name: Jochen Weber
Originator Email: address@hidden
Open/Closed: Open
Discussion Lock: Any
Release: 3.4.0
Operating System: Mac OS
_______________________________________________________
Details:
**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):
r = randn(4, 4);
subsasgn(r, struct('type', '()', 'subs', {{2, 2}}), 0);
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:
r = zeros(256, 256, 256, 4); % 0.5GByte of double 0's
subsasgn(r, struct('type', '()', 'subs', {{2, 2}}), 1); % instantaneous
r = subsasgn(r, struct('type', '()', 'subs', {{2, 2}}), 2); % creating a copy
of r, assign in copy, then replace r with copy
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
r = zeros(256, 256, 256, 4);
r(2, 2) = 1;
is instantaneous, which is a little "inconsistent", I guess...
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?33221>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Octave-bug-tracker] [bug #33221] subsasgn without LHS assignment Matlab incompatibility,
anonymous <=