bugGNU Octave - Bugs: bug #35247, intersect.m for matrices with...

 
 

bug #35247: intersect.m for matrices with 'rows' argument errors out with more than 1 output argument and more columns than rows

Submitted by:  None
Submitted on:  Thu 05 Jan 2012 02:42:58 PM UTC  
 
Category: LibrariesSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: Jordi Gutiérrez Hermoso <jordigh>
Originator Name: Liesbeth JanssenOriginator Email: -unavailable-
Open/Closed: ClosedRelease: dev
Operating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Thu 05 Jan 2012 03:28:44 PM UTC, comment #2:

This seems to fix the problem for me:

http://hg.savannah.gnu.org/hgweb/octave/rev/402acc45350e

It will go on the stable release scheduled for this week.

Jordi Gutiérrez Hermoso <jordigh>
Project AdministratorIn charge of this item.
Thu 05 Jan 2012 03:01:06 PM UTC, comment #1:

Confirmed. This isn't a problem about compatibility with Matlab. It's simply a bug in the logic that didn't account for one edge case. I'm investigating.

Jordi Gutiérrez Hermoso <jordigh>
Project AdministratorIn charge of this item.
Thu 05 Jan 2012 02:42:58 PM UTC, original submission:

For two matrices A and B with the same number of columns, the Matlab function [C,IA,IB] = intersect(A,B,'rows') returns the index vectors IA and IB such that C = A(IA) and C = B(IB). This holds regardless of the number of rows or columns.

Example from Matlab:

>> A=rand(3,4); B=A;
>> [C,IA,IB] = intersect(A,B,'rows')


C =

0.6787 0.3922 0.7060 0.0462
0.7431 0.1712 0.2769 0.8235
0.7577 0.6555 0.0318 0.0971

IA =

1
3
2

IB =

1
3
2

In Octave, however, the intersect function gives an error when requesting more than 1 output argument. The problem appears only when THE NUMBER OF ROWS IS SMALLER THAN THE NUMBER OF COLUMNS. Example:

octave:1> A=rand(3,4); B=A;
octave:2> [C] = intersect(A,B,'rows')
C =

0.180418 0.768069 0.697431 0.823813
0.663449 0.725690 0.470303 0.266596
0.922315 0.395967 0.434297 0.019502

octave:3>
octave:3> [C,IA] = intersect(A,B,'rows')
error: subscript indices must be either positive integers or logicals.
error: called from:
error: /usr/share/octave/3.2.3/m/set/intersect.m at line 76, column 4
octave:3>
octave:3> [C,IA,IB] = intersect(A,B,'rows')
error: subscript indices must be either positive integers or logicals.
error: called from:
error: /usr/share/octave/3.2.3/m/set/intersect.m at line 76, column 4

If the number of rows is LARGER than the number of columns, the intersect function seems to works fine in Octave:

octave:4> A=rand(5,4); B=A;
octave:5> [C,IA,IB] = intersect(A,B,'rows')
C =

0.109814 0.137919 0.947014 0.558020
0.118984 0.778847 0.442949 0.063836
0.373961 0.867630 0.912788 0.841257
0.390284 0.406292 0.661324 0.075581
0.764201 0.560298 0.594685 0.023296

IA =

1
4
5
3
2

IB =

1
4
5
3
2

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 jordigh (Posted a comment)
  • -unavailable- added by None (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 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 05 Jan 2012 03:28:44 PM UTCjordighStatusNone=>Fixed
      Open/ClosedOpen=>Closed
      Summaryintersect.m for matrices with \'rows\' argument gives error; cannot handle more than 1 output argument =>intersect.m for matrices with 'rows' argument errors out with more than 1 output argument and more columns than rows
    Thu 05 Jan 2012 03:01:06 PM UTCjordighItem GroupMatlab Compatibility=>Incorrect Result
      Assigned toNone=>jordigh
      Release3.2.3=>dev

    Back to the top


    Powered by Savane 3.1-cleanup1