octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #45389] nd-array indexing with less subscripts


From: Amro
Subject: [Octave-bug-tracker] [bug #45389] nd-array indexing with less subscripts than dimensions
Date: Wed, 24 Jun 2015 08:22:21 +0000
User-agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0

URL:
  <http://savannah.gnu.org/bugs/?45389>

                 Summary: nd-array indexing with less subscripts than
dimensions
                 Project: GNU Octave
            Submitted by: amro_octave
            Submitted on: Wed 24 Jun 2015 11:22:20 AM EEST
                Category: Interpreter
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.0.0
        Operating System: Any

    _______________________________________________________

Details:

Consider the example below.

First we run it in MATLAB R2015a:


>> x=ones(2,2,2)
x(:,:,1) =
     1     1
     1     1
x(:,:,2) =
     1     1
     1     1

>> x(1,3)=5
x(:,:,1) =
     1     1
     1     1
x(:,:,2) =
     5     1
     1     1

>> x(3,1)=7
x(:,:,1) =
     1     1
     1     1
     7     0
x(:,:,2) =
     5     1
     1     1
     0     0


Next we try it in Octave 4.0.0:


> x=ones(2,2,2)
x =

ans(:,:,1) =

   1   1
   1   1

ans(:,:,2) =

   1   1
   1   1

>> x(1,3)=5
x =

ans(:,:,1) =

   1   1
   1   1

ans(:,:,2) =

   5   1
   1   1

>> x(3,1)=7
error: Invalid resizing operation or ambiguous assignment to an out-of-bounds
array element


----

What's interesting is that on other cases, both MATLAB and Octave throw an
error:


>> x=ones(2,2,2);
>> x(9)=9
Attempt to grow array  along ambiguous dimension. 
>> x(1,9)=9
Attempt to grow array  along ambiguous dimension. 
>> x(9,9)=9
Attempt to grow array  along ambiguous dimension.



>> x=ones(2,2,2);
>> x(9)=9
error: Invalid resizing operation or ambiguous assignment to an out-of-bounds
array element
>> x(1,9)=9
error: Invalid resizing operation or ambiguous assignment to an out-of-bounds
array element
>> x(9,1)=9
error: Invalid resizing operation or ambiguous assignment to an out-of-bounds
array element






    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?45389>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]