Initialization¶
This page contains information about initialising the FpSemigroupInterface
class.
-
inline void libsemigroups::FpSemigroupInterface::add_rule(relation_type rel)¶
Add a rule using a relation_type.
- Complexity
Constant.
- Parameters
rel – the rule being added.
- Throws
LibsemigroupsException – if any of the following apply:
started() returns
true
; orrel.first
orrel.second
contains a letter that is out of bounds.
- Returns
(None)
-
inline void libsemigroups::FpSemigroupInterface::add_rule(rule_type rel)¶
Add a rule using a rule_type.
- Complexity
Constant.
- Parameters
rel – the rule being added.
- Throws
LibsemigroupsException – if any of the following apply:
started() returns
true
; orrel.first
orrel.second
contains a letter that is out of bounds.
- Returns
(None)
-
inline void libsemigroups::FpSemigroupInterface::add_rule(std::initializer_list<size_t> u, std::initializer_list<size_t> v)¶
Add a rule using two word_type const references.
- Complexity
Constant.
- Parameters
u – the left-hand side of the rule being added.
v – the right-hand side of the rule being added.
- Throws
LibsemigroupsException – if any of the following apply:
started() returns
true
; oru
orv
contains a letter that is out of bounds.
- Returns
(None)
-
inline void libsemigroups::FpSemigroupInterface::add_rule(std::string const &u, std::string const &v)¶
Add a rule using two std::string const references.
- Complexity
Constant.
- Parameters
u – the left-hand side of the rule being added.
v – the right-hand side of the rule being added.
- Throws
LibsemigroupsException – if any of the following apply:
started() returns
true
; oru
orv
contains a letter that does not belong to alphabet().
- Returns
(None)
-
inline void libsemigroups::FpSemigroupInterface::add_rule(word_type const &u, word_type const &v)¶
Add a rule using two word_type const references.
- Complexity
Constant.
- Parameters
u – the left-hand side of the rule being added.
v – the right-hand side of the rule being added.
- Throws
LibsemigroupsException – if any of the following apply:
started() returns
true
; oru
orv
contains a letter that is out of bounds.
- Returns
(None)
-
void libsemigroups::FpSemigroupInterface::add_rules(FroidurePinBase &S)¶
Add rules from a FroidurePin instance.
- Complexity
At most \(O(|S||A|)\) where \(A\) is a generating set for
S
.
- Parameters
S – a FroidurePin object representing a semigroup.
- Throws
LibsemigroupsException – if any of the following apply:
alphabet() is empty;
the number of generators of
S
is not equal toalphabet().size()
; orstarted() returns
true
;
- Returns
(None)
-
inline void libsemigroups::FpSemigroupInterface::add_rules(std::vector<rule_type> const &rels)¶
Add rules in a vector.
- Complexity
\(O(n)\) where \(n\) is the size of
rels
.
- Parameters
rels – a vector of rule_type.
- Throws
LibsemigroupsException – if add_rule() with argument any item in
rels
throws.- Returns
(None)
-
inline std::string const &libsemigroups::FpSemigroupInterface::alphabet() const noexcept¶
Returns a const reference to the alphabet.
- Complexity
Constant.
- Parameters
(None)
- Throws
(None) – This function is
noexcept
and is guaranteed never to throw.- Returns
A const reference to the alphabet, a value of type std::string.
-
inline std::string libsemigroups::FpSemigroupInterface::alphabet(size_t i) const¶
Returns the
i
th letter of the alphabet.- Complexity
Constant.
- Parameters
i – the index of the letter.
- Throws
std::range_error – if the index
i
is out of range.- Returns
A std::string by value.
-
inline bool libsemigroups::FpSemigroupInterface::has_identity() const noexcept¶
Check if an identity has been set.
This function returns
true
if an identity has been set andfalse
if it has not.See also
set_identity(std::string const&) and set_identity(letter_type).
- Complexity
Constant.
- Parameters
(None)
- Throws
(None) – This function is
noexcept
and is guaranteed never to throw.- Returns
A value of type
bool
.
-
std::string const &libsemigroups::FpSemigroupInterface::identity() const¶
Returns the identity (if any).
- Complexity
Constant.
- Parameters
(None)
- Throws
LibsemigroupsException – if no identity has been defined.
- Returns
A const reference to the identity, a value of type std::string.
-
std::string const &libsemigroups::FpSemigroupInterface::inverses() const¶
Returns the inverses (if any).
See also
set_inverses() for the meaning of the return value of this function.
- Complexity
Constant.
- Parameters
(None)
- Throws
LibsemigroupsException – if no identity has been defined.
- Returns
A const reference to the inverses, a value of type std::string.
-
inline size_t libsemigroups::FpSemigroupInterface::number_of_rules() const noexcept¶
Returns the number of rules.
- Complexity
Constant.
- Parameters
(None)
- Throws
(None) – This function is
noexcept
and is guaranteed never to throw.- Returns
A value of type
size_t
.
-
void libsemigroups::FpSemigroupInterface::set_alphabet(size_t n)¶
Set the size of the alphabet.
Use this to specify the alphabet of a finitely presented semigroup if you intend to use indices rather than the actual letters in the alphabet in subsequent calculations.
See also
- Complexity
Constant.
- Parameters
n – the number of letters.
- Throws
LibsemigroupsException – If the size of the of alphabet has already been set to another value, or the parameter
n
is0
.- Returns
(None)
-
void libsemigroups::FpSemigroupInterface::set_alphabet(std::string const &a)¶
Set the alphabet of the finitely presented semigroup.
See also
- Complexity
Constant.
- Parameters
a – the alphabet.
- Throws
LibsemigroupsException – If the alphabet has already been set to another value, the parameter
a
is empty, or there are repeated characters ina
.- Returns
(None)
-
inline void libsemigroups::FpSemigroupInterface::set_identity(letter_type id)¶
Set a character in alphabet() to be the identity using its index.
This function adds rules to
this
so thatid
is the identity. This function can be called repeatedly.See also
- Complexity
\(O(n)\) where \(n\) is alphabet().size().
- Parameters
id – the index of the character to be the identity.
- Throws
LibsemigroupsException – If
id
is out of bounds.- Returns
(None)
-
void libsemigroups::FpSemigroupInterface::set_identity(std::string const &id)¶
Set a character in alphabet() to be the identity.
This function adds rules to
this
so thatid
is the identity. This function can be called repeatedly.See also
- Complexity
\(O(n)\) where \(n\) is alphabet().size().
- Parameters
id – a string containing the character to be the identity.
- Throws
LibsemigroupsException – If
id
has length greater than 1, orid
contains a character that is not in alphabet().- Returns
(None)
-
void libsemigroups::FpSemigroupInterface::set_inverses(std::string const &a)¶
Set the inverses of letters in alphabet().
The letter in
a
with indexi
is the inverse of the letter in alphabet() with indexi
.See also
- Complexity
\(O(n)\) where \(n\) is alphabet().size().
- Parameters
a – a string of length alphabet().size().
- Throws
LibsemigroupsException – if any of the following apply:
a
is empty;alphabet() is empty;
no identity has been defined using set_identity();
the length of
a
is not equal to alphabet().size();the letters in
a
are not exactly those in alphabet() (perhaps in a different order).
- Returns
(None)