ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 31 Dec 2010 09:45:58 +0100Constructing a morphism of free modules using the indexing sethttps://ask.sagemath.org/question/7748/constructing-a-morphism-of-free-modules-using-the-indexing-set/I have a set S indexed by triplets of numbers [i,j,k], and I want to construct an endomorphism T of the free module over S (call it F(S)) of the form:
T: e[i,j,k] ---> Sum over (u,v,w) : f(i,j,k, u,v,w) e[u,v,w]
where f(ijkuvw) is a certain function.
Is there a simple way to do this?
Thanks!Tue, 28 Dec 2010 09:46:12 +0100https://ask.sagemath.org/question/7748/constructing-a-morphism-of-free-modules-using-the-indexing-set/Answer by niles for <p>I have a set S indexed by triplets of numbers [i,j,k], and I want to construct an endomorphism T of the free module over S (call it F(S)) of the form:</p>
<p>T: e[i,j,k] ---> Sum over (u,v,w) : f(i,j,k, u,v,w) e[u,v,w]</p>
<p>where f(ijkuvw) is a certain function. </p>
<p>Is there a simple way to do this?</p>
<p>Thanks!</p>
https://ask.sagemath.org/question/7748/constructing-a-morphism-of-free-modules-using-the-indexing-set/?answer=11904#post-id-11904I suppose it depends how you define the free module over `S` -- I think the recommended way is using [`CombinatorialFreeModule`](http://www.sagemath.org/doc/reference/sage/combinat/free_module.html#sage.combinat.free_module.CombinatorialFreeModule), although while trying to do what you want, I did get a number of errors saying that it is "still using old coercion framework", whatever that means . . .
In any case, I think I was able to do something like what you want, as long as your basis set is finite. Let me know if it works for you:
sage: a = (1,1,1)
sage: b = (1,3,2)
sage: c = (2,1,2)
sage: F = CombinatorialFreeModule(ZZ,[a,b,c])
sage: f = lambda x: sum(x)*F.basis()[x]
sage: f(a)
3*B[(1, 1, 1)]
sage: f(b)
6*B[(1, 3, 2)]
sage: f(c)
5*B[(2, 1, 2)]
sage: phi = F.hom([f(x) for x in [a,b,c]], F)
sage: phi.on_basis()
[3*B[(1, 1, 1)], 6*B[(1, 3, 2)], 5*B[(2, 1, 2)]]
Note, in particular, that it's a little tricky to get the elements `a, b, c` as elements of `F`. The method `F.basis()` gives the basis as a sage finite family, and you recover the element corresponding to `a`, for example, as if it were the key in a python dictionary: `F.basis()[a]`. Such a convoluted approach would not be necessary if coercion was working correctly.
Some further examples of `.hom()` are given (for rings) at the [Homomorphisms of rings](http://www.sagemath.org/doc/reference/sage/rings/morphism.html) manual page.
Wed, 29 Dec 2010 13:03:51 +0100https://ask.sagemath.org/question/7748/constructing-a-morphism-of-free-modules-using-the-indexing-set/?answer=11904#post-id-11904Answer by Michael McBreen for <p>I have a set S indexed by triplets of numbers [i,j,k], and I want to construct an endomorphism T of the free module over S (call it F(S)) of the form:</p>
<p>T: e[i,j,k] ---> Sum over (u,v,w) : f(i,j,k, u,v,w) e[u,v,w]</p>
<p>where f(ijkuvw) is a certain function. </p>
<p>Is there a simple way to do this?</p>
<p>Thanks!</p>
https://ask.sagemath.org/question/7748/constructing-a-morphism-of-free-modules-using-the-indexing-set/?answer=11908#post-id-11908Thanks, that seems to work!Fri, 31 Dec 2010 09:45:58 +0100https://ask.sagemath.org/question/7748/constructing-a-morphism-of-free-modules-using-the-indexing-set/?answer=11908#post-id-11908