#15364: Introduce factor_or_zero into global namespace
-------------------------------------+-------------------------------------
       Reporter:  zabrocki           |        Owner:
           Type:  enhancement        |       Status:  needs_work
       Priority:  minor              |    Milestone:  sage-6.2
      Component:  factorization      |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Mike Zabrocki      |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  public/ticket/15364/zabrocki/factor_or_zero|  
1e0e3da44e609c65c2b6b269f80991d01a33b844
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by zabrocki):

 I noticed another problem with `factor` and the factorization objects that
 it returns.   I took a symmetric function expression and used
 `.map_coefficients(factor)` and my coefficients which were 1 and -1
 disappeared (I was applying it to an expression with polynomial
 coefficients, but you get the idea from the following expression).

 {{{
 sage: s = SymmetricFunctions(QQ).s()
 sage: (s[3,2]+2*s[2,2,1]).map_coefficients(factor)
 2*s[2, 2, 1]
 }}}

 This happens because `map_coefficients` is calling `s.sum_of_terms` which
 calls `s.term` which calls `s._from_dict` and we have the strange behavior
 that `s._from_dict({Partition([3,2]) : factor(1)})` is 0.

 If you trace it further, you see that `_from_dict` removes the zeros and
 computes

 {{{dict( (key, coeff) for key, coeff in d.iteritems() if coeff)}}}

 Now `bool(factor(2))` is `True` while `bool(factor(1))` and
 `bool(factor(-1))` is `False`.  I don't know if there is a good reason
 that `factor(1)` and `factor(-1)` should be `False` or if this bug should
 be fixed in `combinat/free_module.py` in the code for `_from_dict`.

--
Ticket URL: <http://trac.sagemath.org/ticket/15364#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 http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to