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

Home » Public Forums » archive » Re: Cleaver 2d reverse indicies?
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: Cleaver 2d reverse indicies? [message #63310 is a reply to message #63308] Mon, 03 November 2008 13:15 Go to previous message
Chris[6] is currently offline  Chris[6]
Messages: 84
Registered: July 2008
Member
> bins_mean = fltarr(size(nd, /dim))
> nx = (size(nd, /dim))[0]
> ny = (size(nd, /dim))[1]
> FOR i = 0UL, nx-1 DO BEGIN
>    FOR j = 0UL, ny-1 DO BEGIN
>       ind_ri = [i+nx*j]
>       IF ri[ind_ri] EQ ri[ind_ri+1] THEN CONTINUE ; nothing to do in
> this iteration
>       ri_sel = ri[ri[ind_ri]:ri[ind_ri+1]-1]
>       bins_mean[i, j] = mean(pxxm(ri_sel), /nan)
>    ENDFOR
> ENDFOR

Well, it seems like you can definitely eliminated the nested loop:

FOR i = 0UL, nx * ny - 1, DO BEGIN
if ri[i] eq ri[i+1] then continue ; nothing to do here
ri_sel = ri[ri[i] : ri[i+1] - 1]
bins_mean[( i mod nx), (i / nx)] = mean(pxxm(ri_sel),/nan)
endfor

I've always wondered if there is a way to eliminated the first loop
when using reverse indices, but haven't thought of / seen a way to
yet.

chris
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL hilbert() function
Next Topic: google code search

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

Current Time: Sun Nov 30 20:25:08 PST 2025

Total time taken to generate the page: 0.48440 seconds