bdezonia/zorbage

Support Gaussian integer types and algebras

bdezonia opened this issue · 9 comments

The GDAL standard supports complex valued types made of two 16-bit shorts or two 32-bit ints. My GDAL reader translates these (widened) as complex floating point numbers. Maybe we should define Gaussian integers made of byte/short/int/long/BigInteger components (and gaussian numbers using rational components) and associated algebras for manipulating them. The GDAL reader could use them (if that is what GDAL means them to be). More research is needed here.

The following link has some good info on the kind of operations a Gaussian algebra would need to support.

https://brilliant.org/wiki/gaussian-integers/

Here is another good resource about gaussian integer algebras:

https://www.maths.tcd.ie/pub/Maths/Courseware/NumberTheory/GaussianIntegers.pdf

I did a little more research on gaussian integers. One thing I learned is that gaussian integers are not just a commutative ring but also an integral domain. And gaussian numbers (components == rationals) are a field.

I have added a gaussian integer classes for the full range of native integral types. I have not done gaussian numbers (with rational components). I also have not checked my implementations versus all of the above mentioned docs. Revisit this later. For now it was good enough to work with the zorbage-gdal package.

One thing I've left unimplemented is figuring out multiples and primes and possible divisions

Gcd and lcm should be possible and I don't know if I've done anything with it yet.

Also isEven() and isOdd() might be possible. Investigate.

Some of the things I mentioned above (is even, is odd, gcd, lcm) are things supported by the IntegralDivision interface in the algebra hierarchy. I think Gaussian Integers should support this interface provided division is always well-defined and the concept of even and odd make sense.

Some other sources imply gaussian integers are a principal ideal domain and/or a unique factorization domain. I made the code into princ ideal domains. But the domain actually may be a euclidean domain and euclidean ring. For those the Norm<U,U> definition is problematic since GaussianIntegers kind of have a Norm<U,V> approach. More investigation needed.

I have implemented a handful of gaussian integer classes. There may be more I could implement (from the linked sources above). But for now I am going to consider this ticket complete. Released in zorbage 1.7.0.