Skip to content

Commit

Permalink
Trac #16781: Implementation of floordiv is incorrect for polynomials …
Browse files Browse the repository at this point in the history
…over finite fields

As reported on sage-devel, the following is incorrect:
{{{
sage: F = GF(47)
sage: x = polygen(F)
sage: u = F(1)
sage: x//u
0
}}}
since {{{x//u}}} should give the quotient after dividing x by u.

This is fixed by #2034, so this ticket just adds a doctest.

URL: http://trac.sagemath.org/16781
Reported by: cremona
Ticket author(s): Jeroen Demeyer
Reviewer(s): Vincent Delecroix
  • Loading branch information
Release Manager authored and vbraun committed Jan 23, 2016
2 parents f64d154 + bca94fc commit 78ce487
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/sage/rings/polynomial/polynomial_template.pxi
@@ -1,11 +1,15 @@
"""
Polynomial Template for C/C++ Library Interfaces
"""

#*****************************************************************************
# Copyright (C) 2008 Martin Albrecht <M.R.Albrecht@rhul.ac.uk>
# Copyright (C) 2008 Robert Bradshaw
#
# Distributed under the terms of the GNU General Public License (GPL)
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************

Expand Down Expand Up @@ -410,13 +414,25 @@ cdef class Polynomial_template(Polynomial):

cpdef RingElement _floordiv_(self, RingElement right):
"""
EXAMPLE::
EXAMPLES::
sage: P.<x> = GF(2)[]
sage: x//(x + 1)
1
sage: (x + 1)//x
1
sage: F = GF(47)
sage: R.<x> = F[]
sage: x // 1
x
sage: x // F(1)
x
sage: 1 // x
0
sage: parent(x // 1)
Univariate Polynomial Ring in x over Finite Field of size 47
sage: parent(1 // x)
Univariate Polynomial Ring in x over Finite Field of size 47
"""
cdef Polynomial_template _right = <Polynomial_template>right

Expand Down

0 comments on commit 78ce487

Please sign in to comment.