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

Home » Public Forums » archive » Speeding up xy distance calculations using complex numbers
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: Speeding up xy distance calculations using complex numbers [message #84535 is a reply to message #84296] Mon, 20 May 2013 04:02 Go to previous messageGo to previous message
Lajos Foldy is currently offline  Lajos Foldy
Messages: 176
Registered: December 2011
Senior Member
On Saturday, May 18, 2013 11:16:53 AM UTC+2, kagol...@lbl.gov wrote:
>
> distance_squared = z1 * conj(z1)
>

distance_squared is complex, it should be REAL_PART(z1 * conj(z1)), or calculate distance with ABS(z1).(ABS is better, try z1=complex(1e20,1e20))

Also, x^2 can be replaced with x*x:

tmp1=x-p[0]
tmp2=y-p[1]
distance_squared = tmp1*tmp1+tmp2*tmp2

This is the fastest on my machine.

regards,
Lajos
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Calculating streamfunction from wind components
Next Topic: Re: Rescaling byte (0-200) ndvi to -1 to 1 values

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

Current Time: Fri Oct 10 20:19:07 PDT 2025

Total time taken to generate the page: 1.24203 seconds