#9819: Add a default gcd and lcm methods for fields
---------------------------+------------------------------------------------
   Reporter:  lftabera     |          Owner:  AlexGhitza                    
       Type:  enhancement  |         Status:  positive_review               
   Priority:  major        |      Milestone:  sage-duplicate/invalid/wontfix
  Component:  algebra      |       Keywords:  lcm, gcd, fields              
Work_issues:               |       Upstream:  N/A                           
   Reviewer:               |         Author:  Luis Felipe Taberea           
     Merged:               |   Dependencies:                                
---------------------------+------------------------------------------------
Changes (by mstreng):

  * status:  needs_review => positive_review


Old description:

> 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/<ipython console> in <module>()
>
> /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.

New description:

 '''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/<ipython console> in <module>()

 /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.

--

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9819#comment:8>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to