#19171: Add a method `divides` to Polynomial
--------------------------------+----------------------------------------
   Reporter:  bruno             |            Owner:
       Type:  enhancement       |           Status:  new
   Priority:  major             |        Milestone:  sage-6.9
  Component:  basic arithmetic  |         Keywords:  polynomial, division
  Merged in:                    |          Authors:  Bruno Grenet
  Reviewers:                    |  Report Upstream:  N/A
Work issues:                    |           Branch:
     Commit:                    |     Dependencies:
   Stopgaps:                    |
--------------------------------+----------------------------------------
 The generic method `divides` that can be found in
 `src/sage/structure/element.pyx` uses `quo_rem` (''via'' `%`) to test if
 an element divides another one: `return (x % self) == 0`.

 For polynomials, depending on the implementations, the method `quo_rem`
 may raise an error if the divisor is not monic (see #16649 for more on
 this).

 This ticket aims at implementing a method `divides` for the class
 `Polynomial`, so that it catches the errors in `quo_rem` to return `False`
 when it is needed.

 **Example of a problematic behavior:**
 {{{#!python
 sage: R.<x> = PolynomialRing(ZZ, implementation="FLINT")
 sage: p = 2*x + 1
 sage: q = R.random_element(10)
 sage: p.divides(q)
 False
 sage: R.<x> = PolynomialRing(ZZ, implementation="NTL")
 sage: p = R(p)
 sage: q = R(q)
 sage: p.divides(q)
 Traceback (most recent call last):
 ...
 ArithmeticError: division not exact in Z[x] (consider coercing to Q[x]
 first)
 }}}

--
Ticket URL: <http://trac.sagemath.org/ticket/19171>
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 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/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to