Actually, it seems that _coerce_map_from works just fine allowing you to 
send an integer into the power series ring. What is broken is recognizing 
that the powerseries element is an integer even though T(1)==1 returns true.

I've been looking around at __init__ in the Integer class 
(sage/rings/integer.pyx) and I've having trouble understanding what is 
going on. It seems that when I pass in Integer(R(1)) for R a polynomial 
ring PyInt_Check() is returing true and all is good. When the power series 
ring is used, this returns false. My guess is that when T(1) is intialized 
it is failing to recognize it as an integer and not setting the right 
thing, but I have been unable to find where "right" thing is done in 
polynomials so it can be modified in powerseries.

Is this what PolynomialBaseringInjection does? or maybe what the 
_new_constant_poly functionality does?

On Monday, March 17, 2014 12:03:41 PM UTC-4, David Roe wrote:
>
> The fact that Integer(T(1)) doesn't work is definitely a bug.  A brief 
> glance at sage.ext.fast_callable (in particular, the code in 
> Expression.__pow__) suggests that fixing the first problem might yield an 
> expression that doesn't use an exponent in the coefficient ring.  However, 
> I'm not as familiar with that code, so there may be a problem there as well.
>
> The best way to fix the problem for power series is to duplicate the 
> functionality from polynomials, defined in 
> sage.rings.polynomial.polynomial_element.PolynomialBaseringInjection and 
> used in 
> sage.rings.polynomial.polynomial_ring.PolynomialRing._coerce_map_from_.
> David
>
>
> On Sun, Mar 16, 2014 at 9:51 PM, Dillon Rose <[email protected]<javascript:>
> > wrote:
>
>> Hello all,
>>
>> I am developing patch # 15780.  We want to use fast_callable to increase the 
>> speed.
>>
>> The changes we have work for most cases.  However, when we try to evaluate 
>> the expression tree built for a polynomial ring over a PowerSeriesRing, an 
>> exception is thrown.
>>
>> T.<z>=PowerSeriesRing(ZZ)
>> P.<x,y>=PolynomialRing(T)
>> f=x^2+x*y
>> g=fast_callable(f)
>> g(1,1)
>>
>> The cause is in generic_power_c() in sage/structure/element.pyx. Basically, 
>> the PowerSeriesRing element 1 fails to be recognized as the integer 1 
>> causing the exception to be thrown.
>>
>>
>> try:
>>     from sage.rings.integer import Integer
>>     n = int(Integer(nn))
>> except TypeError:
>>     raise NotImplementedError, "non-integral exponents not supported"
>>
>>
>> This is occuring because the expression from fast_callable has a term 
>> ('ipow', n) where n is actually an integer, but whose parent is the 
>> coefficient ring of the polynomial ring.
>>
>> The question here is basically: what part of this needs to be fixed? It 
>> seems odd that the exponents being returned from fast_callable are in the 
>> base ring causing the call to generic_power. This expression should be fast 
>> to evaluate and, even if it worked, this is certainly slowing it down. But 
>> it also is odd that Integer() is unable to coerce a power series integer.
>>
>>
>> Dillon Rose
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "sage-devel" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/sage-devel.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" 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-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to