"Nicolas M. Thiery" <nicolas.thi...@u-psud.fr> writes:

>       Hi Martin!
>
> On Wed, Jul 13, 2011 at 12:22:50PM +0200, Martin Rubey wrote:
>> Martin Rubey <martin.ru...@math.uni-hannover.de> writes:
>> > I have a basis and two CombinatorialFreeModules over this basis, say one
>> > over QQ and the other over QQ[q].  I'd like to convert elements from the
>> > first into the second.  Is there a built-in way to do this, or do I have
>> > to iterate over the coefficients?
>> 
>> Sorry, I mis-asked: should have been tensor products of
>> CombinatorialFreeModules.
>
>     sage: phi = A.module_morphism(B.monomial)
>     sage: phi(x)
>
> where A and B are respectively the source and target free module
> (tensor product or not) should do the job.

Hm, and now I have a similar problem: how to do it in the other
direction? I.e., I have a map from QQ[q] to QQ and want to use it to
construct an element in a module over QQ given an element over QQ[q]...

Hm, I just found from_vector.

sage: R.<q> = QQ[]
sage: F1 = CombinatorialFreeModule(R, ['a','b','c'])
sage: F2 = CombinatorialFreeModule(QQ, ['a','b','c'])
sage: def phi(p): return p.subs(q=1)
sage: f = F1.an_element().map_coefficients(phi)
sage: F2.from_vector(f.to_vector())

wouldn't F2(f) be nicer?

Martin

-- 
You received this message because you are subscribed to the Google Groups 
"sage-combinat-devel" group.
To post to this group, send email to sage-combinat-devel@googlegroups.com.
To unsubscribe from this group, send email to 
sage-combinat-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sage-combinat-devel?hl=en.

Reply via email to