comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Removing equal elements from an array
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Removing equal elements from an array [message #49828 is a reply to message #49761] Thu, 17 August 2006 10:59 Go to previous messageGo to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Thu, 17 Aug 2006 10:07:59 -0600, R.G. Stockwell wrote:

>
> "Julio" <julio@cpa.unicamp.br> wrote in message
> news:1155653196.084429.65000@74g2000cwt.googlegroups.com...
>> [quoted text muted]
>
> If I follow you correctly, you want to find unique pairs of numbers right?
> How about combining the pairs into one number, and running uniq() on that?
>
> For instance:
>
> A = fltarr(2,4)
> A[0,*]=[20.4, 40.3, 50.2, 50.2]
> A[1,*]=[30.2, 60.2, 32.4, 32.4]
> combo = A[0,*]*1000 + A[1,*]
> indices = UNIQ(combo, SORT(combo))

This method is so deceptively simple that it really seems like it should
work, and sometimes it does, but it doesn't, in general, for floating
point numbers, even if they fall in the proper range. I gave a similar
example before, but it's worth repeating:

[.2,10] => combo=210
[.1,110] => combo=210
[.15,60] => combo=210

or what about:

[5.5,5.5] => combo= 5505.5
[5.2,305.] => combo= 5505.5

The only sure fire way to map a given pair of numbers over a finite range
to a single unique combination, is to scale them to integers, then offset
one set entirely from the other (64bit integers are nice for this). For
small sets of numbers you might not run into this form of collision, but
for many numbers, it's quite likely you would.

JD
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: quickly reassign numbers in large array?
Next Topic: Re: Changing the Dec labeling from horizontal to vertical

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 17:48:08 PDT 2025

Total time taken to generate the page: 0.88082 seconds