[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: uniq function?
From: |
Daniel Heiserer |
Subject: |
Re: uniq function? |
Date: |
Tue, 03 Nov 1998 10:15:15 +0100 |
> > Hi,
> > is there a unique function similar to unix' unique.
> >
> > Assume I have a vector whichs elements are sorted.
> > I want to kick out every element which is twice.
> >
> > a=[1 1 1 2 3 4 5 6 6 6 6];
> > b=unique(a)
> > >> b=[1 2 3 4 5 6]
> >
> >
> Dear Daniel,
>
> b = intersection(a,a)
>
> will do it!
Well intersection bases on create_set as far as I have seen.
Here a little benchmark between "create_set" and "unique".
Unique is a factor 70 faster!!!!
octave:3> a=1:1000000;
octave:4> b=[a,a];
octave:5> b=sort(b);
octave:6> tic;c=unique(b);toc
ans = 11
octave:7> tic;d=create_set(b);toc
ans = 721
octave:8> e=find(c-d)
e = [](0x0)
octave:9>
Mit freundlichen Gruessen
Daniel Heiserer
-----
--------------------------------------------------------------
Dipl.-Pys. Daniel Heiserer, BMW AG, Knorrstrasse 147, 80788 Muenchen
Abteilung EK-20
Tel.: 089-382-21187, Fax.: 089-382-42820
mailto:address@hidden
- uniq function?, Daniel Heiserer, 1998/11/03
- Re: uniq function?,
Daniel Heiserer <=