Hello everyone,
I'm trying to construct, given a set of words W on an alphabet A, the free algebra Z<A>. And I would to keep the basis as words.
The method .algebra is not implented on Words, so I tried to create my own class using CombinatorialFreeModule:
def __init__(self, alphabet):
CombinatorialFreeModule.__init__(self, ZZ,
basis_keys=Words(alphabet),
category=AlgebrasWithBasis(ZZ))
The problem now is that I cannot construct elements of the algebra. Here is the kind of error I get:
sage: A
Free module generated by Words over {1, 2, 3, 4} over Integer Ring
sage: A('123')
TypeError: do not know how to make x (= 123) an element of self (=Free module generated by Words over {1, 2, 3, 4} over Integer Ring)
sage: A(Word([1,2,4]))
TypeError: do not know how to make x (= 124) an element of self (=Free module generated by Words over {1, 2, 3, 4} over Integer Ring)
sage: A(Word([1,2,4], 4))
NotImplementedError: please implement _an_element_ for Words over {1, 2, 3, 4}
So I tried to add the method _an_element_ (returning the empty word) but I still have the same problem...
I don't really know if this is a NotImplemented technology (and then I should add it ?) or if I'm doing it wrong ?
Thanks by advance,
Aladin