comp.lang.ada
 help / color / mirror / Atom feed
From: Keith Thompson <kst@cts.com>
Subject: Re: Large numbers (or is Ada the choice for me?)
Date: 09 Mar 2001 17:42:35 -0800
Date: 2001-03-09T17:42:35-08:00	[thread overview]
Message-ID: <yec1ys6o0vo.fsf@king.cts.com> (raw)
In-Reply-To: slrn9ai9uk.iv9.georg@apal.ii.uib.no

georg@ii.uib.no (Hans Georg Schaathun) writes:
> I need a tool to solve large systems of linear equations, with no
> floating point operations (or any other approximations) allowed.
> Even though I am not a seasoned programmer, I think I'll have to
> write the tool myself.
> 
> My question is, will it be reasonably simple to handle large
> rational numbers with Ada?  Is there any packages for this?
> 
> Does basic Ada (gnat) support (f.ex.) 2048-bit integers?  Does
> any module exist for integers of dynamic size?  Are these
> handled reasonably efficiently, or is there much overhead?
> 
> I guess I will manage to implement the rational numbers without
> too much hardship, but I really don't feel like implementing
> arithmetics on large integers.

I believe Gnat includes an arbitrary-precision rational number
package; it needs it at compilation time to handle the rather
stringent language rules for compile-time expressions.

For a good time, try compiling

    Kaboom : constant := (1.0 + 1.0e-10) ** 1.0e10;

The result should be a good approximation to e, but the compiler's
front end will almost certainly run out of memory trying to evaluate
the expression.  Don't try this if your operating doesn't cope well
with memory hogs.  If your own application does this kind of thing,
either in general or only for certain matrices, you may be in trouble.

Anyway, since Gnat is GPL'ed, you can grab pieces of it and use them
in your own code (with the usual restrictions).  It may even provide
the package as part of the runtime library.  Look for something like
"Universal_Arithmetic".

... Ah, found it.  See packages Uintp (universal integer arithmetic)
and Urealp (universal real arithmetic).  Figuring out how to use them
is left as an exercise.

-- 
Keith Thompson (The_Other_Keith) kst@cts.com  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center           <*>  <http://www.sdsc.edu/~kst>
MAKE MONEY FAST!!  DON'T FEED IT!!



  parent reply	other threads:[~2001-03-10  1:42 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
2001-03-10  1:42 ` Keith Thompson [this message]
2001-03-19 20:48 ` Large numbers (or is Ada the choice for me?) 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