comp.lang.ada
 help / color / mirror / Atom feed
From: Tucker Taft <stt@averstar.com>
Subject: Re: Modular type (Re: Large numbers)
Date: Thu, 15 Mar 2001 11:24:40 -0500
Date: 2001-03-15T16:24:41+00:00	[thread overview]
Message-ID: <3AB0ECC8.3680464C@averstar.com> (raw)
In-Reply-To: slrn9b18tc.dqq.georg@apal.ii.uib.no

Hans Georg Schaathun wrote:
> 
> On 15 Mar 2001 11:58:58 +0100, Florian Weimer
>   <fw@deneb.enyo.de> wrote:
> : If you want to calculate the inverse of $x \in (\Z/n\Z)^\times$,
> : you  can use that $x^{\phi(n)}$ equals $1$, so you need only
> : $O(\log \phi (n))$ operations.
> 
> Ooops, sure.  Sorry, I should have thought of that by myself.  Thx.
> 
> :                                (To calculate $\phi(n)$, you need the
> : factorization of $n$, which is quite expensive, but needed only once).
> 
> Usually rather simple for prime numbers though, and I only want
> prime moduli :-)
> 
> : > Is it in any way possible to choose the modulus for a modular type
> : > runtime, e.g. by parameter to the program?
> :
> : No, there isn't.  The modulus has to be a static expression (which is
> : a stronger requirement then a compile-time constant).
> 
> I wonder why this is necessary.  Is there an efficiency gain from using
> built-in modular type compared to defining ones own modular type
> with a run-time parameter as modulus?  (Assuming prime modulus.)

If you want to deal with a dynamic modulus, you could use mod 2**32 types
and the explicit "mod" operator (for moduli < 2**16).  If your compiler
supports mod 2**64 types, then you could handle dynamic moduli up to
2**32, of course.

In retrospect, it does seem that the language could have allowed
a run-time modulus.  I suppose we were reluctant to define a new
kind of scalar type whose base range was not static.  The base range
is static for all others.

As far as division, it is clearly not the normal modular division,
but that is not particularly well defined for non-prime moduli,
so it wasn't really an option.

> :-- Hans Georg
> --
> Signature en panne.

-- 
-Tucker Taft   stt@avercom.net   http://www.averstar.com/~stt/
Chief Technology Officer, AverCom Corporation (A Titan Company) 
Burlington, MA  USA (AverCom was formerly the Commercial Division of AverStar:
http://www.averstar.com/services/ebusiness_applications.html)



  reply	other threads:[~2001-03-15 16:24 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   ` Modular type (Re: Large numbers) Hans Georg Schaathun
2001-03-15 10:58     ` Florian Weimer
2001-03-15 11:12       ` Hans Georg Schaathun
2001-03-15 16:24         ` Tucker Taft [this message]
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