bugGNU Octave - Bugs: bug #45293, Inconsistent behaviour when...

 
 

bug #45293: Inconsistent behaviour when appending to empty matrices

Submitter:  Alexander Klein <matalex>
Submitted:  Wed 10 Jun 2015 11:26:35 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Wont Fix Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 08 Jun 2019 02:55:24 AM UTC, comment #3: 

I ran all of the sample code in Matlab and the results are identical to Octave.  The behavior may be unexpected, but it is compatible, and so we won't change it.

I think for Matlab compatiblity all dimensions greater than 2 are singleton (i.e., 1).  Hence, x(:,:,end+1) refers to x(:,:,1+1) = x(:,:,2).  However, the first two dimensions--rows and columns--can be 0 so end+1 in that case just equals 1.

Marking as "Won't Fix" and closing report.


Rik <rik5>
Group administrator
Thu 29 Dec 2016 09:29:07 PM UTC, comment #2: 

This behavior is still the same in Octave 4.2.0.

Hartmut <hardy>
Wed 10 Jun 2015 02:12:25 PM UTC, comment #1: 

Thanks for your bug report. Confirmed on the current stable and development versions as well.

To summarize, the "end" magic index seems to not work on higher empty dimensions. All of your examples where c is empty and "end" is used in the first or second dimension, "end+1" is exactly the same as "1". But in the third dimension, "end+1" implicitly creates a zero-element first page and assigns ones to a second page.

Mike Miller <mtmiller>
Group Member
Wed 10 Jun 2015 11:26:35 AM UTC, original submission:  

The other day I discovered that Octave's behaviour when appending to empty fields depends on the dimensionality of what is appended and the dimension you append to, see the final example below, which is completely different from what happens above it.

If this is intended behaviour, then maybe some warning should be issued!


octave:74> c=[];c(end+1)=1
c =  1
octave:75> c=[];c(end+1,:)=ones(1,2)
c =

   1   1

octave:76> c=[];c(:,end+1)=ones(2,1)
c =

   1
   1

octave:77> c=[];c(end+1,:,:)=ones(2)
c =

ans(:,:,1) =

   1   1

ans(:,:,2) =

   1   1

octave:78> c=[];c(:,:,end+1)=ones(2)
c =

ans(:,:,1) =

   0   0
   0   0

ans(:,:,2) =

   1   1
   1   1


Alexander Klein <matalex>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by hardy (Posted a comment)
  • -email is unavailable- added by matalex (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-06-08 mtmiller Carbon-CopyRemoved 80942 -
    2019-06-08 rik5 Item GroupIncorrect Result Matlab Compatibility
        StatusConfirmed Wont Fix
        Open/ClosedOpen Closed
    2015-06-10 mtmiller CategoryOctave Function Interpreter
    2015-06-10 mtmiller StatusNone Confirmed
        Release3.8.2 dev

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code