Karim Belabas on Thu, 27 Dec 2007 00:15:10 +0100

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

 Re: "exponent (expo) overflow"

```* Alessandro Languasco [2007-12-26 11:52]:
> I'm writing a GP script in which I have to compute a quite large
> power of a matrix. This is fine until I use the exponent L<=2^(23)
> but for larger L>=2^(24) I have a
>
> *** for: exponent (expo) overflow
>
> (which in fact is not too surprising; the exponent is quite large....).
> But I really need to use larger exponents.
>
> Do you know if is it possible to solve this problem ?
> Maybe some default() instruction could be used in this situation,
> but I don't know if it is possible and how to do this.

The allowed range of exponents is hard-coded into the t_REAL representation:
BITS_IN_LONG - 2 bits are used to code the exponent, and one of them is a sign.

So the simplest solution to your problem is to use a 64bit machine for
your computation. (Assuming you won't need exponents larger than 2^61.)

Another possibility is to split your computation and renormalize your matrix
(say divide it by 2^N for some suitable N) after each part of the
computation.

Another is to do the computation in a completely different way, but I'll
need more details ( is the matrix diagonalizable ? If not, perhaps a
suitable power of A^t A might suit you just as well ? )

Cheers,

K.B.
--
Karim Belabas                  Tel: (+33) (0)5 40 00 26 17
IMB, Universite Bordeaux 1     Fax: (+33) (0)5 40 00 69 50
351, cours de la Liberation    http://www.math.u-bordeaux.fr/~belabas/
F-33405 Talence (France)       http://pari.math.u-bordeaux.fr/  [PARI/GP]

```