Re: Loop question [message #20398] |
Mon, 19 June 2000 00:00 |
promashkin
Messages: 169 Registered: December 1999
|
Senior Member |
|
|
Hello Kyle,
Maybe the following will work for you:
samples=256
temp_arr=FLTARR(samples)
data_arr=FLTARR(5000)
ind_arr=LONG(LINDGEN(1000)*0.256)
key_arr = [0, where(ind_arr - shift(ind_arr, 1) eq 1)]
temp_arr = data_arr[key_arr]
This will work with the way of filling of IND_ARR that you provided. In
the given example, it also looks to me that temp_arr can never receive
any values subsequent to data_arr[999].
Cheers,
Pavel
"R. Kyle Justice" wrote:
>
> Can the following FOR loop be vectorized?
>
> samples=256
> temp_arr=FLTARR(samples)
> data_arr=FLTARR(5000)
> ind_arr=LONG(LINDGEN(1000)*0.256)
>
> FOR j=0L,samples-1 DO BEGIN
> temp_ind=WHERE(j EQ ind_arr)
> temp_arr(j)=data_arr(temp_ind(0))
> ENDFOR
>
> Kyle J.
|
|
|