Opened 8 years ago

Last modified 6 years ago

#14914 needs_work enhancement

Stuffle algebra

Reported by: deneufchatel Owned by: Matthieu Deneufchâtel
Priority: minor Milestone: sage-6.10
Component: combinatorics Keywords: stuffle quasi shuffle
Cc: Merged in:
Authors: Matthieu Deneufchâtel Reviewers:
Report Upstream: N/A Work issues:
Branch: public/ticket/14914 (Commits, GitHub, GitLab) Commit: 30cceb22a0d0d91ebbb2cf0aec61e0501bfe94c3
Dependencies: Stopgaps:

Status badges

Description (last modified by chapoton)

The stuffle (or quasi shuffle) algebra with counit and coproduct.

Apply:

Attachments (3)

stuffle.patch (19.9 KB) - added by deneufchatel 8 years ago.
trac_14914_stuffle_addon1_fc.patch (26.4 KB) - added by chapoton 8 years ago.
indexed_alphabet.py (2.3 KB) - added by vdelecroix 6 years ago.

Download all attachments as: .zip

Change History (8)

Changed 8 years ago by deneufchatel

comment:1 Changed 8 years ago by chapoton

  • Description modified (diff)

here is a first review patch, cleaning up and making sure that all tests pass

(check using sage -bt stuffle_algebra.py)

some somments:

TAB characters are forbidden in python, you should use 4 spaces. More generally one should avoid whitespaces at the end of the lines (trailing whitespaces) (check your text editor configuration)

the examples section should look like that:

EXAMPLES::

    sage: 2+2
    4

namely, with a shift of 4 spaces

If you want to work further on this ticket now, you should rather use a third patch on top of the two existing ones.

comment:2 Changed 8 years ago by tscrim

Hey Matthieu,

Is this patch ready for review (i.e. does it do everything you want it to)?

Best,
Travis

comment:3 Changed 8 years ago by deneufchatel

  • Status changed from new to needs_review

Changed 8 years ago by chapoton

comment:4 Changed 6 years ago by chapoton

  • Branch set to public/ticket/14914
  • Commit set to 30cceb22a0d0d91ebbb2cf0aec61e0501bfe94c3
  • Keywords stuffle quasi shuffle added
  • Milestone set to sage-6.6

turned into a git branch


New commits:

738c9fetrac 14914 patch for stuffle algebras
30cceb2trac #14914 clean up and lazy import into global namespace

Changed 6 years ago by vdelecroix

comment:5 Changed 6 years ago by vdelecroix

  • Milestone changed from sage-6.6 to sage-6.10
  • Status changed from needs_review to needs_work

The latex command \stuffle is not interpreted in the reference manual.

The (see above) is not appropriate. In this case it makes reference to another function. And indeed, in the reference manual, the class appears first. You can use the syntax :func:`the_name_of_my_function` to refer to a function. But in that case I would actually move the definition from the function to the class (since the entry point for the users is the class).

The first line of stuffle is W = Words(indexed_letters(40, names)). Why the hardcoded 40? Whatever number you put it will fail for some input! What you actually want to do is to work over the infinite alphabet a1, a2, .... You can find a draft of the kind of set you want in the attached file indexed_alphabet.py. With it you have

sage: A = IndexedAlphabet('a', 0, Infinity)
sage: A
Indexed alphabet {a0, a1, a2...}
sage: A[19]
'a19'
sage: A.cardinality()
+Infinity
sage: W = Words(A)
sage: W(['a0','a1','a19'])
word: a0,a1,a19

Once the above integrated, there is no need for an argument names in the function stuffle.

To test emptyness of a word you can do faster

sage: w = Word()
sage: if not w: print "I am empty"
I am empty
Note: See TracTickets for help on using tickets.