comp.lang.ada
 help / color / mirror / Atom feed
* [OT] Hints for an algorithm - avoiding O(n^2)
@ 2004-03-12  9:15 Jano
  2004-03-12 11:06 ` Jean-Pierre Rosen
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Jano @ 2004-03-12  9:15 UTC (permalink / raw)


Sorry for the off-topic, but this is the only group I read frequently
that I'm sure is packed with knowledgeable people.

The problem is a simple one: I'm planning to write a simulator of
sideral-like objects using the Newton laws (precision is not a top
priority). The obvious way is to compute the force interactions
between each pair of objects, sum them all, and iterate over... but
this is O(n^2). To be precise, there are n(n-1)/2 forces to be
computed if I'm right (n the number of objects).

I was wondering if you know of another approach more efficient. A
simple hint is enough, I'll look further as necessary once in the
right path.

I'm having some thoughts about making a discrete division of the space
and compute the potential field, but the idea is not mature enough...
I'm not sure if the loss of precision will be too big, or if the
results will not be similar in time (I'm planning to manage about
1000-2000 objects simultaneously).

Thanks!

P.s: It will be programmed in Ada... just to ease the OT a bit :)



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2004-03-17  2:24 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-12  9:15 [OT] Hints for an algorithm - avoiding O(n^2) Jano
2004-03-12 11:06 ` Jean-Pierre Rosen
2004-03-12 12:53   ` Stuart Palin
2004-03-12 12:55   ` Stuart Palin
2004-03-12 13:48     ` Dmitry A. Kazakov
2004-03-17  1:16       ` jtg
2004-03-12 13:30   ` Björn Persson
2004-03-12 13:42     ` James Rogers
2004-03-12 14:29     ` Robert I. Eachus
2004-03-12 23:44       ` Björn Persson
2004-03-13 15:21         ` Robert I. Eachus
2004-03-14 17:27           ` Jano
2004-03-15  5:34             ` Robert I. Eachus
2004-03-14 17:27   ` Jano
2004-03-13  0:12 ` Wes Groleau
2004-03-17  2:24 ` jtg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox