libsemigroups  v3.0.0
C++ library for semigroups and monoids
Loading...
Searching...
No Matches
Transformations

Defined in transf.hpp.

This page contains the documentation for functionality in libsemigroups for various partial transformations.

A partial transformation \(f\) is just a function defined on a subset of \(\{0, 1, \ldots, n - 1\}\) for some integer \(n\) called the degree of f. A partial transformation is stored as a container of the images of \(\{0, 1, \ldots, n -1\}\), i.e. \(((0)f, (1)f, \ldots, (n - 1)f)\) where the value UNDEFINED is used to indicate that \((i)f\) is, you guessed it, undefined (i.e. not among the points where \(f\) is defined).

Topics

 make<Transf>
 Safely construct a Transf instance.
 
 make<PPerm>
 Safely construct a PPerm instance.
 
 make<Perm>
 Safely construct a Perm instance.
 

Classes

class  DynamicPTransf< Scalar >
 Partial transformations with dynamic degree. More...
 
class  Perm< N, Scalar >
 Permutations with static or dynamic degree. More...
 
class  PPerm< N, Scalar >
 Partial permutations with static or dynamic degree. More...
 
class  PTransfBase< Scalar, Container >
 Base class for partial transformations. More...
 
class  StaticPTransf< N, Scalar >
 Partial transformations with static degree. More...
 
class  Transf< N, Scalar >
 Transformations with static or dynamic degree. More...
 

Typedefs

template<size_t N>
using LeastPerm = typename detail::LeastPermHelper<N>::type
 Type of perms using the least memory for a given degree.
 
template<size_t N>
using LeastPPerm = typename detail::LeastPPermHelper<N>::type
 Type of partial perms using the least memory for a given degree.
 
template<size_t N>
using LeastTransf = typename detail::LeastTransfHelper<N>::type
 Type of transformations using the least memory for a given degree.
 
template<size_t N = 0, typename Scalar = std::conditional_t<N == 0, uint32_t, typename SmallestInteger<N>::type>>
using PTransf
 Partial transformations with static or dynamic degree.
 

Functions

template<typename T>
std::vector< typename T::point_type > domain (T const &f)
 Returns the set of points where a partial transformation is defined.
 
template<typename T, typename Scalar>
void domain (T const &f, std::vector< Scalar > &dom)
 Replace the contents of a vector by the set of points where a partial transformation is defined.
 
template<typename T>
std::vector< typename T::point_type > image (T const &f)
 Returns the set of images of a partial transformation.
 
template<typename T, typename Scalar>
void image (T const &f, std::vector< Scalar > &im)
 Replace the contents of a vector by the set of images of a partial transformation.
 
template<size_t N, typename Scalar>
Perm< N, Scalar > inverse (Perm< N, Scalar > const &f)
 Returns the inverse of a permutation.
 
template<size_t N, typename Scalar>
void inverse (Perm< N, Scalar > const &from, Perm< N, Scalar > &to)
 Returns the inverse of a permutation.
 
template<size_t N, typename Scalar>
PPerm< N, Scalar > inverse (PPerm< N, Scalar > const &f)
 Returns the inverse of a partial perm.
 
template<size_t N, typename Scalar>
void inverse (PPerm< N, Scalar > const &from, PPerm< N, Scalar > &to)
 Replace contents of a partial perm with the inverse of another.
 
template<size_t N, typename Scalar>
PPerm< N, Scalar > left_one (PPerm< N, Scalar > const &f)
 Returns the left one of a partial perm.
 
template<typename T>
auto one (T const &f) -> std::enable_if_t< IsDerivedFromPTransf< T >, T >
 Returns the identity transformation of same degree as a sample.
 
template<size_t N, typename Scalar>
PPerm< N, Scalar > right_one (PPerm< N, Scalar > const &f)
 Returns the right one of a partial perm.
 
template<typename Scalar, typename Container>
void throw_if_image_value_out_of_range (PTransfBase< Scalar, Container > const &f)
 Check a partial transformation.
 
template<size_t N, typename Scalar>
void throw_if_image_value_out_of_range (Transf< N, Scalar > const &f)
 Check a transformation.
 
template<size_t N, typename Scalar>
auto throw_if_not_perm (Perm< N, Scalar > const &f)
 Check a permutation.
 
template<size_t N, typename Scalar>
void throw_if_not_pperm (PPerm< N, Scalar > const &f)
 Check a partial perm.
 

Variables

template<typename T>
static constexpr bool IsDerivedFromPTransf = std::is_base_of_v<detail::PTransfPolymorphicBase, T>
 Helper variable template.
 
template<typename T>
static constexpr bool IsDynamic = detail::IsDynamicHelper<T>::value
 Helper variable template.
 
template<typename T>
static constexpr bool IsPerm = detail::IsPermHelper<T>::value
 Helper variable template.
 
template<typename T>
static constexpr bool IsPPerm = detail::IsPPermHelper<T>::value
 Helper variable template.
 
template<typename T>
static constexpr bool IsPTransf = detail::IsPTransfHelper<T>::value
 Helper variable template.
 
template<typename T>
static constexpr bool IsStatic = detail::IsStaticHelper<T>::value
 Helper variable template.
 
template<typename T>
static constexpr bool IsTransf = detail::IsTransfHelper<T>::value
 Helper variable template.
 

Typedef Documentation

◆ LeastPerm

template<size_t N>
using LeastPerm = typename detail::LeastPermHelper<N>::type

Helper for getting the type of the least size, and fastest, permutation in libsemigroups or HPCombi that are defined on at most N points.

Defined in transf.hpp.

Template Parameters
Nthe maximum number of points the permutations will be defined on.

◆ LeastPPerm

template<size_t N>
using LeastPPerm = typename detail::LeastPPermHelper<N>::type

Helper for getting the type of the least size, and fastest, partial perm in libsemigroups or HPCombi that are defined on at most N points.

Defined in transf.hpp.

Template Parameters
Nthe maximum number of points the partial perms will be defined on.

◆ LeastTransf

template<size_t N>
using LeastTransf = typename detail::LeastTransfHelper<N>::type

Helper for getting the type of the least size, and fastest, transformation in libsemigroups or HPCombi that are defined on at most N points.

Defined in transf.hpp.

Template Parameters
Nthe maximum number of points the transformations will be defined on.

◆ PTransf

template<size_t N = 0, typename Scalar = std::conditional_t<N == 0, uint32_t, typename SmallestInteger<N>::type>>
using PTransf
Initial value:
std::
conditional_t<N == 0, DynamicPTransf<Scalar>, StaticPTransf<N, Scalar>>
Partial transformations with static degree.
Definition transf.hpp:828

Defined in transf.hpp.

This alias equals either DynamicPTransf or StaticPTransf depending on the template parameters N and Scalar.

If N is 0 (the default), then PTransf is DynamicPTransf. In this case the default value of Scalar is uint32_t. If N is not 0, then PTransf is StaticPTransf, and the default value of Scalar is the smallest integer type able to hold N. See also SmallestInteger.

Template Parameters
Nthe degree (default: 0).
Scalaran unsigned integer type (the type of the image values).

Function Documentation

◆ domain() [1/2]

template<typename T>
std::vector< typename T::point_type > domain ( T const & f)
nodiscard

Returns a std::vector containing those values i such that:

  • \(i\in \{0, \ldots, n - 1\}\) where \(n\) is PTransfBase::degree() of the 1st parameter f; and
  • f[i] != UNDEFINED.
Template Parameters
Tthe type of the 1st argument (Transf, libsemigroups::PTransf, PPerm, or Perm).
Parameters
fthe partial transformation whose image is sought.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
\(O(n)\) where \(n\) equals PTransfBase::degree() of f.
See also
image

◆ domain() [2/2]

template<typename T, typename Scalar>
void domain ( T const & f,
std::vector< Scalar > & dom )

Replaces the contents of the 2nd argument dom by those values i such that:

  • \(i\in \{0, \ldots, n - 1\}\) where \(n\) is PTransfBase::degree() of the 1st parameter f; and
  • f[i] != UNDEFINED.
Template Parameters
Tthe type of the 1st argument (Transf, libsemigroups::PTransf, PPerm, or Perm).
Scalarthe type of the values in the 2nd argument (typically T::point_type where T is the 1st template parameter).
Parameters
fthe partial transformation whose image is sought.
domvector to store the result.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
\(O(n)\) where \(n\) equals PTransfBase::degree() of f.
See also
image

◆ image() [1/2]

template<typename T>
std::vector< typename T::point_type > image ( T const & f)
nodiscard

Returns a std::vector containing those values f[i] such that:

  • \(i\in \{0, \ldots, n - 1\}\) where \(n\) is PTransfBase::degree() of the 1st parameter f; and
  • f[i] != UNDEFINED.
Template Parameters
Tthe type of the 1st argument (Transf, libsemigroups::PTransf, PPerm, or Perm).
Parameters
fthe partial transformation whose image is sought.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
\(O(n\log(n))\) where \(n\) equals PTransfBase::degree() of f.
See also
domain

◆ image() [2/2]

template<typename T, typename Scalar>
void image ( T const & f,
std::vector< Scalar > & im )

Replaces the contents of the 2nd argument im by those values f[i] where:

  • \(i\in \{0, \ldots, n - 1\}\) where \(n\) is PTransfBase::degree() of the 1st parameter f;
  • f[i] != UNDEFINED.
Template Parameters
Tthe type of the 1st argument (Transf, libsemigroups::PTransf, PPerm, or Perm).
Scalarthe type of the values in the 2nd argument (typically T::point_type where T is the 1st template parameter.
Parameters
fthe partial transformation whose image is sought.
imvector to store the result.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
\(O(n\log(n))\) where \(n\) equals PTransfBase::degree() of f.
See also
domain

◆ inverse() [1/4]

template<size_t N, typename Scalar>
Perm< N, Scalar > inverse ( Perm< N, Scalar > const & f)
nodiscard

This function returns a newly constructed inverse of f. The inverse of a permutation \(f\) is the permutation \(g\) such that \(fg = gf\) is the identity permutation of degree \(N\).

Template Parameters
Nthe degree of f.
Scalarthe type of points of f.
Parameters
fthe permutation to invert.
Returns
A value of type PPerm.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Linear in f.degree().

◆ inverse() [2/4]

template<size_t N, typename Scalar>
void inverse ( Perm< N, Scalar > const & from,
Perm< N, Scalar > & to )

This function inverts from into to. The inverse of a permutation \(f\) is the permutation \(g\) such that \(fg = gf\) is the identity permutation of degree \(n\).

Template Parameters
Nthe degree of f.
Scalarthe type of points of f.
Parameters
fromthe permutation to invert.
tothe permutation to hold the inverse of from.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Linear in f.degree().

◆ inverse() [3/4]

template<size_t N, typename Scalar>
PPerm< N, Scalar > inverse ( PPerm< N, Scalar > const & f)
nodiscard

This function returns a newly constructed inverse of f. The inverse of a partial permutation \(f\) is the partial perm \(g\) such that \(fgf = f\) and \(gfg = g\).

Template Parameters
Nthe degree of f.
Scalarthe type of points.
Parameters
fthe partial perm to invert.
Returns
A value of type PPerm.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Linear in f.degree().
See also
right_one and left_one

◆ inverse() [4/4]

template<size_t N, typename Scalar>
void inverse ( PPerm< N, Scalar > const & from,
PPerm< N, Scalar > & to )

This function inverts from into to. The inverse of a partial permutation \(f\) is the partial perm \(g\) such that \(fgf = f\) and \(gfg = g\).

Parameters
fromthe partial perm to invert.
tothe partial perm to hold the inverse of from.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Linear in f.degree().

◆ left_one()

template<size_t N, typename Scalar>
PPerm< N, Scalar > left_one ( PPerm< N, Scalar > const & f)
nodiscard

This function returns a newly constructed partial perm with degree equal to N that fixes every value in the domain of f, and is UNDEFINED on any other values.

Parameters
fthe partial perm.
Returns
A value of type PPerm<N, Scalar>.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Linear in f.degree().

◆ one()

template<typename T>
auto one ( T const & f) -> std::enable_if_t<IsDerivedFromPTransf<T>, T>
nodiscard

This function returns a newly constructed partial transformation with degree equal to the degree of f that fixes every value from 0 to f.degree() - 1.

Template Parameters
Tthe type of the transformation being constructed (Perm, PPerm, Transf, or PTransf).
Returns
A value of type T.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Linear in f.degree().

◆ right_one()

template<size_t N, typename Scalar>
PPerm< N, Scalar > right_one ( PPerm< N, Scalar > const & f)
nodiscard

This function returns a newly constructed partial perm with degree equal to N that fixes every value in the image of the argument f, and is UNDEFINED on any other values.

Parameters
fthe partial perm.
Returns
A value of type PPerm<N, Scalar>.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Linear in f.degree().

◆ throw_if_image_value_out_of_range() [1/2]

template<typename Scalar, typename Container>
void throw_if_image_value_out_of_range ( PTransfBase< Scalar, Container > const & f)
Template Parameters
Nthe degree.
Scalaran unsigned integer type (the type of the image values).
Parameters
fthe partial transformation to check.
Exceptions
LibsemigroupsExceptionif any of the following hold:
  • the size of cont is incompatible with T::container_type.
  • any value in cont exceeds cont.size() and is not equal to UNDEFINED.
Complexity
Linear in degree().

◆ throw_if_image_value_out_of_range() [2/2]

template<size_t N, typename Scalar>
void throw_if_image_value_out_of_range ( Transf< N, Scalar > const & f)
Template Parameters
Nthe number of points.
Scalarthe type of the points.
Parameters
fthe transformation.
Exceptions
LibsemigroupsExceptionif the image of any point exceeds f.degree() or is equal to UNDEFINED.
Complexity
Linear in f.degree().

◆ throw_if_not_perm()

template<size_t N, typename Scalar>
auto throw_if_not_perm ( Perm< N, Scalar > const & f)
Template Parameters
Nthe first template parameter of Perm.
Scalarthe second template parameter of Perm.
Parameters
fthe permutation.
Exceptions
LibsemigroupsExceptionif:
  • the image of any point in f exceeds f.degree()
  • f is not injective
Complexity
Linear in f.degree().

◆ throw_if_not_pperm()

template<size_t N, typename Scalar>
void throw_if_not_pperm ( PPerm< N, Scalar > const & f)
Template Parameters
Tthe type of the partial perm to check.
Parameters
fthe partial perm.
Exceptions
LibsemigroupsExceptionif:
  • the image of any point in f exceeds f.degree() and is not equal to UNDEFINED; or
  • f is not injective
Complexity
Linear in f.degree().

Variable Documentation

◆ IsDerivedFromPTransf

template<typename T>
bool IsDerivedFromPTransf = std::is_base_of_v<detail::PTransfPolymorphicBase, T>
staticconstexpr

The value of this variable is true if the template parameter T is derived from PTransfPolymorphicBase.

Template Parameters
Ta type.

◆ IsDynamic

template<typename T>
bool IsDynamic = detail::IsDynamicHelper<T>::value
staticconstexpr

The value of this variable is true if the template parameter T is derived from DynamicPTransf.

Template Parameters
Ta type.

◆ IsPerm

template<typename T>
bool IsPerm = detail::IsPermHelper<T>::value
staticconstexpr

The value of this variable is true if the template parameter T is Perm for any template parameters.

Template Parameters
Ta type.

◆ IsPPerm

template<typename T>
bool IsPPerm = detail::IsPPermHelper<T>::value
staticconstexpr

The value of this variable is true if the template parameter T is PPerm for any template parameters.

Template Parameters
Ta type.

◆ IsPTransf

template<typename T>
bool IsPTransf = detail::IsPTransfHelper<T>::value
staticconstexpr

The value of this variable is true if the template parameter T is either DynamicPTransf or StaticPTransf for any template parameters.

Template Parameters
Ta type.
See also
libsemigroups::IsStatic and libsemigroups::IsDynamic

◆ IsStatic

template<typename T>
bool IsStatic = detail::IsStaticHelper<T>::value
staticconstexpr

The value of this variable is true if the template parameter T is derived from StaticPTransf.

Template Parameters
Ta type.

◆ IsTransf

template<typename T>
bool IsTransf = detail::IsTransfHelper<T>::value
staticconstexpr

The value of this variable is true if the template parameter T is Transf for any template parameters.

Template Parameters
Ta type.