#19171: Add a method `divides` to Polynomial
-------------------------------------+-------------------------------------
Reporter: bruno | Owner:
Type: defect | Status: needs_work
Priority: major | Milestone: sage-7.3
Component: commutative | Resolution:
algebra |
Keywords: polynomial, | Merged in:
division |
Authors: Bruno Grenet | Reviewers: Vincent Delecroix
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/bruno/t19171_divides_poly | ac43c02c86eb8884bc3d7fa4013f78aef1e34803
Dependencies: #16649 | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by vdelecroix):
Replying to [comment:15 bruno]:
> I am not sure I fully understand your latest comments:
>
> > Since one is always a unit the {{{if self.is_one(): return True}}}
would better be inside the block {{{except NotImplementedError:}}}.
>
> Do you mean adding a {{{try: ... except NotImplementedError:}}}
construction? Because if I add this test say right below the test {{{if
self.is_unit(): return True}}}, an exception will be raised in the cases
where {{{is_unit}}} is not implemented but {{{is_one}}} is.
I meant
{{{
try:
if self.is_unit(): return True # units divide everything
except NotImplementedError:
if self.is_one(): return True # if is_unit is not implemented
}}}
>
> > And why not using {{{quo_rem}}} instead of catching a potential
{{{ArithmeticError}}}?
>
> Using {{{p % self}}} is really the same as {{{ p.quo_rem(self)[1] }}} so
I do not see the difference.
Not exactly. NTL makes a distinction... and you should actually use
`pseudo_quo_rem` when it is there:
{{{
sage: R.<x> = PolynomialRing(ZZ, implementation="NTL")
sage: p = 2*x + 1
sage: q = R.random_element(10)
sage: p.quo_rem(q)
Traceback (most recent call last):
...
ArithmeticError: division not exact in Z[x] (consider coercing to Q[x]
first)
sage: p.pseudo_quo_rem(q)
(0, 2*x + 1)
}}}
--
Ticket URL: <https://trac.sagemath.org/ticket/19171#comment:16>
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 https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.