Hi, On 27 May 2011 21:08, Chris Smith <smi...@gmail.com> wrote:
> Aaron S. Meurer wrote: > >> Shouldn't it return 1? > > The quote I posted takes the approach that the divisor is the number that > divides both and still gives an integer, so our gcd and current primitive > method (soon to be changed) is consistent with that notion. > > >>> R=Rational;gcd(R(2,3),R(4,9)) > 2/9 > > The primitive function in polys doesn't advertise (and doesn't do) a > removal of the gcd...it should clearly state that, I think, or be changed to > do so. I will have to defer to those that know what primitive is suppose to > mean. > For long time I wasn't convinced what gcd(p/q, P/Q) should return and the safest was to return 1. Some libraries, e.g. gmpy, don't define gcd() of rationals at all. However, following other symbolic mathematics systems it seems useful to define gcd(p/q, P/Q) as gcd(p, P)/lcm(q, Q) because this way we can clear denominators when dividing by the gcd and core diverged from polys. As I recall, the implementation of gcd() in core was done upon request. To make core and polys behave the same way, I submitted a pull request: https://github.com/sympy/sympy/pull/379 in which I changed behavior of gcd() and lcm() in Field. As expected (by myself), no tests failed other than those testing the old behavior. > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To post to this group, send email to sympy@googlegroups.com. > To unsubscribe from this group, send email to > sympy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sympy?hl=en. > > Mateusz -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com. To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.