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

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

[Octave-bug-tracker] [bug #50776] Octave inconsistent with Matlab for co


From: Rik
Subject: [Octave-bug-tracker] [bug #50776] Octave inconsistent with Matlab for corner indexing case
Date: Tue, 11 Apr 2017 15:29:39 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0

Update of bug #50776 (project octave):

                  Status:                    None => Confirmed              
                 Summary: Octave logical indexing inconsistent with Matlab =>
Octave inconsistent with Matlab for corner indexing case

    _______________________________________________________

Follow-up Comment #1:

The issue is not so much logical/linear indexing, rather it is the
determination of what the indexed object is.

For indexing, where


S = scalar
V = vector
M = matrix

R = result



Case 1: scalar indexed with scalar, vector, matrix
S(S)
S(V)
S(M)

shape of result = shape of indexing S, V, M object.



Case 2: vector indexed with scalar, vector, matrix
V(S) = scalar (shape of indexing object)
V1(V2) = vector, BUT, retains shape of original object V1
V(M) = matrix (shape of indexing object)



Case 3: matrix indexed with scalar, vector, matrix
M(S)
M(V)
M(M)

shape of result = shape of indexing S, V, M object.


As you can see, there is only one odd case which is a vector indexed by a
vector.  Octave treats the 3-D example matrix as a matrix, which means the
resulting shape is the shape of the indexing object (a vector).


octave:3> x = reshape (1:3, 1,1,3)
x =

ans(:,:,1) =  1
ans(:,:,2) =  2
ans(:,:,3) =  3

octave:4> x([3 2 1])
ans =

   3   2   1

octave:5> x([3 2 1]')
ans =

   3
   2
   1



Notice how the output follows the orientation of the input as it should.  On
the other hand, Matlab seems to be treating the original matrix as a vector
and thus retaining the shape of the original object.  What does this return in
Matlab?


x = reshape (1:3, 1,1,3);
isvector (x)


My guess is that they are internally inconsistent and they don't think 'x' is
a vector, except for the odd case of indexing.




    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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