bugGNU Octave - Bugs: bug #52437, Second output of ismember is wrong...

 
 

bug #52437: Second output of ismember is wrong for complex input

Submitted by:  Luis Mendo <lmendo>
Submitted on:  Fri 17 Nov 2017 10:43:57 PM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Regression
Status: ConfirmedAssigned to: None
Originator Name: Luis MendoOpen/Closed: Open
Release: 4.2.0Operating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat 18 Nov 2017 06:24:06 PM UTC, comment #4:

A possible patch to the reimplemented version is to add something like this at the beginning:

That is, if complex inputs are detected, replace values in the inputs by globally unique integer labels. By "globally unique" I mean unique across the two inputs. That way the lookup function will work fine.

Luis Mendo <lmendo>
Sat 18 Nov 2017 04:56:02 PM UTC, comment #3:

Thanks.

Note that the linked version before the reimplementation gives an error on logical inputs. Matlab and Octave's reimplemented version work with logical inputs.

So in addition to regression, something like this could be added at the beginning of ismember:

Also, Matlab's and Octave's reimplemented ismember are happy to compare inputs of different numeric type, as long as one of them is double in Matlab, or in any case in Octave. Replacing the following line in ismember (version before the reimplementation)

by

seems enough.

Luis Mendo <lmendo>
Sat 18 Nov 2017 06:34:56 AM UTC, comment #2:

Apparently this cset http://hg.octave.org/octave/rev/dbc61d4e428d broke ismember for complex input.

Before the "reimplementation" ismember returned [1 2 3], you can try with this http://hg.octave.org/octave/raw-file/0c4e6a3d6e3e/scripts/set/ismember.m

mark as regression

Andreas Weber <andy1978>
Project Member
Sat 18 Nov 2017 01:09:11 AM UTC, comment #1:

To clarify: ismember apparently was "reimplemented using lookup and unique" (as indicated by the first comment I quoted, taken from its source code). And lookup doesn't handle complex values properly (as indicated by the second comment I quoted, taken from its source code).

Luis Mendo <lmendo>
Fri 17 Nov 2017 10:43:57 PM UTC, original submission:

This code

gives [3 3 3] instead of the expected [1 2 3].

The problem seems to be that 'ismember' uses the 'lookup' function, which was

and 'lookup' has the comment

Well, it may not be meaningful for lookup's original purpose, but it definitely is for ismember.

It looks like ismember's second output should be obtained with something other than lookup, at least in the complex case

Luis Mendo <lmendo>

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by andy1978 (Posted a comment)
  • -unavailable- added by lmendo (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 18 Nov 2017 06:34:56 AM UTCandy1978Item GroupIncorrect Result=>Regression
      StatusNone=>Confirmed

    Back to the top


    Powered by Savane 3.1-cleanup1