#17058: Add abelian_vectors and abelian_complexity method to finite words
-------------------------+-------------------------------------------------
Reporter: | Owner:
slabbe | Status: needs_work
Type: | Milestone: sage-6.4
enhancement | Resolution:
Priority: major | Merged in:
Component: | Reviewers:
combinatorics | Work issues:
Keywords: | Commit:
Authors: | ea0257cb2b026ab2ffe366a4d599e084d074a58c
Report Upstream: N/A | Stopgaps:
Branch: |
u/slabbe/17058 |
Dependencies: |
-------------------------+-------------------------------------------------
Changes (by vdelecroix):
* status: needs_review => needs_work
Comment:
Hello,
It is weird to call a method `alphabet` on the word which is not the
alphabet of the parent. Moreover, there is already the method `letters`
which does the job. So please use `letters` if you need it.
Now about your design choice, if the alphabet of the parent is {a,b,c} and
my word is abbab then the abelianization must be a vector of length 3.
With your branch:
{{{
sage: W = Words([0,1,2])
sage: w = W([0,1,1,0,1,2,0,2,0,2])
sage: w.abelian_vectors(3)
{(1, 0, 2), (1, 1, 1), (1, 2, 0), (2, 0, 1)}
sage: w[:5].abelian_vectors(3) # word on 0,1
{(1, 2)}
sage: w[5:].abelian_vectors(3) # word on 0,2
{(1, 2), (2, 1)}
}}}
which is completely crazy!
For the algorithm, it would be faster to deal only with integers because
{{{
sage: tuple(my_list)
}}}
is much faster than
{{{
sage: tuple(my_dict[a] for a in alphabet)
}}}
i.e. I would initialize `abelian` as a list of length the cardinality of
the alphabet and then
{{{
abelian[rank[start.next()]] += 1
abelian[rank[stop.next()]] -= 1
S.add(tuple(abelian))
}}}
where `rank` would be a dictionnary `letter -> index`.
Cheers
Vincent
--
Ticket URL: <http://trac.sagemath.org/ticket/17058#comment:4>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.