#18600: Fix several methods for sparse polynomials
-------------------------------------+-------------------------------------
       Reporter:  bruno              |        Owner:
           Type:  defect             |       Status:  needs_info
       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       |  29331f254d9255c23c673393c6fd0121c04d9d6c
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by bruno):

 The coercion model is really something I do not understand yet in Sage, so
 I trust what you wrote. Simply, in the following change, isn't it faster
 (and cleaner to some extent) to first define the underlying list of
 coefficients rather than defining the zero polynomial before adding
 monomials to it?

 {{{#!diff
 -        coeffs = self.list()
 -        v = [0] + [coeffs[n]/(n+1) for n from 0 <= n <= degree]
 -        return S(v)
 +        p = S.zero()
 +        for n in range(degree+1):
 +            if self[n]:
 +                p += cm.bin_op(Q(self[n]), n+1, operator.div) *
 S.gen()**(n+1)
 +        return p
 }}}

 What about something as the following?
 {{{#!python
     coeffs = [self.zero()] * (degree + 2)
     for n in range(degree+1):
         if self[n]:
             coeffs[n+1] = cm.bin_op(Q(self[n]), n+1, operator.div)
     return S(coeffs)
 }}}

 ''Note. I'm going in vacations and won't be able to interact much until
 August 24.''

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