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

Home » Public Forums » archive » Vectorization question
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Vectorization question [message #21705] Mon, 11 September 2000 14:51 Go to previous message
Liam E. Gumley is currently offline  Liam E. Gumley
Messages: 378
Registered: January 2000
Senior Member
Given the following arrays

a = intarr(10)
x = [2, 2, 2, 3, 3, 4]
b = [1, 3, 4, 2, 1, 8]

How would I vectorize the following operation

for i = 0, n_elements(x) - 1 do a[x[i]] = a[x[i]] + b[i]

To achieve this result

print, a, format='(10i4)'
0 0 8 3 8 0 0 0 0 0

In the real-world case where this occurs, I need to repeat this kind of
operation several hundred times, where the size of 'a' is around
1,000,000 and the size of 'x' is around 100,000 ('a' and 'b' are float
type in the real-world case).

Many thanks for any suggestions.

Cheers,
Liam.
http://cimss.ssec.wisc.edu/~gumley
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Spherical gridding at a pole
Next Topic: Re: CW_BGROUP

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

Current Time: Wed Oct 08 15:34:12 PDT 2025

Total time taken to generate the page: 0.00371 seconds