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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,69bb03cc695b330a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-03-17 01:38:52 PST Path: nntp.stanford.edu!newsfeed.stanford.edu!news.tele.dk!129.240.148.23!uio.no!nntp.uib.no!georg From: georg@ii.uib.no (Hans Georg Schaathun) Newsgroups: comp.lang.ada Subject: Modular type (Re: Large numbers) Date: 15 Mar 2001 08:33:24 GMT Organization: University of Bergen Message-ID: References: <3AA95244.94BAD60D@averstar.com> NNTP-Posting-Host: apal.ii.uib.no X-Trace: toralf.uib.no 984645204 54623 129.177.16.7 (15 Mar 2001 08:33:24 GMT) X-Complaints-To: abuse@uib.no NNTP-Posting-Date: 15 Mar 2001 08:33:24 GMT User-Agent: slrn/0.9.5.6 [hacked] (UNIX) Xref: nntp.stanford.edu comp.lang.ada:91471 Date: 2001-03-15T08:33:24+00:00 List-Id: On Fri, 09 Mar 2001 16:59:32 -0500, Tucker Taft wrote: : My friends in "experimental mathematics" (sounds like fun, eh?) generally : prefer to use arbitrary-precision packages based on the Chinese : remainder theorem, because that allows large multiplications to : be performed very efficiently. Essentially a number is represented : by its value modulo a series of prime numbers, typically those just : less than 2**31. Multiplication can then be done by : multiplying the individual "digits" independently. A few dozen "digits" : is usually enough to handle some very large numbers. Great hint; I should have thought of this before. Thank you. But it raises two more questions. 1) Division. If I remember correctly, that is NP-hard; though that does not really matter since our numbers are bounded to 32 bits. I was rather disappointed to see that Ada does division completely wrong (it would be better not to do it at all). What is the best way to do division? A linear search for the inverse requires 2*10^9 multiplications, which is about as many as required for all the rest of the problem. Is this really the preferred algorithm? 2) Dynamic modulus. Is it in any way possible to choose the modulus for a modular type runtime, e.g. by parameter to the program? Or must a dozen mod-types be defined with hardcoded modulus? (Barring of course, the possibility to define modular types from scratch.) :-- Hans Georg -- Signature en panne.