From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,c212e60d58417232 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-03-12 04:05:13 PST Path: archiver1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!nnx.oleane.net!oleane!nnrp.oleane.net!skymaster!nobody From: "Jean-Pierre Rosen" Newsgroups: comp.lang.ada Subject: Re: [OT] Hints for an algorithm - avoiding O(n^2) Date: Fri, 12 Mar 2004 12:06:16 +0100 Organization: Adalog Message-ID: <7j5s2c.32r.ln@skymaster> References: <5d6fdb61.0403120115.7c102e3c@posting.google.com> NNTP-Posting-Host: mailhost.axlog.fr X-Trace: s1.read.news.oleane.net 1079092990 13808 195.25.228.57 (12 Mar 2004 12:03:10 GMT) X-Complaints-To: abuse@oleane.net NNTP-Posting-Date: Fri, 12 Mar 2004 12:03:10 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Xref: archiver1.google.com comp.lang.ada:6262 Date: 2004-03-12T12:06:16+01:00 List-Id: "Jano" <402450@cepsz.unizar.es> a �crit dans le message de news:5d6fdb61.0403120115.7c102e3c@posting.google.com... > 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). > If I remember my Newton laws correctly, you just need to compute the force between an object and the center of mass of all other objects. Hmmm.... not sure that it won't be O(n^2) still, but it might ease a bit. -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Visit Adalog's web site at http://www.adalog.fr