Dear supporters, take two polynomial rings: sage: R1=PolynomialRing(QQ,['x2','x1']) sage: R2=PolynomialRing(QQ,['x4', 'x3', 'x1'])
Assume that I have an element p of R1 that only contains x1 but not x2. I would like to be able to transform it into an element of R2 by mapping R1('x1') to R2('x2'). Since R2(p) wouldn't work (no coercion map), I see two ways: sage: f = R1.hom([1,'x1'],R2) sage: f(p) and sage: R2(str(p)) Singular provides the command 'imap' for a reasonably fast name- preserving map between rings. Is there a similar command in Sage? If not: I have the above situation rather frequently, but always with different rings (so that I can not use one homomorphism f repeatedly for many polynomials). What method would you recommend? I see that sage: timeit('f = R1.hom([1,"x1"],R2)') 625 loops, best of 3: 435 µs per loop sage: timeit('g = R2(str(R1("x1^2+2*x1")))') 625 loops, best of 3: 216 µs per loop Does this mean that using the string representation is faster than creating and using a homomorphism? Cheers, Simon --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---