The thing is: we actually need this specific implementation which is much
quicker for what we're doing. So I'm going to look closer at the object and
probably open a ticket to allow for such basic operation.

Best

Viviane

2015-06-09 2:24 GMT-05:00 Nicolas Borie <nicolas.bo...@univ-mlv.fr>:

> Le 09/06/2015 06:50, Viviane Pons a écrit :
>
>> Hi everyone,
>>
>> I'm doing this:
>>
>> sage: FreeA.<a,b,c,d,e,f> = FreeAlgebra(QQ,implementation="letterplace")
>> sage: P = a*b*a*c*c*b + a*b*a*d*d*b + a*c*a*d*d*c + b*c*b*d*d*c
>> sage: X = P.lm()
>> sage: X
>> a*b*a*c*c*b
>>
>> And now I would like a way to "cut" my element X into two factors of a
>> given size. Something like
>>
>> sage: u,v = X[:2],X[2:]
>>
>> with then u=a*b and v = a*c*c*d
>>
>> except this doesn't work (no __getitem__ on X). I have looked a bit, but
>> I cannot find how to do this even though it seems quite a natural
>> operation. I must say, I don't even understand the datastructure of X,
>> list(X) doesn't give me something I can easily read or transform into a
>> word or anything...
>>
>> If someone knows about this, I would appreciate the help.
>>
> Hello,
>
> This feature seems to be strongly wrapped... You can access the data
> structure by iterating on element :
>
>
> **************************************************************************************************
> sage: FreeA.<a,b,c,d,e,f> = FreeAlgebra(QQ,implementation="letterplace")
> sage: P = a*b*a*c*c*b + a*b*a*d*d*b + a*c*a*d*d*c + b*c*b*d*d*c
> sage: for basis_elt, coef in P:
> ....:     print list(basis_elt), coef
> ....:
> [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
> 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0] 1
> [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
> 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0] 1
> [0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
> 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0] 1
> [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
> 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0] 1
>
> **************************************************************************************************
>
> Depending what is your need, perhaps one of the following will be easier
> to manipulate :
>
> **************************************************************************************************
> sage: W = Words(['abcdef'])
> sage: A = W.algebra(QQ)
> sage: A
> Free module generated by Words over {'abcdef'} over Rational Field
> sage: A = FreeMonoid(6, 'a,b,c,d,e,f').algebra(QQ)
> sage: A
> Free module generated by Free monoid on 6 generators (a, b, c, d, e, f)
> over Rational Field
>
> **************************************************************************************************
>
> Note that the first one using Words produce a strange bug on my machine
> (old sage 6.4.beta2)
>
> **************************************************************************************************
> sage: W = Words(['abcdef'])
> sage: W.algebra(QQ)
> ---------------------------------------------------------------------------
> AttributeError                            Traceback (most recent call last)
> <ipython-input-30-c6db62886943> in <module>()
> ----> 1 W.algebra(QQ)
>
> /home/nborie/sage-6.3/local/lib/python2.7/site-packages/sage/structure/parent.so
> in sage.structure.parent.Parent.__getattr__
> (build/cythonized/sage/structure/parent.c:7213)()
>
> AttributeError: 'Words_over_OrderedAlphabet' object has no attribute
> 'algebra'
> sage: W.al
> W.algebra   W.alphabet
> sage: W.algebra(QQ)
> Free module generated by Words over {'abcdef'} over Rational Field
>
> **************************************************************************************************
>
> The method algebra works only after I asked for a tab completion on W...
> Never see that before....
>
> Following the feature you choose, you will perhaps have to add a product
> method (product_on_basis or whatever, most of the time, the categories does
> it already for you...)
>
> Cheers,
> Nicolas.
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-devel+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-devel@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-devel.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to