[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Vectorization question
- Subject: Vectorization question
- From: "Liam E. Gumley" <Liam.Gumley(at)ssec.wisc.edu>
- Date: Mon, 11 Sep 2000 16:51:01 -0500
- Newsgroups: comp.lang.idl-pvwave
- Organization: Space Science and Engineering Center, UW-Madison
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:21360
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