Deleting multiple points: UniqueRows

August 7, 2009 by Luigi Giaccari 
Filed under: Algorithms, Numerical Analysis 
Leave a Comment
VN:F [1.8.1_1037]
Rating: 0 (from 0 votes)
VN:F [1.8.1_1037]
Rating: 0.0/10 (0 votes cast)

The native unique works using the sortrows algorithm which can be very slow for large models.

Sometimes we need to avoid passing multiple values to functions that do not support those.
In most of these cases we are pretty sure that there are no multiple values but we use unique to be completly sure. If actually there are no multiple values, it is a waste of time to call sortrows.

This what UniqueRows does, it checks if there is a chance to find multiple values and in the worst case pass to sortrows only candidates that can generate a multiple values.

Here is an example on 10^6 3D points randomly generated. Of course it is very rare to find multiple values in random doubles numbers.

X=rand(10^6,3);

tic
output=unique(X,'rows');%native unique
toc

tic
output=UniqueRows(X);%UniqueRows
toc

Output:

Elapsed time is 1.313679 seconds.
Elapsed time is 0.374713 seconds.

If any problems occurs in execution, or if you found a bug, have a suggestion or question just contact me at:

giaccariluigi@msn.com

Download Now

VN:F [1.8.1_1037]
Rating: 0.0/10 (0 votes cast)
VN:F [1.8.1_1037]
Rating: 0 (from 0 votes)

Popularity: 17% [?]

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
  • Live
  • PDF
  • Technorati
  • Twitter
  • Yahoo! Bookmarks
  • Add to favorites
  • email
  • MySpace
  • RSS

Related Posts

  • No Related Post

Comments

Tell me what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!


Include MATLAB code in your comment by doing the following:

<pre lang="MATLAB">

%insert code here

</pre>