#18617: Implement polynomial number_of_terms method (and deprecate 
hamming_weight)
-----------------------------------+--------------------------------
   Reporter:  bruno                |            Owner:
       Type:  enhancement          |           Status:  new
   Priority:  major                |        Milestone:  sage-6.8
  Component:  commutative algebra  |         Keywords:  polynomial
  Merged in:                       |          Authors:  Bruno Grenet
  Reviewers:                       |  Report Upstream:  N/A
Work issues:                       |           Branch:
     Commit:                       |     Dependencies:
   Stopgaps:                       |
-----------------------------------+--------------------------------
 Right now, there is a method `hamming_weight` to compute the number of
 nonzero coefficients of a polynomial. The goal of this ticket is two-fold:

 1. Rename this method into `number_of_terms`: I think the name
 `hamming_weight` is not excessively standard for this function, thus the
 function may be unknown form many users. My conviction is comes in part
 from several discussions I have been involved in where no one seem to know
 of the existence of this method.

 2. Implement a specialized version for sparse polynomials, in the spirit
 of #18518, #18585, #18600, which is much faster:

 {{{#!python
 sage: R.<x> = PolynomialRing(ZZ,sparse=True)
 sage: p = R.random_element(10000)
 sage: %timeit p.number_of_terms() # new code
 The slowest run took 44.58 times longer than the fastest. This could mean
 that an intermediate result is being cached
 1000000 loops, best of 3: 203 ns per loop
 sage: %timeit Polynomial.number_of_terms(p) # old code
 100 loops, best of 3: 2.77 ms per loop
 }}}

 ''Note.'' While I decided to group several modifications for sparse
 polynomials in a single ticket #18600, I prefer keeping this change in a
 separate ticket since it involves a deprecation that might be
 controversial (though I do not expect it will be the case).

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