octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #35247] intersect.m for matrices with 'rows' a


From: anonymous
Subject: [Octave-bug-tracker] [bug #35247] intersect.m for matrices with 'rows' argument gives error; cannot handle more than 1 output argument
Date: Thu, 05 Jan 2012 14:42:59 +0000
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101203 SUSE/3.6.13-0.1.1 Firefox/3.6.13

URL:
  <http://savannah.gnu.org/bugs/?35247>

                 Summary: intersect.m for matrices with 'rows' argument gives
error; cannot handle more than 1 output argument 
                 Project: GNU Octave
            Submitted by: None
            Submitted on: Thu 05 Jan 2012 02:42:58 PM UTC
                Category: Libraries
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: None
             Assigned to: None
         Originator Name: Liesbeth Janssen
        Originator Email: address@hidden
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 3.2.3
        Operating System: GNU/Linux

    _______________________________________________________

Details:

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





    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?35247>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]