[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #55622] for loop does not run over a matrix wi
From: |
John W. Eaton |
Subject: |
[Octave-bug-tracker] [bug #55622] for loop does not run over a matrix with colums but no row |
Date: |
Mon, 11 Feb 2019 11:17:42 -0500 (EST) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0 |
Update of bug #55622 (project octave):
Status: Wont Fix => Patch Submitted
Open/Closed: Closed => Open
_______________________________________________________
Follow-up Comment #12:
I disagree.
The for loop in Matlab is documented to loop over the columns of a matrix.
When indexing an N-d array as a matrix, Matlab joins the columns from all
dimensions as if they were one. Octave also does this re-dimensioning when
evaluating an N-d array in a for loop command. The behavior is only different
when the leading dimension is the only zero dimension.
For example, if you have an array like x = ones (2,3,4), you can write x(:,1),
x(:,2), ..., x(:,12) to index all the columns. This behavior is consistent
for zero-sized arrays. If you have x = ones (0,3,4), you can perform the same
indexing. Only when one or more of the dimensions beyond the first is zero do
you have no columns to index in the re-dimensioned array. By not looping when
only the first dimension equal to zero, we are less compatible with Matlab and
inconsistent with other array indexing.
We've already copied the weirder part of for N-d array for loops, which is to
always assign the re-dimensioned value to the loop index even when there are
zero trips through the loop.
I believe the attached change makes the behavior compatible.
(file #46234)
_______________________________________________________
Additional Item Attachment:
File name: loop-iteration-diffs.txt Size:1 KB
<https://savannah.gnu.org/file/loop-iteration-diffs.txt?file_id=46234>
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?55622>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #55622] for loop does not run over a matrix with colums but no row, (continued)
- [Octave-bug-tracker] [bug #55622] for loop does not run over a matrix with colums but no row, Marco Caliari, 2019/02/01
- [Octave-bug-tracker] [bug #55622] for loop does not run over a matrix with colums but no row, Rik, 2019/02/01
- [Octave-bug-tracker] [bug #55622] for loop does not run over a matrix with colums but no row, Mike Miller, 2019/02/01
- [Octave-bug-tracker] [bug #55622] for loop does not run over a matrix with colums but no row, Rik, 2019/02/01
- [Octave-bug-tracker] [bug #55622] for loop does not run over a matrix with colums but no row, John W. Eaton, 2019/02/01
- [Octave-bug-tracker] [bug #55622] for loop does not run over a matrix with colums but no row, Rik, 2019/02/01
- [Octave-bug-tracker] [bug #55622] for loop does not run over a matrix with colums but no row, John W. Eaton, 2019/02/02
- [Octave-bug-tracker] [bug #55622] for loop does not run over a matrix with colums but no row, Rik, 2019/02/02
- [Octave-bug-tracker] [bug #55622] for loop does not run over a matrix with colums but no row, Rik, 2019/02/10
- [Octave-bug-tracker] [bug #55622] for loop does not run over a matrix with colums but no row, Mike Miller, 2019/02/11
- [Octave-bug-tracker] [bug #55622] for loop does not run over a matrix with colums but no row,
John W. Eaton <=
- [Octave-bug-tracker] [bug #55622] for loop does not run over a matrix with colums but no row, Rik, 2019/02/14
- [Octave-bug-tracker] [bug #55622] for loop does not run over a matrix with colums but no row, anonymous, 2019/02/14
- [Octave-bug-tracker] [bug #55622] for loop does not run over a matrix with colums but no row, Rik, 2019/02/15
- [Octave-bug-tracker] [bug #55622] for loop does not run over a matrix with colums but no row, Marco Caliari, 2019/02/16
- [Octave-bug-tracker] [bug #55622] for loop does not run over a matrix with colums but no row, anonymous, 2019/02/16