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]> 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]. > 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. > -- 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.
