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

Home » Public Forums » archive » Re: Avoiding a FOR loop in calculation of SPH potential energy
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: Avoiding a FOR loop in calculation of SPH potential energy [message #67092 is a reply to message #67086] Tue, 23 June 2009 00:29 Go to previous message
cody is currently offline  cody
Messages: 4
Registered: December 2002
Junior Member
i've been reading through this discussion group and one thing i see
often is that you can vectorize a FOR loop to avoid it. so my code
would be something like:

u = 1 + bytarr(pn)
dx = u#s.x
dy = u#s.y
dz = u#s.z
for i = 0L, pn-1 do dx[0, i] = dx[*, i] - s.x
for i = 0L, pn-1 do dy[0, i] = dy[*, i] - s.y
for i = 0L, pn-1 do dz[0, i] = dz[*, i] - s.z
d = sqrt(dx^2+dy^2+dz^2)
print,'calculated all ds?'

but i'm not able to allocate that much memory for 100k particles and i
wouldn't know how to do the proper potential energy calculation that
way either since not all particles are the same mass.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Catalyst CatDestroyDefaults
Next Topic: VALUE_LOCATE tutorial

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

Current Time: Wed Oct 08 19:29:55 PDT 2025

Total time taken to generate the page: 0.00436 seconds