[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #50776] Octave logical indexing inconsistent w
From: |
Richard |
Subject: |
[Octave-bug-tracker] [bug #50776] Octave logical indexing inconsistent with Matlab |
Date: |
Mon, 10 Apr 2017 06:12:46 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/53.0.2785.143 Chrome/53.0.2785.143 Safari/537.36 |
URL:
<http://savannah.gnu.org/bugs/?50776>
Summary: Octave logical indexing inconsistent with Matlab
Project: GNU Octave
Submitted by: crobar
Submitted on: Mon 10 Apr 2017 10:12:45 AM UTC
Category: Interpreter
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Matlab Compatibility
Status: None
Assigned to: None
Originator Name: Richard Crozier
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: dev
Operating System: GNU/Linux
_______________________________________________________
Details:
Octave does not use the same rules for doing logical indexing on vectors as
Matlab in terms of the shape of the output. In Matlab the rule seems to be:
for vectors, return always the same shape of vector being indexed, for
anything else return a column vector
For example, in Matlab:
>> a = reshape (1:3, 1,1,3)
a(:,:,1) =
1.0000e+000
a(:,:,2) =
2.0000e+000
a(:,:,3) =
3.0000e+000
>> b = true(1,3)
b =
1×3 logical array
1 1 1
>> a(b)
ans(:,:,1) =
1.0000e+000
ans(:,:,2) =
2.0000e+000
ans(:,:,3) =
3.0000e+000
>> size (a(b))
ans =
1.0000e+000 1.0000e+000 3.0000e+000
In Octave:
octave:15> a = reshape (1:3, 1,1,3)
a =
ans(:,:,1) = 1
ans(:,:,2) = 2
ans(:,:,3) = 3
octave:16> b = true(1,3)
b =
1 1 1
octave:17> a(b)
ans =
1 2 3
octave:18> size(a(b))
ans =
1 3
This is using a dev version of Octave, but from quite a while ago, but I've
even deleted the repo clone I built it from, so I can't give hg id:
octave:19> ver
----------------------------------------------------------------------
GNU Octave Version: 4.1.0+
GNU Octave License: GNU General Public License
Operating System: Linux 4.4.0-34-generic #53~14.04.1-Ubuntu SMP Wed Jul 27
16:56:40 UTC 2016 x86_64
----------------------------------------------------------------------
Package Name | Version | Installation directory
--------------+---------+-----------------------
control | 2.8.1 | /home/rcrozier/octave/control-2.8.1
odepkg *| 0.8.5 | /home/rcrozier/octave/odepkg-0.8.5
signal | 1.3.2 | /home/rcrozier/octave/signal-1.3.2
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?50776>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #50776] Octave logical indexing inconsistent with Matlab,
Richard <=
- [Octave-bug-tracker] [bug #50776] Octave inconsistent with Matlab for corner indexing case, Rik, 2017/04/11
- [Octave-bug-tracker] [bug #50776] Octave inconsistent with Matlab for corner indexing case, John W. Eaton, 2017/04/11
- [Octave-bug-tracker] [bug #50776] Octave inconsistent with Matlab for corner indexing case, Rik, 2017/04/11
- [Octave-bug-tracker] [bug #50776] Octave inconsistent with Matlab for corner indexing case, Richard, 2017/04/12
- [Octave-bug-tracker] [bug #50776] Octave inconsistent with Matlab for corner indexing case, Richard, 2017/04/12
- [Octave-bug-tracker] [bug #50776] Octave inconsistent with Matlab for corner indexing case, John W. Eaton, 2017/04/12
- [Octave-bug-tracker] [bug #50776] Octave inconsistent with Matlab for corner indexing case, John W. Eaton, 2017/04/12
- [Octave-bug-tracker] [bug #50776] Octave inconsistent with Matlab for corner indexing case, Rik, 2017/04/12
- [Octave-bug-tracker] [bug #50776] Octave inconsistent with Matlab for corner indexing case, John W. Eaton, 2017/04/12
- [Octave-bug-tracker] [bug #50776] Octave inconsistent with Matlab for corner indexing case, Rik, 2017/04/12