Possible bug in intersect
Carlo de Falco
carlo.defalco at gmail.com
Sat Apr 11 15:54:46 CDT 2009
On 11 Apr 2009, at 19:03, bug-octave-request at octave.org wrote:
> Message: 3
> Date: Sat, 11 Apr 2009 17:38:51 +0200
> From: Thomas Weber <thomas.weber.mail at gmail.com>
> Subject: Re: Possible bug in intersect
> To: Jaroslav Hajek <highegg at gmail.com>
> Cc: Massimiliano Culpo <misticoannoiato at yahoo.it>, bug at octave.org
> Message-ID: <20090411153851.GA16531 at atlan>
> Content-Type: text/plain; charset="us-ascii"
>
> On Sat, Apr 11, 2009 at 02:11:25PM +0200, Jaroslav Hajek wrote:
>> On Sat, Apr 11, 2009 at 12:26 PM, Massimiliano Culpo
>> <misticoannoiato at yahoo.it> wrote:
>>> Please find attached a possible bug occurring in octave-3.0.4.
>>> The same behavior is very likely to be found also in octave-3.0.5.
>>>
>>> Massimiliano Culpo
>>>
>>
>> I fixed this in the development sources.
>
> Test for this bug attached.
>
> Thomas
> -------------- next part --------------
> # HG changeset patch
> # User Thomas Weber <thomas.weber.mail at gmail.com>
> # Date 1239464264 -7200
> # Node ID 68036841138c9ef0365ff0f188f3edfee8eb8460
> # Parent 22ae6b3411a769d62f66f196473336440194404a
> Add test for bugfix b2459d21a207
>
> diff --git a/scripts/set/intersect.m b/scripts/set/intersect.m
> --- a/scripts/set/intersect.m
> +++ b/scripts/set/intersect.m
> @@ -104,3 +104,8 @@
> %! assert(ib,[3;1]);
> %! assert(a(ia,:),c);
> %! assert(b(ib,:),c);
> +%!test
> +%! a = [1 1 1 2 2 2];
> +%! b = [1 2 3; 4 5 6];
> +%! c = intersect(a,b);
> +%! assert(c, [1,2]);
>
> ------------------------------
This behaviour is not compatible:
---------
>> a = [1 1 1 2 2 2]
a =
1 1 1 2 2 2
>> b = [1 2 3; 3 2 1]
b =
1 2 3
3 2 1
>> intersect(a,b)
??? Error using ==> intersect at 51
A and B must be vectors, or 'rows' must be specified.
>> intersect(a,b,'rows')
??? Error using ==> intersect at 198
A and B must have the same number of columns.
>> version
ans =
7.5.0.338 (R2007b)
>>
---------
I would suggest to change the test to
---------
c = intersect(a,b(:));
assert(c, [1,2]);
---------
so that it won't fail if intersect gets changed to be strictly
compatible.
c.
More information about the Bug-octave
mailing list