coercion vs conversion between polynomial rings

41 views
Skip to first unread message

luisfe

unread,
Jun 27, 2012, 5:57:31 AM6/27/12
to sage-...@googlegroups.com
I think that the following behavior is wrong.

sage: K=QQ['t,s']
sage: L=QQ['t0,t1,s0,s1'] 
sage: L.inject_variables()  
Defining t0, t1, s0, s1
sage: Hom(K,L)([t0+t1,s0]).register_as_coercion()
sage: L.coerce_map_from(K)
Ring morphism:
  From: Multivariate Polynomial Ring in t, s over Rational Field
  To:   Multivariate Polynomial Ring in t0, t1, s0, s1 over Rational Field
  Defn: t |--> t0 + t1
        s |--> s0
sage: K.0*L(1)
t0 + t1   #GOOD
sage: L(K.0)
t0          #BAD


Even if a register a coercion between K and L, L.__call__ is making a conversion instead. Is this the expected result or is it a bug.



David Roe

unread,
Jun 27, 2012, 1:40:18 PM6/27/12
to sage-...@googlegroups.com
This is a bug in the __call__ method of multivariate polynomial rings, which doesn't respect user-defined coercions.  The offending lines are 805-813 in sage/rings/polynomial/multi_polynomial_libsingular.pyx:

        if isinstance(element, MPolynomial_libsingular) and element.parent() is not self and element.parent() != self:
            variable_names_s = element.parent().variable_names()
            variable_names_t = self.variable_names()

            if set(variable_names_s).issubset(variable_names_t):
                for v in variable_names_s:
                    ind_map.append(variable_names_t.index(v)+1)
            else:
                ind_map = [i+1 for i in range(_ring.N)]

David





--
To post to this group, send an email to sage-...@googlegroups.com
To unsubscribe from this group, send an email to sage-devel+...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Maarten Derickx

unread,
Jun 27, 2012, 7:41:38 PM6/27/12
to sage-...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages