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 17:03:21 +0000
User-agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0

Follow-up Comment #2, bug #45389 (project octave):

Thank you for the response Rik.

I filed this as a possible MATLAB compatibility issue. I admit it's an edge
case, but I only stumbled across it by mistake. I assure you I don't usually
write code that bad :)

As for trying to explain the MATLAB behavior, it seems to me there is some
logic behind it. Consider this:


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


it effectively reflows the array into a 2-by-(2*2) matrix, similar to doing
"reshape".

I think my previous example is interpreted in a similar way, where "x(3,1)"
implies reshaping into a 2D matrix, and then indexing into that result. In
this case the array is grown in size since we're indexing out of bound.

In the second example with "x(1,9)", MATLAB threw an error because it is not
clear which original dimension it should grow (2nd or 3rd?), at least that's
the way I explain it...

Anyway, as you said, this can be easily avoided by writing correct and clear
code in the first place :) I just wanted to document the difference.


    _______________________________________________________

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]