bugGNU Octave - Bugs: bug #44425, set functions (intersect, union,...

 
 

bug #44425: set functions (intersect, union, etc.) are in different shape than Matlab

Submitted by:  None
Submitted on:  Wed 04 Mar 2015 05:11:45 PM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: FixedAssigned to: None
Originator Name: nnoOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 4.0.0
Operating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

(Jump to the original submission Jump to the original submission)

Tue 02 Jun 2015 04:39:10 PM UTC, comment #6:

Retagging release from 4.0.0-rc1 to 4.0.0.

John W. Eaton <jwe>
Project Administrator
Sat 21 Mar 2015 01:23:59 AM UTC, comment #5:

Fixed in this cset (http://hg.savannah.gnu.org/hgweb/octave/rev/72ccbd36e23c).

Rik <rik5>
Project Administrator
Sat 07 Mar 2015 05:59:32 PM UTC, comment #4:

This is related to bug #42577 (setdiff output dimension inconsistency) which was fixed by following the rules derived there. Apparently those were incorrect.

This is a relatively easy fix because the code is just in m-files in the scripts/set directory. There is already provision to detect the orientation of the inputs and "correct" the output orientation. The documentation of each m-file needs to be updated as well to reflect that now column vectors are the preferred output.

This is a minor change so I don't have any issues checking in a fix before the 4.0 release as I don't think it will destabilize anything. But I don't have time to fix this right now myself.

Rik <rik5>
Project Administrator
Wed 04 Mar 2015 09:03:00 PM UTC, comment #3:

checking http://www.mathworks.com/help/matlab/release-notes.html,
in R2013a:

The shape of the output, C, from intersect, setxor, and union, when the 'rows' and 'legacy' flags are not specified, is as follows. C is column vector unless both A and B are row vectors, in which case C is a row vector.

Avinoam Kalma <avinoam>
Project Member
Wed 04 Mar 2015 05:33:17 PM UTC, comment #2:

Checking the m-file for intersect, I see that Octave specifically was implementing Matlab compatibility on the return size.

So we had to work hard to guarantee a row vector to match the documentation. Could you find out when Matlab changed their behavior by looking in their Release Notes? If this is a recent change Octave may need move slowly to avoid breaking existing code. If this happened a long time ago then maybe we can just invert the behavior from rows to columns before the 4.0 release.

Rik <rik5>
Project Administrator
Wed 04 Mar 2015 05:22:58 PM UTC, comment #1:

What version of Matlab are you using?

I'm pretty sure that Octave was forced into this behavior by earlier Matlab versions. What happens if you use the 'legacy' flag?

Rik <rik5>
Project Administrator
Wed 04 Mar 2015 05:11:45 PM UTC, original submission:

In Matlab,

size(intersect([1 2],[1;2]))
size(intersect([1;2],[12]))

both return [2 1], i.e. the result of intersect is a column vector.

Octave returns [1 2], i.e. the result a row vector.

Note that Octave's behaviour is consistent with the documentation (which states that for intersect(A<B), "If A and B are both column vectors return a column vector, otherwise return a row vector."), but is not compatible with Matlab. Matlab returns a column vector unless A and B are row vectors.

Anonymous

 

(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 jwe (Posted a comment)
  • -unavailable- added by avinoam (Posted a comment)
  • -unavailable- added by rik5 (Posted a comment)
  •  

    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 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 02 Jun 2015 04:39:10 PM UTCjweRelease4.0.0-rc1=>4.0.0
    Sat 21 Mar 2015 01:23:59 AM UTCrik5StatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Sat 07 Mar 2015 05:59:32 PM UTCrik5StatusNone=>Confirmed
      Release3.8.0=>4.0.0-rc1
      Summaryintersect results are in different shape than in Matlab=>set functions (intersect, union, etc.) are in different shape than Matlab

    Back to the top


    Powered by Savane 3.1-cleanup1