[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #31287] Certain assignments of empty arrays gi
[Octave-bug-tracker] [bug #31287] Certain assignments of empty arrays give errors (Matlab incompatibility)
Mon, 03 Jan 2011 15:26:19 +0000
Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:126.96.36.199) Gecko/2010102906 Iceweasel/3.0.6 (Debian-3.0.6-3)
Follow-up Comment #10, bug #31287 (project octave):
Here is a corrected version of the deduced rules and an
attached testscript. The testscript ran without unforeseen
messages in Matlab 2009b, but I suggest that someone
verifies this, if possible with a more recent Matlab
Rules for empty assignment, deduced from Matlab version
Empty assignment here means an assignment:
lhs(idx) = rhs;
where 'lhs' is a variable, 'idx' are indices separated by
commas, and 'rhs' is some expression, and at least on
dimension of 'lhs(idx)' is zero and at least one dimension
of 'rhs' is zero.
'lhs(idx)' will be called 'i_lhs' in the following.
In the following, refering to dimensions means the
dimensions as returned by 'size()'.
Without explicitly mentioning it, all the following (only)
applies to empty assignment.
1. So called null-assignment, i.e. rhs is the constant 
Succeeds if idx contains at most 1 non-'special' index or
the second non-'special' index is preceded (at any
position before it) by an index being an empty numeric
array (see NOTEs below). 'Special' indices are:
1.1. a colon ':',
1.2. any empty numeric array,
1.3. a logical index of any length with all elements false
(called just 'logical index' in the following); but
with a logical index, there are the following
restrictions (see NOTEs below):
1.3.1. If lhs is more than 2-dimensional, and idx contains
more than 1 index, an index being a logical index
gives an error if no further index being an empty
numerical array is given.
1.3.2. idx can contain more than 1 logical index only if it
contains less than 3 indices or it contains at least
1 further index being an empty numerical array at
position 1 or 2.
1.3.3. If idx contains a logical index as well as a colon :,
assignment only succeeds if idx contains less than 3
indices or idx contains at least 1 further index
being an empty numeric array.
2. No null-assignment.
2.1. lhs <= 2-dimensional AND idx contains at most 2 indices
AND rhs <= 2-dimensional
Empty assignment always succeeds.
2.2. Cases not covered by 2.1.
Empty assignment succeeds if and only if all dimensions
!= 1 (i.e. 0 or >= 2) are in the same order in i_lhs
and rhs (which implies that there is the same number of
these non-singleton dimensions in i_lhs and rhs).
I.e. dimensions of 1 can be in arbitrary numbers and
positions in i_lhs and rhs.
NOTE to rule 1 in general: Since more than 1 non-'special'
index is allowed if the second is preceded by an index being
an empty numeric array, I'd say more than 1 non-'special'
index should be always allowed in empty assignment. So the
the testscript will mark messages due to more than 1
non-'special' index (not preceded by an index being an empty
array) as 'DISPUTABLE'.
NOTE to rule 1.3: I'm not sure that this rule is consistent
with all cases. Even if it should be, if no less bizarre
rule can be found, I'd suggest not to copy this behavior,
but to leave off the restrictions 1.3.1 to 1.3.3.. The
attached testscript will print a message marked 'DISPUTABLE'
if only the restrictions 1.3.1 -- 1.3.3 are violated.
Additional Item Attachment:
File name: testscript_bug_31287.m Size:4 KB
Reply to this item at:
Message sent via/by Savannah
- [Octave-bug-tracker] [bug #31287] Certain assignments of empty arrays give errors (Matlab incompatibility),
Olaf Till <=