#16836: __neg__ fails in CartesianProduct of CombinatorialFreeModule
-------------------------+-------------------------------------------------
Reporter: | Owner:
cnassau | Status: needs_review
Type: | Milestone: sage-6.4
defect | Resolution:
Priority: major | Merged in:
Component: | Reviewers:
categories | Work issues:
Keywords: | Commit:
Authors: | b8f88790e6fa4143906f1120a0270321b4139e2c
Christian Nassau | Stopgaps:
Report Upstream: N/A |
Branch: |
public/16836 |
Dependencies: |
-------------------------+-------------------------------------------------
Comment (by vdelecroix):
Not sure the old code is appropriate:
{{{
sage: NNSemiring = NonNegativeIntegerSemiring()
sage: C = cartesian_product([ZZ,NNSemiring,RR])
sage: -C([2,0,.4])
(-2, 0, -0.400000000000000)
sage: parent(_)
The cartesian product of (Integer Ring, Integer Ring, Real Field with 53
bits of precision)
}}}
The problem is that `NN` is a facade (i.e. its elements are Integer whose
with parent the Integer Ring). But when `NN` is a factor of a cartesian
product it is not considered as being one. I would just remove completely
this `__neg__` for magma elements or adopt my version. That would avoid
many problems!
The good way to do it is to implement a `negation_parent` in the coercion
model similar to the `division_parent` that we have right now. This does
choose for you the right parent when you do `x / y`.
{{{
sage: from sage.structure.element import get_coercion_model
sage: cm = get_coercion_model()
sage: cm.division_parent(ZZ)
Rational Field
sage: cm.division_parent(QQ)
Rational Field
sage: cm.division_parent(Zmod(14))
Ring of integers modulo 14
}}}
But it is out of the scope of this ticket I guess.
Vincent
--
Ticket URL: <http://trac.sagemath.org/ticket/16836#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.