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

Home » Public Forums » archive » To reduce an n^2 problem
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
To reduce an n^2 problem [message #91940] Mon, 21 September 2015 14:55 Go to previous message
simulana is currently offline  simulana
Messages: 15
Registered: August 2012
Junior Member
Let's say I have a gravitational potential problem in 2D array (or any Poisson problem), where the potential at each cell is determined by the sum of the contributions of all other cells, of the form m/r. This is naturally an n^2 problem, with a simple solution requiring a for loop over each cell and determining the distances from every other cell and then the sum of their contributions.

First question - has anyone ever done this using IDL? I know that multigrid solvers and FFT solvers have been written into many other languages to solve this problem. But, it seems like a direct solution could be obtained using IDL's array capabilities (a la distance_measure). What remains is serious indexing trouble, either with mapping the distance_measure results back to a 2D array (since it must be correlated to density), or if you skip distance_measure altogether and just attempt to make an (nx,ny,nx*ny) array for all of the distances.

Second question - even if you haven't done this in IDL, here is a thought experiment. Would using IDL arrays actually reduce this problem below n^2?

Thanks for your time.
[Message index]
 
Read Message
Read Message
Previous Topic: Bug in mapped polygon objects?
Next Topic: READ A IMAGE

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

Current Time: Wed Oct 08 15:59:06 PDT 2025

Total time taken to generate the page: 0.00424 seconds