Lyndon words up to depth in Signatory-compatible ordering.
Source code in src/tensorsig/algebra/lyndon_words.py
| @lru_cache(maxsize=None)
def lyndon_words(width: int, depth: int) -> Tuple[WordsBasisElement, ...]:
"""Lyndon words up to ``depth`` in Signatory-compatible ordering."""
if width < 1:
raise ValueError("width must be >= 1")
if depth < 1:
raise ValueError("depth must be >= 1")
words: List[WordsBasisElement] = []
for length in range(1, depth + 1):
words.extend(_lyndon_fixed_length(width, length))
return tuple(words)
|