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

Home » Public Forums » archive » Finding strings values common to two (large!) arrays
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: Finding strings values common to two (large!) arrays [message #92213 is a reply to message #92210] Thu, 29 October 2015 15:47 Go to previous message
Dick Jackson is currently offline  Dick Jackson
Messages: 347
Registered: August 1998
Senior Member
On Thursday, 29 October 2015 11:17:26 UTC-7, Jeremy Bailin wrote:
> On Wednesday, October 28, 2015 at 5:53:32 PM UTC-4, Dick Jackson wrote:
>> On Wednesday, 28 October 2015 14:48:13 UTC-7, Dick Jackson wrote:
>>> On Wednesday, 28 October 2015 12:26:30 UTC-7, rrya...@gmail.com wrote:
>>>> Yeah, I learned that trick from your posts on Fanning's webpage. It's been a revelation. But i still don't like the structure of:
>>>>
>>>> id = id[uniq(id,sort(id))]
>>>>
>>>> i wish uniq just had a built-in flag to do this for me... Under what circumstance would I want to *NOT* sort? Seems like if they just built uniq to sort by default, you could probably optimize this at the compiler level --- though I'm hardly an expert...
>>>>
>>>> id = id[uniq(id)] ;would be nice or just
>>>>
>>>> -R
>>>
>>> As of IDL 8.4, you can now do this:
>>>
>>> IDL> a = [6, 2, 8, 3, 1, 8, 5, 3] ; (first digits of tau)
>>> IDL> a.uniq()
>>> 1 2 3 5 6 8
>>>
>>> Reference: IDL_Variable::Uniq
>>> http://www.exelisvis.com/docs/IDL_Variable.html#Uniq
>>
>> ... and to put a finer point on it, this method assumes the elements need to be sorted. In the case where they are already sorted (where sorting time can thus be saved, which is the default with the regular uniq() function), you can use:
>> a.uniq(/no_sort)
>>
>> Cheers,
>> -Dick
>>
>> Dick Jackson Software Consulting Inc.
>> Victoria, BC, Canada --- http://www.d-jackson.com
>
> Actually, there is a use case for running uniq intentionally without sorting, which I have used before: identifying duplications (similar to times you might use label_region).
>
> IDL> q = [3,5,3,3,8,7,7]
> IDL> q[uniq(q)]
> 3 5 3 8 7
>
> -Jeremy.

One thing that can come around to bite you is how Uniq() comes around:

IDL> q = [3,5,3,3,8,7,7,3] ; duplicates on each end...
IDL> q[uniq(q)] ; are considered adjacent with Uniq() unsorted...
3 5 3 8 7
IDL> q.uniq(/no_sort) ; but not by IDL_Variable::Uniq(/NO_SORT)
3 5 3 8 7 3

Cheers,
-Dick

Dick Jackson Software Consulting Inc.
Victoria, BC, Canada --- http://www.d-jackson.com
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: point on an image()
Next Topic: Histogram within a colorbar

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

Current Time: Wed Oct 08 14:00:31 PDT 2025

Total time taken to generate the page: 0.00444 seconds