Ask Your Question

free algebra and indexed letters

I try to work with a Combinatorial Free Module with basis a set of Words over an alphabet of indexed letters (y1,y2,...). For example, I define

from sage.combinat.free_module import CombinatorialFreeModule as CFM Mots=Words(['y1','y2','y3','y4','y5','y6','y7','y8']) Module=CFM(QQ,Mots)

But I have some problems with the letters. For example :

mot=Word('y1') sage: mot word: y1 sage: mot in Mots False

Is there a way to cure this problem ?

edit retag close merge delete

1 answer

Sort by » oldest newest most voted

I think when you evaluate

mot=Word('y1')


it treats 'y' and '1' as separate characters, giving a word of length 2. Instead,

mot=Word(['y1'])


makes it have length one. To force it to live in Mots, do this:

sage: mot = Mots(Word(['y1']))
sage: Word(['y1']) in Mots
False
sage: Mots(Word(['y1'])) in Mots
True


Not ideal, but it seems to work.

more

Comments

Thanks, that helps !

( 2011-12-31 04:26:07 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Stats

Asked: 2011-12-30 05:41:57 -0600

Seen: 92 times

Last updated: Dec 30 '11