gcd problem / really bignums for exponents



 In some CAS, the design for polynomials is to store a polynomial of degree
d as a dense vector of length d+1 coefficients.  For such a system it will
be pretty much impossible to store a polynomial whose degree will be a
bignum (larger than 2^32 or so).  So it might be OK to make such a
calculation into an error condition.
So one solution would be to do the arithmetic really fast, but then check
that the result of adding two positive fixnums is a fixnum that is larger
than either of them. If so, continue computing. If not, politely signal that
the user should do something else.

While one can presumably invent a calculation requiring a polynomial of huge
degree, it is not going to happen very often, and to slow down all
polynomial calculations because of some weird supposition is unattractive.
Assuming we can catch the potential error without much cost.

(let ((n (f+ x y)) (and (>= n x)(>= n y) n))    or something like that.

> -----Original Message-----
> From: maxima-bounces at math.utexas.edu 
> [mailto:maxima-bounces at math.utexas.edu] On Behalf Of Raymond Toy
> Sent: Wednesday, February 28, 2007 6:31 AM
> To: maxima at math.utexas.edu
> Subject: Re: [Maxima] gcd problem / really bignums for exponents
> 
> >>>>> "Raymond" == Raymond Toy <raymond.toy at ericsson.com> writes:
> 
>     Raymond> The f+ macro is (the fixnum (+ (the fixnum x) 
> (the fixnum y))).
>     Raymond> Without high speed or low safety, cmucl and sbcl 
> will still check that
>     Raymond> everything is a fixnum.  I think gcl just 
> believes the code, and hence
>     Raymond> produces the "wrong" answer when x or y or the 
> result is not a fixnum.
> 
> FWIW, I tested gcl with
> 
> (defun foo (x y)
>   (declare (optimize (safety 3)))
>   (the fixnum (+ (the fixnum x) (the fixnum y))))
> 
> (foo x y) produces the wrong answer if x and y are bigger than
> fixnums.  The safety setting doesn't have an affect.
> 
> Moral:  Don't lie to the compiler.
> 
> Ray
> 
> 
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>