#18600: Fix several methods for sparse polynomials
-------------------------------------+-------------------------------------
       Reporter:  bruno              |        Owner:
           Type:  defect             |       Status:  needs_work
       Priority:  major              |    Milestone:  sage-6.9
      Component:  commutative        |   Resolution:
  algebra                            |    Merged in:
       Keywords:  sparse polynomial  |    Reviewers:  Vincent Delecroix
        Authors:  Bruno Grenet       |  Work issues:
Report Upstream:  N/A                |       Commit:
         Branch:  public/18600       |  e75ab73b3b2e0bc3a40105640d0572b1b6af9cea
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by bruno):

 Replying to [comment:11 vdelecroix]:
 > - inconsistency between dense and sparse
 > {{{
 > sage: R.<x> = PolynomialRing(Zmod(4), sparse=False)
 > sage: p = x**4 + 1
 > sage: p.integral()
 > x^5 + x
 > sage: R.<x> = PolynomialRing(Zmod(4), sparse=True)
 > sage: p = x**4 + 1
 > sage: p.integral()
 > Traceback (most recent call last):
 > ...
 > TypeError: self must be an integral domain.
 > }}}

 Right, I should mimick what you did for the dense case. Before I do this,
 I actually have a question on what you wrote:
 {{{#!python
         cm = sage.structure.element.get_coercion_model()
         try:
             S = cm.bin_op(R.one(), ZZ.one(), operator.div).parent()
             Q = S.base_ring()
         except TypeError:
             Q = (R.base_ring().one()/ZZ.one()).parent()
             S = R.change_ring(Q)
 }}}
 I don't get what you consider `ZZ.one()` instead of `R.one()` or even
 better `R.base_ring.one()`. I have the following behavior:
 {{{#!python
 sage: R.<x> = Zmod(4)[]
 sage: cm.bin_op(R.one(),ZZ.one(),operator.div).parent()
 Traceback (most recent call last):
 ...
 TypeError: self must be an integral domain.
 sage: cm.bin_op(R.one(),R.one(),operator.div).parent()
 Traceback (most recent call last):
 ...
 TypeError: self must be an integral domain.
 sage: cm.bin_op(R.one(),R.base_ring().one(),operator.div).parent()
 Univariate Polynomial Ring in x over Ring of integers modulo 4
 }}}

 and

 {{{#!python
 sage: R.<x> = ZZ[]
 sage: cm.bin_op(R.one(),R.base_ring().one(),operator.div).parent()
 Univariate Polynomial Ring in x over Rational Field
 sage: R.<x> = ZZ['y'][]
 sage: cm.bin_op(R.one(),R.base_ring().one(),operator.div).parent()
 Univariate Polynomial Ring in x over Fraction Field of Univariate
 Polynomial Ring in y over Integer Ring
 }}}

 If I understand correctly, using `R.base_ring.one()` may fix the issue of
 your `TODO`. What do you think of this?

--
Ticket URL: <http://trac.sagemath.org/ticket/18600#comment:12>
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