On Jan 28, 7:09 am, Konrad Hinsen <konrad.hin...@laposte.net> wrote:
> It is possible to generalize the Fast Multipole Method somewhat, but  
> it remains a technique for a limited (though important) class of  
> interactions. It is rather unlikely that it will be of any use for  
> simulating a flock of birds.

The FMM itself might not be directly applicable to simulating bird
flocking, but the general idea of the FMM and similar algorithms
(coalesce groups of far-away point forces into a single force) could
be helpful.

For the n^2 algorithm, it's mainly important to pay attention to data
locality.  Suppose for example that you keep the n 2-D coordinates of
the birds in an n x 2 array.  (OP is right, Java multi-D arrays are
awful for performance; map this n x 2 array onto a single-D Java
array.)  So you have

L =
x_1, y_1
x_2, y_2
...
x_n, y_n

Computing the distances is a kind of outer product.  For best locality
in L, you'll want to store it row-wise rather than column-wise.  That
way when you iterate over points you'll be traveling with unit stride
over L rather than skipping over it by n steps each time.

mfh
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to