[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #61750] ismember does not report all matches
From: |
Nicholas Jankowski |
Subject: |
[Octave-bug-tracker] [bug #61750] ismember does not report all matches |
Date: |
Sat, 1 Jan 2022 14:11:46 -0500 (EST) |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 |
Follow-up Comment #5, bug #61750 (project octave):
reading the octave help, it does not specify that it should be the first
instance. but that is the matlab compatible option. the first output is a
logical array the same size as the first input (A), indicating whether that
input is present somewhere in the second input (B). the second output is an
integer array the same size as A, indicating location of each element of A in
B. For repeated occurrences in B, matlab returns the location of the first
occurrence. Haven't stepped through ismember yet to see why octave returns the
last instance in these cases.
So, the problematic case below:
>> [c,d]=ismember({'1'}, {'1', '2', '1'})
c = 1
d = 3
in order to be compatible should be:
>> [c,d]=ismember({'1'}, {'1', '2', '1'})
c = 1
d = 1
another example from the matlab help with which octave should try to be
compatible (see
https://www.mathworks.com/help/matlab/ref/double.ismember.html)
A = [5 3 4 2];
B = [2 4 4 4 6 8];
[Lia,Locb] = ismember(A,B)
Lia = 1x4 logical array
0 0 1 1
Locb = 1×4
0 0 2 1
which in octave currently produces:
A = [5 3 4 2];
B = [2 4 4 4 6 8];
[Lia,Locb] = ismember(A,B)
Lia =
0 0 1 1
Locb =
0 0 4 1
so you can see, something about the algorithm is finding the matches, but
returning the last instance. once it's corrected, improving the documentation
would be worthwhile as well.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?61750>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #61750] ismember does not report all matches, Philip Nienhuis, 2022/01/01
- [Octave-bug-tracker] [bug #61750] ismember does not report all matches, Nicholas Jankowski, 2022/01/01
- [Octave-bug-tracker] [bug #61750] ismember does not report all matches, Nicholas Jankowski, 2022/01/01
- [Octave-bug-tracker] [bug #61750] ismember does not report all matches, Nicholas Jankowski, 2022/01/01
- [Octave-bug-tracker] [bug #61750] ismember does not report all matches, Liang Tang, 2022/01/01
- [Octave-bug-tracker] [bug #61750] ismember does not report all matches,
Nicholas Jankowski <=
- [Octave-bug-tracker] [bug #61750] ismember does not report all matches, Arun Giridhar, 2022/01/01
- [Octave-bug-tracker] [bug #61750] ismember does not report all matches, Markus Mützel, 2022/01/02
- [Octave-bug-tracker] [bug #61750] ismember does not report all matches, Nicholas Jankowski, 2022/01/02
- [Octave-bug-tracker] [bug #61750] ismember follows matlab 'legacy' behavior, Nicholas Jankowski, 2022/01/02
- [Octave-bug-tracker] [bug #61750] ismember follows matlab 'legacy' behavior, Nicholas Jankowski, 2022/01/02
- [Octave-bug-tracker] [bug #61750] ismember follows matlab 'legacy' behavior, Markus Mützel, 2022/01/03