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

Home » Public Forums » archive » Re: increment an array subset based on another subset
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: increment an array subset based on another subset [message #82405] Wed, 12 December 2012 07:36
havok2063 is currently offline  havok2063
Messages: 24
Registered: December 2012
Junior Member
On Tuesday, December 11, 2012 7:39:17 PM UTC-5, havo...@gmail.com wrote:
> I have a sorted list of ids and subsets they belong to:
>
>
>
> ids = [11, 21, 45, 50, 56, 416, 430]
>
>
>
> sub = [A, A, B, A, B, B, A]
>
>
>
> I want to increment the ids of A based on the number of elements in subset B that lie in front of it. So for example , the 4th element will get incremented by 1 (50+1) since 1 element of B is in front. The last element will get incremented by 3 (430+3) since 3 elements of B lie in front of it. The first 2 elements of A don't get incremented.
>
>
>
> I feel like the answer lies somewhere with where, total, or histogram, but the solution escapes me. Anyone have ideas?
>
>
>
> Thanks.

Excellent. Thanks a lot.
Re: increment an array subset based on another subset [message #82415 is a reply to message #82405] Tue, 11 December 2012 20:19 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Jeremy Bailin writes:

> increment = total(sub eq B, /cumulative, /int) * (sub eq A)
> ids += increment

Well, duh, I should have thought of that! ;-)

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: increment an array subset based on another subset [message #82416 is a reply to message #82415] Tue, 11 December 2012 17:51 Go to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On 12/11/12 6:39 PM, havok2063@gmail.com wrote:
>
> I have a sorted list of ids and subsets they belong to:
>
> ids = [11, 21, 45, 50, 56, 416, 430]
>
> sub = [A, A, B, A, B, B, A]
>
> I want to increment the ids of A based on the number of elements in subset B that lie in front of it. So for example , the 4th element will get incremented by 1 (50+1) since 1 element of B is in front. The last element will get incremented by 3 (430+3) since 3 elements of B lie in front of it. The first 2 elements of A don't get incremented.
>
> I feel like the answer lies somewhere with where, total, or histogram, but the solution escapes me. Anyone have ideas?
>
> Thanks.
>

increment = total(sub eq B, /cumulative, /int) * (sub eq A)
ids += increment

-Jeremy.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: I have a problem!
Next Topic: Re: Efficient sub array extraction

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

Current Time: Wed Oct 08 15:13:56 PDT 2025

Total time taken to generate the page: 0.00528 seconds