comp.lang.ada
 help / color / mirror / Atom feed
From: georg@ii.uib.no (Hans Georg Schaathun)
Subject: Modular type (Re: Large numbers)
Date: 15 Mar 2001 08:33:24 GMT
Date: 2001-03-15T08:33:24+00:00	[thread overview]
Message-ID: <slrn9b0vik.243.georg@apal.ii.uib.no> (raw)
In-Reply-To: 3AA95244.94BAD60D@averstar.com

On Fri, 09 Mar 2001 16:59:32 -0500, Tucker Taft
  <stt@averstar.com> 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.



  reply	other threads:[~2001-03-15  8:33 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-09 18:58 Large numbers (or is Ada the choice for me?) Hans Georg Schaathun
2001-03-09 19:35 ` Marin David Condic
2001-03-09 20:44   ` David Starner
2001-03-09 23:12     ` Marin David Condic
2001-03-10  2:56       ` David Starner
2001-03-10 11:37         ` Florian Weimer
2001-03-10  6:08       ` tmoran
2001-03-09 21:01   ` Randy Brukardt
2001-03-09 23:02   ` Robert A Duff
2001-03-09 23:28     ` Marin David Condic
2001-03-10 16:49       ` Hans Georg Schaathun
2001-03-10 11:59   ` Jeffrey Carter
2001-03-09 20:37 ` Brian Catlin
2001-03-09 21:26 ` JP Thornley
2001-03-09 21:59 ` Tucker Taft
2001-03-15  8:33   ` Hans Georg Schaathun [this message]
2001-03-15 10:58     ` Modular type (Re: Large numbers) Florian Weimer
2001-03-15 11:12       ` Hans Georg Schaathun
2001-03-15 16:24         ` Tucker Taft
2001-03-10  1:42 ` Large numbers (or is Ada the choice for me?) Keith Thompson
2001-03-19 20:48 ` Robert I. Eachus
2001-03-20  3:33   ` Brian Rogoff
replies disabled

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