I have not taken the time to read this whole thread, but here goes anyway: The distinction is between ideals of Q (which are of course only (0) and (1)) and sub-Z-modules of Q, a.k.a. fractional ideals (since in the generalization to number fields K we (ab)use the terminology "ideal of K" to mean "fractional ideal of K" which is the same as "OK_submodule of K (of maximal rank)".
Every f.g. Z-submodule of Q is cyclic, and instead of the current behaviour of gcd(x,y) for rationals (which is to give the generator of the Q-ideal generated by x and y) the old -- and perhaps desired -- behaviour is to give the generator of the Z-module generated by x and y. The latter is, of course, unique up to sign. It's the same as Simon's generator of the sum of the Z-submodules generated by x and by y. And then lcm(x,y) is the genrator of their intersection. This way, both gcd(x,y) and lcm(x,y) are positive rationals (or 0 but not when x and y are nonzero). And we have gcd(x,y)*lcm(x,y) = abs(x*y) which I think is a better convention for when x and/or y are negative than deciding to make one of the gcd and the lcm negative. John On Thu, Feb 10, 2011 at 10:01 AM, William Stein <wst...@gmail.com> wrote: > On Thu, Feb 10, 2011 at 9:55 AM, William Stein <wst...@gmail.com> wrote: >> [... gcd stuff ...] > > It seems like nobody explained how the current gcd definition got > included. It's from a patch to rational.pyx from Alex Ghitza (who I > cc'd) that did this: > > - d = self.denom()*other.denom() > - self_d = self.numer()*other.denom() > - other_d = other.numer()*self.denom() > - return self_d.gcd(other_d) / d > + if self == 0 and other == 0: > + return Rational(0) > + else: > + return Rational(1) > > > This was from trac 3214 "uniformise the behaviour of gcd for rational > numbers": > > http://trac.sagemath.org/sage_trac/ticket/3214 > > which was reported by Andrey Novoseltsev. > > So if Andrey or Alex cared so much, they may want to pipe up. > > This thread is at least: > > > http://groups.google.com/group/sage-devel/browse_thread/thread/cd05585cf395b3a0/160c549d6bdc8867#160c549d6bdc8867 > > William > > -- > To post to this group, send an email to sage-devel@googlegroups.com > To unsubscribe from this group, send an email to > sage-devel+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/sage-devel > URL: http://www.sagemath.org > -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org