Opened 13 years ago

Closed 13 years ago

#4988 closed defect (fixed)

[with patch, with positive review] major easy-to-fix but STUPID bug in gcd

Reported by: was Owned by: was
Priority: major Milestone: sage-3.3
Component: number theory Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

This is stupid:

sage: gcd(3,6,2)
3

The problem is that there is an undocumented mysterious and not even used integer third input!

File:        /Users/was/s/local/lib/python2.5/site-packages/sage/rings/arith.py
Type:        <type 'function'>
Definition:  gcd(a, b, integer, **kwargs)
Docstring: 

    The greatest common divisor of a and b, or if a is a list and b is
    omitted the greatest common divisor of all elements of a.

    INPUT:
        a,b -- two elements of a ring with gcd
    or
        a -- a list or tuple of elements of a ring with gcd

    Additional keyword arguments are passed to the respectively called
    methods.

    EXAMPLES:
        sage: GCD(97,100)
        1
        sage: GCD(97*10^15, 19^20*97^2)
        97
        sage: GCD(2/3, 4/3)
        2/3
        sage: GCD([2,4,6,8])
        2
        sage: GCD(srange(0,10000,10))  # fast  !!
        10

This caused me a ton of confusion just now.

Attachments (1)

trac_4988.patch (2.0 KB) - added by cremona 13 years ago.

Download all attachments as: .zip

Change History (4)

Changed 13 years ago by cremona

comment:1 Changed 13 years ago by cremona

  • Summary changed from major easy-to-fix but STUPID bug in gcd to [with patch, needs review] major easy-to-fix but STUPID bug in gcd

Patch attached. I deleted the now redundant integer parameter (which once was used to tell the function to use integer-specific code and is now redundant). I added a relevant doctest and some more so hopefully William's confusion will never again occur (in someone else, I mean ;)). I discovered some places which still had "integer=True" in gcd calls and fixed those. I tested all rings/ and used search_src() to find any other places where "integer=True" might have been used, and found that search_src("integer=True") runs for ever while producing no output.

comment:2 Changed 13 years ago by ncalexan

  • Summary changed from [with patch, needs review] major easy-to-fix but STUPID bug in gcd to [with patch, with positive review] major easy-to-fix but STUPID bug in gcd

Fine by me.

comment:3 Changed 13 years ago by mabshoff

  • Resolution set to fixed
  • Status changed from new to closed

Merged in Sage 3.3.alpha1

Note: See TracTickets for help on using tickets.