Hi, On 11 July 2013 10:17, Stephen Loo <[email protected]> wrote:
> Hi all, > > I found that there are many different kind of gcd in sympy different > module, such as > > sympy.core.numbers.igcd > sympy.polys.polytools.gcd > sympy.polys.polytools.gcdex > sympy.polys.polytools.gcd_list > sympy.polys.polytools.half_gcdex > > And the new one > sympy.solvers.diophantine.extended_euclid > > They calculate integer gcd or polynomial gcd. I suggest to make single > public function call, like gamma, put in integer argument and return > integer, put in polynomial argument and return polynomial. And gcd function > should not limit to 2 integer only, for example, gcd(10, 15, 20) = 5 > > Any idea? Any suggestion? > First of all, functions gcdex() and half_gcdex() don't count because they implement extended Euclidean algorithm. I didn't know about extended_euclid(). It seems redundant. igcd() is a specialized function that works only with integers and is needed internally to reduce overhead that gcd() function has. The function you would like to have is gcd(). It works with numbers, polynomials and whatever that has a gcd() method. It either takes two arguments (plus symbols and options in polynomial case) or one iterable (plus symbols and options in polynomial case). The iterable case is equivalent to calling gcd_list() explicitly (that's why there is gcd_list()). Currently it isn't possible to support gcd(1, 2, 3, 4, 5) syntax, because that effectively means (in the current API) compute GCD of 1 and 2 which are polynomials in 3, 4, 5 (treated as symbols) in the default coefficient domain (which is integer ring). In the integer case this limitation could be relaxed easily, but then the API would be inconsistent, because gcd(x, y, z) would still mean GCD of polynomials x and y in z (x*z**0, y*z**0) (over ZZ[x, y]). > Thanks. > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sympy. > For more options, visit https://groups.google.com/groups/opt_out. > > > Mateusz -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out.
