libsemigroups  v3.0.0
C++ library for semigroups and monoids
Loading...
Searching...
No Matches
libsemigroups::words Namespace Reference

Defined in word-range.hpp.

This namespace contains some functions for creating word_type objects in a compact form.

Example
using namespace words;
pow("a", 5) // same as "aaaaa"
01_w + 2 // same as 012_w
01_w + 01_w // same as 0101_w
prod(0123_w, 0, 16, 3) // same as 032103_w
Namespace containing some operators for creating words.
Definition word-range.hpp:2072
Word pow(Word const &x, size_t n)
Returns the power of a word.
Definition word-range.hpp:2230
Word prod(Container const &elts, int first, int last, int step=1)
Returns a product of letters or words.
Definition word-range.hpp:2411

Functions

letter_type human_readable_index (char c)
 Returns the index of a character in human readable order.
 
template<typename Word = std::string>
Word::value_type human_readable_letter (size_t i)
 Returns a character by index in human readable order.
 
word_type operator+ (letter_type w, word_type const &u)
 Concatenate a letter and a word.
 
word_type operator+ (word_type const &u, letter_type w)
 Concatenate a word and a letter.
 
word_type operator+ (word_type const &u, word_type const &w)
 Concatenate two words.
 
void operator+= (letter_type a, word_type &u)
 Concatenate a letter and a word in-place.
 
void operator+= (word_type &u, letter_type a)
 Concatenate a word and a letter in-place.
 
static void operator+= (word_type &u, word_type const &v)
 Concatenate a word with another word in-place.
 
word_type pow (std::initializer_list< letter_type > ilist, size_t n)
 Returns the power of a word.
 
std::string pow (std::string_view w, size_t n)
 Returns the power of a string.
 
template<typename Word>
Word pow (Word const &x, size_t n)
 Returns the power of a word.
 
template<typename Word>
void pow_inplace (Word &w, size_t n)
 Power a word in-place.
 
template<typename Container, typename Word = Container>
Word prod (Container const &elts, int first, int last, int step=1)
 Returns a product of letters or words.
 
template<typename Container, typename Word = Container>
Word prod (Container const &elts, size_t last)
 Returns a product of letters or words.
 
static word_type prod (std::initializer_list< letter_type > const &elts, size_t last)
 Returns a product of letters.
 
static word_type prod (std::initializer_list< letter_type > ilist, int first, int last, int step=1)
 Returns a product of letters.
 
static std::string prod (std::initializer_list< std::string_view > const &elts, size_t last)
 Returns a product of words.
 
static std::string prod (std::initializer_list< std::string_view > const &sv, int first, int last, int step=1)
 Returns a product of strings.
 
static word_type prod (std::initializer_list< word_type > const &elts, int first, int last, int step=1)
 Returns a product of words.
 
static word_type prod (std::initializer_list< word_type > const &elts, size_t last)
 Returns a product of words.
 
static std::string prod (std::string_view elts, size_t last)
 Returns a product of letters.
 
static std::string prod (std::string_view sv, int first, int last, int step=1)
 Returns a product of letters.
 

Function Documentation

◆ human_readable_index()

letter_type human_readable_index ( char c)
nodiscard

Defined in word-range.hpp.

This function is the inverse of human_readable_letter, see the documentation of that function for more details.

Parameters
ccharacter whose index is sought.
Returns
A value of type letter_type.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
See also
human_readable_letter

◆ human_readable_letter()

template<typename Word = std::string>
Word::value_type human_readable_letter ( size_t i)

This function exists to map the numbers 0 to 255 to the possible values of a char, in such a way that the first characters are a-zA-Z0-9. The ascii ranges for these characters are: \([97, 123)\), \([65, 91)\), \([48, 58)\) so the remaining range of chars that are appended to the end after these chars are \([0,48)\), \([58, 65)\), \([91, 97)\), \([123, 255]\).

This function is the inverse of human_readable_index.

Parameters
ithe index of the character.
Returns
A value of type char.
Exceptions
LibsemigroupsExceptionif i exceeds the number of characters.

◆ operator+() [1/3]

word_type operator+ ( letter_type w,
word_type const & u )

See operator+.

◆ operator+() [2/3]

word_type operator+ ( word_type const & u,
letter_type w )

See operator+.

◆ operator+() [3/3]

word_type operator+ ( word_type const & u,
word_type const & w )

Returns the concatenation of u and w.

Parameters
ua word.
wa word.
Returns
A word_type.
Exceptions
This function guarantees not to throw a LibsemigroupsException.

◆ operator+=() [1/3]

void operator+= ( letter_type a,
word_type & u )
inline

See operator+=.

◆ operator+=() [2/3]

void operator+= ( word_type & u,
letter_type a )
inline

See operator+=.

◆ operator+=() [3/3]

static void operator+= ( word_type & u,
word_type const & v )
inlinestatic

Changes u to u + v in-place. See operator+.

Parameters
ua word.
va word.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
See also
operator+

◆ pow() [1/3]

word_type pow ( std::initializer_list< letter_type > ilist,
size_t n )

See pow(Word const&, size_t) for details.

◆ pow() [2/3]

std::string pow ( std::string_view w,
size_t n )

See pow(Word const&, size_t) for details.

◆ pow() [3/3]

template<typename Word>
Word pow ( Word const & x,
size_t n )

Returns the Word w to the power n.

Template Parameters
Wordthe type of the first parameter.
Parameters
xthe word to power.
nthe power.
Returns
A Word.
Exceptions
This function guarantees not to throw a LibsemigroupsException.

◆ pow_inplace()

template<typename Word>
void pow_inplace ( Word & w,
size_t n )

Modify the Word w to contains its nth power.

Template Parameters
Wordthe type of the first parameter.
Parameters
wthe word.
nthe power.
Exceptions
This function guarantees not to throw a LibsemigroupsException.

◆ prod() [1/10]

template<typename Container, typename Word = Container>
Word prod ( Container const & elts,
int first,
int last,
int step = 1 )

Let elts correspond to the ordered set \(a_0, a_1, \ldots, a_{n - 1}\), first to \(f\), last to \(l\), and step to \(s\). If \(f \leq l\), let \(k\) be the greatest positive integer such that \(f + ks < l\). Then the function prod returns the word corresponding to \(a_f a_{f + s} a_{f + 2s} \cdots a_{f + ks}\). All subscripts are taken modulo \(n\).

If there is no such \(k\) (i.e. \(s < 0\), or \(f = l\)), then the empty word is returned. Where \(f > l\), the function works analogously, where \(k\) is the greatest positive integer such that \(f + k s > l\).

Template Parameters
Containerthe type of the 1st argument elts.
Wordthe return type (defaults to Container).
Parameters
eltsthe ordered set.
firstthe first index.
lastthe last index.
stepthe step.
Returns
A Word.
Exceptions
LibsemigroupsExceptionif step = 0
LibsemigroupsExceptionif elts is empty, but the specified range is not
Examples
using namespace words;
word_type w = 012345_w
prod(w, 0, 5, 2) // {0, 2, 4}
prod(w, 1, 9, 2) // {1, 3, 5, 1}
prod("abcde", 4, 1, -1) // "edc"
prod({"aba", "xyz"}, 0, 4, 1) // "abaxyzabaxyz"
std::vector< letter_type > word_type
Type for a word over the generators of a semigroup.
Definition types.hpp:101

◆ prod() [2/10]

template<typename Container, typename Word = Container>
Word prod ( Container const & elts,
size_t last )

Returns the same as prod(elts, 0, last, 1).

See prod(Container const&, int, int, int).

◆ prod() [3/10]

static word_type prod ( std::initializer_list< letter_type > const & elts,
size_t last )
inlinestatic

Returns the same as prod(elts, 0, last, 1).

See prod(Container const&, int, int, int).

◆ prod() [4/10]

static word_type prod ( std::initializer_list< letter_type > ilist,
int first,
int last,
int step = 1 )
inlinestatic

◆ prod() [5/10]

static std::string prod ( std::initializer_list< std::string_view > const & elts,
size_t last )
inlinestatic

Returns the same as prod(elts, 0, last, 1).

See prod(Container const&, int, int, int).

◆ prod() [6/10]

static std::string prod ( std::initializer_list< std::string_view > const & sv,
int first,
int last,
int step = 1 )
inlinestatic

◆ prod() [7/10]

static word_type prod ( std::initializer_list< word_type > const & elts,
int first,
int last,
int step = 1 )
inlinestatic

◆ prod() [8/10]

static word_type prod ( std::initializer_list< word_type > const & elts,
size_t last )
inlinestatic

Returns the same as prod(elts, 0, last, 1).

See prod(Container const&, int, int, int).

◆ prod() [9/10]

static std::string prod ( std::string_view elts,
size_t last )
inlinestatic

Returns the same as prod(elts, 0, last, 1).

See prod(Container const&, int, int, int).

◆ prod() [10/10]

static std::string prod ( std::string_view sv,
int first,
int last,
int step = 1 )
inlinestatic