#18585: Comparison of sparse polynomials
-------------------------------------+-------------------------------------
       Reporter:  bruno              |        Owner:
           Type:  defect             |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-6.9
      Component:  commutative        |   Resolution:
  algebra                            |    Merged in:
       Keywords:  polynomials        |    Reviewers:  Vincent Delecroix
        Authors:  Bruno Grenet       |  Work issues:
Report Upstream:  N/A                |       Commit:
         Branch:                     |  3121374eed7b683bd135e9ec5086aac03c4c8eb5
  u/bruno/compare_sparse_polynomials |     Stopgaps:
   Dependencies:                     |
-------------------------------------+-------------------------------------

Comment (by vdelecroix):

 Replying to [comment:20 bruno]:
 > Replying to [comment:18 vdelecroix]:
 > >Dough! I was asking because for sparse matrices it is explicitely
 mentioned in the specification that no value can be zero. And this is very
 useful!
 >
 > There is no such specification as for matrices. There is a method
 `__normalize()` to remove the zero coefficients, used by default in
 `__init__`, and used for instance in the multiplication (since there may
 be some cancellations).

 `matrix_generic_sparse.pyx`, main docstring line 69-71
 {{{
     A generic sparse matrix is
     represented using a dictionary whose keys are pairs of integers
 `(i,j)` and
     values in the base ring. The values of the dictionary must never be
 zero.
 }}}

 > Replying to [comment:19 vdelecroix]:
 > > Though, multiplication is nicer
 > > {{{
 > > sage: (p*p).dict()
 > > {0: 1, 2: 2, 4: 1}
 > > }}}
 > >
 > > What do you think about opening a ticket about enforcing non-zero
 values in the dictionary?
 >
 > I am in favor of opening a ticket to add this specification, though I am
 not in favor of removing the `check=False` option that can be useful at
 some places to get (slightly) faster code.

 I now understand that it only due to `check=False`. In the case
 `check=True` (which is the default) zeros are removed. So I would assume
 that there '''never''' are zero value in the dictionary. One only needs to
 specify it in the documentation.

 You could have a look at the implementation of `degree`. It does not check
 if the values are zero or not. It just assumes that values are nonzero.

 Vincent

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