Description
It took me several days to succeed with my trivial project of implementing a ring; I've taken the Gaussian integers as an example. Maybe we can link this somewhere so that others can be a bit quicker with their projects.
I noticed a few things:
-
The documentation of "canonical_unit" is not very clear. I think what we do/want is fixing a system P of representatives of non-associates in R, i.e. a system of representatives of ~ where f ~ g iff f=gu for some u. Then for given f, canonical_unit(f) should return u such that fu^-1 \in P (I think the u^-1 should match your conventions). For a field, you will take P={0,1}, and canonical_unit(f)=f for non-zero f. You should mention that you use this for example to get leading entries in P in the Hermite normal form.
-
There needs to be some explanation of uniqueness/non-uniqueness of the Hermite normal form etc. and how you can control this using the Euclidean ring interface. I think the whole (and only!) control comes from the implementation of divrem. This basically fixes functions r,q:R \times R \setminus { 0 } \to R such that x=q(x,y)*y + r(x,y) for all x,y with y non-zero. Now, in some cases this choice produces a canonical system of representatives of residues mod r \in R. Namely, if r(x,y) = r(x+wy, y) for all y \in R (I believe). This holds for example for the Z, K[X], Z[i] if I'm not mistaken. If this is not true, you may produce non-unique HNFs and have to do something additionally to make them unique.
-
In the documentation of "gcdx" I currently don't understand what is meant by "with s reduced modulo g and t reduced modulo f."