# Linear transformations between CombinatorialFreeModule

I have a CombinatorialFreeModule whose basis is a set of tuples. I want to define a linear transformation that permutes the two first components of a tuple in the basis. As a minimal example, that's what I tried:

def Action(k):
V = CombinatorialFreeModule(SR, [(1,0,0),(0,1,0)], prefix="")
e = V.basis()
f = lambda x: ((-1)^(k - x[2]))*V.basis()[(x[1],x[0],x[2])]
return V.hom([f(x) for x in e.keys()], V)


However, I get the following error when I compute Action(1) (I have parameters in the case I am interested in, but this is a minimal example):

unable to convert [-[(0, 1, 0)], -[(1, 0, 0)]] to an element of Set of Morphisms from Free module generated by {(1, 0, 0), (0, 1, 0)} over Symbolic Ring to Free module generated by {(1, 0, 0), (0, 1, 0)} over Symbolic Ring in Category of finite dimensional vector spaces with basis over Symbolic Ring


Is there a way to correct that? As my real basis is much more bigger than that, I don't want to just define the image of each vector separately.

edit retag close merge delete

Sort by ยป oldest newest most voted

Here is a solution via module_morphism:

V = CombinatorialFreeModule(SR, [(1,0,0),(0,1,0)], prefix="")
p = [1,0,2]     # permutation of tuple indices
H = V.module_morphism(lambda t: V.monomial(tuple(t[i] for i in p)), codomain=V)
e = V.random_element()
print('e =\t',e)
print('H(e) =\t',H(e))


As an example it prints:

e =  [(0, 1, 0)] + 2*[(1, 0, 0)]
H(e) =   2*[(0, 1, 0)] + [(1, 0, 0)]

more