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

Home » Public Forums » archive » Re: accelerate processing time
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: accelerate processing time [message #49271] Mon, 10 July 2006 10:29
Jean[1] is currently offline  Jean[1]
Messages: 8
Registered: November 2005
Junior Member
Hi,

I would try something like this, to reduce the load:
1) get your central point coordinates
x_coord = 12.2
y_coord = 5.4

2) find all the points from the x and y arrays that MAY be within your
"radio" distance

possiblesPoints = where(x eq x_coord + radio or x eq x_coord - radio or
y eq y_coord + radio or y eq y_coord - radio)

3) from this set of points, compute your distance in one step.

sqDistance = (x_coord - x[possiblesPoints])^2 + (y_coord -
y[possiblesPoints])^2

4) select the proper distance

goodDistance = where(sqDistance LE radio^2)

5) retreive the coordinates

neighborsX = x[possiblesPoints[goodDistance]]
neighborsY = y[possiblesPoints[goodDistance]]


Jean H.

m.goullant@gmail.com wrote:
> Hi all,
> I'm a newbie in IDL and in programming. I have the following question:
>
> I have an irregular point cloud (X,Y,Z), and i must calculate the
> euclidean distances several times because I need to do some iterations
> to get the final results:
>
> radio=mask /2
>
> FOR i=0L,N_ELEMENTS(z)-1 DO BEGIN
>
> distances=sqrt((x-x[i])^2+(y-y[i])^2) ; Euclidean distances
> neighbors=WHERE(distances LE radio)
>
> ENDFOR
>
> If I have 2 million floating points, with several iterations, the
> computing time will be very tedious.
>
> Can anyone advice me in a solution for this!
>
> Thank you! Best regards,
> Marie
>
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: accelerate processing time
Next Topic: Greetings from Wimbledon

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

Current Time: Wed Oct 08 13:39:39 PDT 2025

Total time taken to generate the page: 0.00539 seconds