id,summary,reporter,owner,description,type,status,priority,milestone,component,resolution,keywords,cc,merged,author,reviewer,upstream,work_issues,branch,commit,dependencies,stopgaps
9819,Add a default gcd and lcm methods for fields,lftabera,AlexGhitza,"'''This ticket should be closed as fixed by #10771'''
For the case of field elements gcd and lcm methods are not of great interest. However, they can be addecuated for some reasons.
- Some algorithms may accept as input either polynomials or rational functions. In these algorithms we may reduce a list of polynomials and rational functions to a common denominator. If all the inputs are polynomials, the denominators are the one element of the base field. In this case, lcm would fail.
See #9063 for a case of this problem.
- Rational numbers already have custom gcd and lcm methods.
-It would erase the following problem. Currently, if we are dealing with elements in a finite field, the gcd of the elements can be computed sometimes coercing to the integers and doing computations. This lead to inconsistencies.
{{{
sage: a=F(2)
sage: gcd(a,a)
2
sage: gcd(a,p)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/luisfe/Varios/Comprobantes-gastos/ in ()
/opt/SAGE/sage-4.5.2/local/lib/python2.6/site-packages/sage/rings/arith.pyc in gcd(a, b, **kwargs)
1423 return ZZ(a).gcd(ZZ(b))
1424 except TypeError:
-> 1425 raise TypeError, ""unable to find gcd of %s and %s""%(a,b)
1426
1427 from sage.structure.sequence import Sequence
TypeError: unable to find gcd of 2 and p
}}}
I propose the following:
- For gcd, follow the convention of the rational cesa. If both elements are 0, return 0 (on the appropriate field). Otherwise return 1
- For lcm, if one of the elements is zero, return zero. Otherwise return 1.
#9063 depends on this bug to be merged.",enhancement,closed,major,sage-duplicate/invalid/wontfix,algebra,duplicate,"lcm, gcd, fields",,,,Marco Streng,N/A,,,,,