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

 
 

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

Submitter:  None
Submitted:  Wed 04 Mar 2015 05:11:45 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  nno Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 4.0.0
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group administrator
Sat 21 Mar 2015 01:23:59 AM UTC, comment #5: 
Rik <rik5>
Group 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>
Group 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>
Group 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.


    ## Adjust output orientation for Matlab compatibility
    if (! by_rows && ! iscol)
      c = c.';
    endif


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>
Group 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?


size(intersect([1 2],[1;2]), 'legacy')
size(intersect([1;2],[1 2]), 'legacy')


Rik <rik5>
Group 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 Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by avinoam (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  •  

    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
    2015-06-02 jwe Release4.0.0-rc1 4.0.0
    2015-03-21 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2015-03-07 rik5 StatusNone 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.13-d3ae.
    Corresponding source code