bugGNU Octave - Bugs: bug #56692, S_IDX output of ismember is...

 
 

bug #56692: S_IDX output of ismember is equivalent to Matlab output with "legacy" option

Submitter:  Rik <rik5>
Submitted:  Mon 29 Jul 2019 04:42:09 AM UTC
   
 
Category:  Octave Function Severity:  2 - Minor
Priority:  1 - Later Item Group:  Matlab Compatibility
Status:  Duplicate Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 29 Jul 2019 09:30:06 PM UTC, comment #2: 

Yes it is.  I've copied over the information from this report.  Marking this as a duplicate and closing.


Rik <rik5>
Group administrator
Mon 29 Jul 2019 09:02:05 PM UTC, comment #1: 

Is this a duplicate of bug #55659?

Mike Miller <mtmiller>
Group Member
Mon 29 Jul 2019 04:42:09 AM UTC, original submission:  

For the following code, Matlab returns [0, 0, 2, 1]


A = [5 3 4 2];
B = [2 4 4 4 6 8];
[~,ib] = ismember(A,B)
ib = [0, 0, 2, 1]


Octave, however, returns [0, 0, 4, 1].

The same result can be had in Matlab if the "legacy" option is used with ismember (which uses the algorithm from Matlab versions prior to 2012b).

The difference is that when there are repeated, non-unique values in the set B, Matlab returns the index of the first occurrence while Octave returns the index of the last occurrence.

Debugging further in the ismember.m file, it is the call to lookup() which returns the last index rather than the first index.

Changing lookup is a lot of work, and likely to have other consequences.

The problem could be worked around in the ismember.m file by sorting the input set in descending order before calling lookup() and then returning


s_idx(tf) = (numel (tf) + 1) - is(s_idx(tf));


But, all of the manipulation seems like a lot of work just to get Matlab compatibility on indices which still work for indexing.

Rik <rik5>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Digest:
   bug dependencies.

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-07-29 rik5 StatusConfirmed Duplicate
        Open/ClosedOpen Closed
    2019-07-29 rik5 Dependencies- Depends on bugs #55659
    2019-07-29 rik5 SummarySecond output of ismember (S_IDX) is equivalent to &quot;legacy&quot; output in Matlab S_IDX output of ismember is equivalent to Matlab output with "legacy" option
    2019-07-29 rik5 Priority5 - Normal 1 - Later
        StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code