libsemigroups  v3.0.0
C++ library for semigroups and monoids
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Loading...
Searching...
No Matches

Defined in pbr.hpp.

Partitioned binary relations (PBRs) are a generalisation of a bipartitions, and were introduced by Martin and Mazorchuk in [44].

See also
pbr::throw_if_invalid(PBR const&).

Public Types

template<typename T>
using initializer_list_type = std::initializer_list<std::vector<T>> const&
 Type of constructor argument.
 
template<typename T>
using vector_type = std::vector<std::vector<T>> const&
 Type of constructor argument.
 

Public Member Functions

 PBR ()=delete
 Deleted.
 
 PBR (initializer_list_type< int32_t > left, initializer_list_type< int32_t > right)
 Construct from adjacencies 1 to n and -1 to -n.
 
 PBR (initializer_list_type< uint32_t > x)
 Construct from adjacencies 0 to 2n - 1.
 
 PBR (PBR &&)=default
 Default move constructor.
 
 PBR (PBR const &)=default
 Default copy constructor.
 
 PBR (size_t n)
 Construct empty PBR of given degree.
 
 PBR (vector_type< int32_t > left, vector_type< int32_t > right)
 Construct from adjacencies 1 to n and -1 to -n.
 
 PBR (vector_type< uint32_t > x)
 Construct from adjacencies 0 to 2n - 1.
 
std::vector< uint32_t > & at (size_t i)
 Returns a reference to the points adjacent to a given point, with bounds checking.
 
std::vector< uint32_t > const & at (size_t i) const
 Returns a const reference to the points adjacent to a given point, with bounds checking.
 
size_t degree () const noexcept
 Returns the degree of a PBR.
 
size_t hash_value () const
 Returns a hash value for a PBR.
 
size_t number_of_points () const noexcept
 Returns the number of points of a PBR.
 
bool operator< (PBR const &that) const
 Compare for less.
 
PBRoperator= (PBR &&)=default
 Default move assignment operator.
 
PBRoperator= (PBR const &)=default
 Default copy assignment operator.
 
bool operator== (PBR const &that) const
 Compare two PBRs for equality.
 
std::vector< uint32_t > & operator[] (size_t i)
 Returns a reference to the points adjacent to a given point.
 
std::vector< uint32_t > const & operator[] (size_t i) const
 Returns a const reference to the points adjacent to a given point.
 
void product_inplace (PBR const &x, PBR const &y, size_t thread_id=0)
 Multiply two PBR objects and store the product in this.
 
void product_inplace_no_checks (PBR const &x, PBR const &y, size_t thread_id=0)
 Multiply two PBR objects and store the product in this.
 

Related Symbols

(Note that these are not member symbols.)

template<typename Return, typename... T>
enable_if_is_same< Return, PBRmake (T... args)
 Construct and check a PBR.
 
bool operator!= (PBR const &x, PBR const &y)
 Compare two PBRs for inequality.
 
PBR operator* (PBR const &x, PBR const &y)
 Multiply two PBRs.
 
bool operator<= (PBR const &x, PBR const &y)
 Convenience function that just calls operator< and operator==.
 
bool operator> (PBR const &x, PBR const &y)
 Convenience function that just calls operator<.
 
bool operator>= (PBR const &x, PBR const &y)
 Convenience function that just calls operator<=.
 
std::string to_human_readable_repr (PBR const &x)
 Return a human readable representation of a PBR.
 

Member Typedef Documentation

◆ initializer_list_type

template<typename T>
using initializer_list_type = std::initializer_list<std::vector<T>> const&

Type of constructor argument.

◆ vector_type

template<typename T>
using vector_type = std::vector<std::vector<T>> const&

Type of constructor argument.

Constructor & Destructor Documentation

◆ PBR() [1/8]

PBR ( )
delete

Deleted. To avoid the situation where the underlying container is not defined, it is not possible to default construct a PBR object.

◆ PBR() [2/8]

PBR ( PBR const & )
default

Default copy constructor.

◆ PBR() [3/8]

PBR ( PBR && )
default

Default move constructor.

◆ PBR() [4/8]

PBR ( vector_type< uint32_t > x)
explicit

Construct from adjacencies 0 to 2n - 1.

The parameter x must be a container of vectors of uint32_t with size 2n for some integer n, and the vector in position i is the list of points adjacent to i in the PBR constructed.

Parameters
xthe container of vectors of adjacencies.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Warning
No checks whatsoever on the validity of x are performed.
See also
throw_if_invalid(PBR const&)

◆ PBR() [5/8]

PBR ( initializer_list_type< uint32_t > x)
explicit

Construct from adjacencies 0 to 2n - 1.

The parameter x must be a container of vectors of uint32_t with size 2n for some integer n, and the vector in position i is the list of points adjacent to i in the PBR constructed.

Parameters
xthe container of vectors of adjacencies.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Warning
No checks whatsoever on the validity of x are performed.
See also
throw_if_invalid(PBR const&)

◆ PBR() [6/8]

PBR ( size_t n)
explicit

Construct empty PBR of given degree.

Parameters
nthe degree.
Exceptions
This function guarantees not to throw a LibsemigroupsException.

◆ PBR() [7/8]

PBR ( initializer_list_type< int32_t > left,
initializer_list_type< int32_t > right )

Construct from adjacencies 1 to n and -1 to -n.

The parameters left and right should be containers of n vectors of integer values, so that the vector in position i of left is the list of points adjacent to i in the PBR, and the vector in position i of right is the list of points adjacent to n+i in the PBR. A negative value i corresponds to ni.

Parameters
leftcontainer of adjacencies of 1 to n.
rightcontainer of adjacencies of n + 1 to 2n.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Warning
No checks whatsoever on the validity of left or right are performed.
See also
throw_if_invalid(PBR const&) and make(initializer_list_type<int32_t>, initializer_list_type<int32_t>)

◆ PBR() [8/8]

PBR ( vector_type< int32_t > left,
vector_type< int32_t > right )

Construct from adjacencies 1 to n and -1 to -n.

The parameters left and right should be containers of n vectors of integer values, so that the vector in position i of left is the list of points adjacent to i in the PBR, and the vector in position i of right is the list of points adjacent to n+i in the PBR. A negative value i corresponds to ni.

Parameters
leftcontainer of adjacencies of 1 to n.
rightcontainer of adjacencies of n + 1 to 2n.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Warning
No checks whatsoever on the validity of left or right are performed.
See also
throw_if_invalid(PBR const&) and make(initializer_list_type<int32_t>, initializer_list_type<int32_t>)

Member Function Documentation

◆ at() [1/2]

std::vector< uint32_t > & at ( size_t i)

Returns a reference to the points adjacent to a given point, with bounds checking.

Parameters
ithe point.
Returns
A value reference to a std::vector<uint32_t>.
Exceptions
std::out_of_rangeif i > number_of_points().
Complexity
Constant.

◆ at() [2/2]

std::vector< uint32_t > const & at ( size_t i) const

Returns a const reference to the points adjacent to a given point, with bounds checking.

Parameters
ithe point.
Returns
A value const reference to a std::vector<uint32_t>.
Exceptions
std::out_of_rangeif i > number_of_points().
Complexity
Constant.

◆ degree()

size_t degree ( ) const
noexcept

Returns the degree of a PBR, where the degree of a PBR is half the number of points in the PBR.

Returns
A value of type size_t.
Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant.

◆ hash_value()

size_t hash_value ( ) const
inline

Returns a hash value for a PBR.

Returns
A hash value for a this.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Linear in degree().
Note
This value is recomputed every time this function is called.

◆ number_of_points()

size_t number_of_points ( ) const
noexcept

Returns the number of points of a PBR.

Returns
A value of type size_t.
Exceptions
This function is noexcept and is guaranteed never to throw.
Complexity
Constant.

◆ operator<()

bool operator< ( PBR const & that) const
inline

Compare for less.

Parameters
thata PBR to compare with.
Returns
true if this is less than that, and false otherwise.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
At worst linear in degree().

◆ operator=()

PBR & operator= ( PBR const & )
default

Default copy assignment operator.

◆ operator==()

bool operator== ( PBR const & that) const
inline

Compare two PBRs for equality.

Parameters
thata PBR to compare with.
Returns
true if this equals that, and false otherwise.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
At worst linear in degree().

◆ operator[]() [1/2]

std::vector< uint32_t > & operator[] ( size_t i)
inline

Returns a reference to the points adjacent to a given point.

Parameters
ithe point.
Returns
A value reference to a std::vector<uint32_t>.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Constant.

◆ operator[]() [2/2]

std::vector< uint32_t > const & operator[] ( size_t i) const
inline

Returns a const reference to the points adjacent to a given point.

Parameters
ithe point.
Returns
A value const reference to a std::vector<uint32_t>.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Constant.

◆ product_inplace()

void product_inplace ( PBR const & x,
PBR const & y,
size_t thread_id = 0 )

Replaces the contents of this by the product of x and y.

The parameter thread_id is required since some temporary storage is required to find the product of x and y. Note that if different threads call this member function with the same value of thread_id then bad things will happen.

Parameters
xa PBR.
ya PBR.
thread_idthe index of the calling thread (defaults to 0).
Exceptions
LibsemigroupsExceptionif:
  • the degree() of x is not the same as the degree() of y;
  • the degree() of *this is not the same as the degree() of x;
  • one if the addresses &x and &y is the same as that of this; or
  • either x or y are invalid.
See also
throw_if_invalid.

◆ product_inplace_no_checks()

void product_inplace_no_checks ( PBR const & x,
PBR const & y,
size_t thread_id = 0 )

Replaces the contents of this by the product of x and y.

The parameter thread_id is required since some temporary storage is required to find the product of x and y. Note that if different threads call this member function with the same value of thread_id then bad things will happen.

Parameters
xa PBR.
ya PBR.
thread_idthe index of the calling thread (defaults to 0).
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Warning
No checks are made on whether or not the parameters are compatible. If x and y have different degrees, then bad things will happen.

Friends And Related Symbol Documentation

◆ make()

template<typename Return, typename... T>
enable_if_is_same< Return, PBR > make ( T... args)
related

Construct and check a PBR.

Template Parameters
Returnthe return type. Must satisfy std::is_same<Return, PBR>.
Tthe types of the arguments.
Parameters
argsthe arguments to forward to the PBR constructor.
Returns
A PBR constructed from args and checked.
Exceptions
LibsemigroupsExceptionif libsemigroups::throw_if_invalid(PBR const&) throws when called with the constructed PBR.
Warning
No checks are performed on the validity of args prior to the construction of the PBR object.
See also
PBR.

◆ operator!=()

bool operator!= ( PBR const & x,
PBR const & y )
related

Compare two PBRs for inequality.

Parameters
xa PBR.
ya PBR.
Returns
true if this is not equal to that, and false otherwise.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
At worst quadratic in the degree of x and y.

◆ operator*()

PBR operator* ( PBR const & x,
PBR const & y )
related

Returns a newly constructed PBR equal to the product of x and y.

Parameters
xa PBR.
ya PBR.
Returns
A value of type PBR
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
Cubic in degree().

◆ operator<=()

bool operator<= ( PBR const & x,
PBR const & y )
related

Convenience function that just calls operator< and operator==.

◆ operator>()

bool operator> ( PBR const & x,
PBR const & y )
related

Convenience function that just calls operator<.

◆ operator>=()

bool operator>= ( PBR const & x,
PBR const & y )
related

Convenience function that just calls operator<=.

◆ to_human_readable_repr()

std::string to_human_readable_repr ( PBR const & x)
related

Return a human readable representation of a PBR.

Parameters
xthe PBR object.
Returns
A value of type std::string.
Exceptions
This function guarantees not to throw a LibsemigroupsException.

The documentation for this class was generated from the following file: