[PATCH] Negative exponent fix, Complex modulo feature

From: Squeak <squeak_at_xirr.com>
Date: Fri, 4 Jun 1999 11:40:03 -0400 (EDT)

The negative exponent bug is triggered by any x^y where y is a literal
negative integer. It is caused by forgetting a minus sign and having the C
compiler change a signed number to a very large unsigned number.

The complex modulo patch simply adds the modulo operation on gaussian
integers.

I am having trouble getting the mpw_gcd function to work on complexes. It
often gives the right answer, but often doesn't. The algorithm is sound,
but my implementation must be stepping on some assumption. I read the
code, doesn't mean I think the code.

At any rate this gel function works as a substitute:

function gcd(a,b) = if(a%b) then gcd(b,a%b) else b

The patches can be used simply by being in the genius-0.4.3 directory and
patch -p1 -i negexp.diff -l

or they can be executed (they are self-extracting).

If george is interested I can send my mpw_gcd modifications, but it has
odd errors (like gcd(54,9i)=6i but gcd(9i,54)=3i which is correct).

TODO: Make the result of the modulo somehow canonical. Right now it just
spits out one of the four true answers based on the quirks of the round
function.

For those who don't want to alter the source but want the all the benefits
of my second patch:

function complex_mod(p,q) = floor(p - q*floor(p/q))

The outside floor is neccessary because all literal imaginaries are
treated as floating point values (before my patch).

Hope someone finds this useful.

-Jack

Received on Fri Jun 04 1999 - 08:14:17 CDT

This archive was generated by hypermail 2.2.0 : Sun Apr 17 2011 - 21:00:02 CDT