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

This page describes the functionality for \(m \times n\) boolean matrices for arbitrary dimensions \(m\) and \(n\). There are two types of such boolean matrices those whose dimension is known at compile-time, and those where it is not. Both types can be accessed via the alias template BMat<R, C>: if R or C has value 0, then the dimensions can be set at run time, otherwise the dimensions are R and C. The default value of R is 0 and of C is R.

The alias BMat<R, C> is either StaticMatrix, DynamicMatrix (compile-time arithmetic), or DynamicMatrix (run-time arithmetic), please refer to the documentation of these class templates for more details. The only substantial difference in the interface of static and dynamic is that the former can be default constructed and the latter should be constructed using the dimensions.

Adapters for BMat objects are documented here.

Example
// default construct an uninitialized 3 x 3 static matrix
// construct an uninitialized 4 x 4 dynamic matrix
BMat<> m(4, 4);
std::conditional_t< R==0||C==0, DynamicBMat, StaticBMat< R, C > > BMat
Alias template for boolean matrices.
Definition matrix.hpp:3963

Classes

struct  BooleanOne
 Function object for returning the multiplicative identity. More...
 
struct  BooleanPlus
 Function object for addition in the boolean semiring. More...
 
struct  BooleanProd
 Function object for multiplication in the boolean semiring. More...
 
struct  BooleanZero
 Function object for returning the additive identity. More...
 

Typedefs

template<size_t R = 0, size_t C = R>
using BMat = std::conditional_t<R == 0 || C == 0, DynamicBMat, StaticBMat<R, C>>
 Alias template for boolean matrices.
 
using DynamicBMat = DynamicMatrix<BooleanPlus, BooleanProd, BooleanZero, BooleanOne, int>
 Alias for dynamic boolean matrices.
 
template<size_t R, size_t C>
using StaticBMat
 Alias for static boolean matrices.
 

Functions

template<typename Mat>
std::enable_if_t< IsBMat< Mat > > throw_if_bad_entry (Mat const &, typename Mat::scalar_type val)
 Check an entry in a boolean matrix is valid.
 
template<typename Mat>
std::enable_if_t< IsBMat< Mat > > throw_if_bad_entry (Mat const &m)
 Check the entries in a boolean matrix are valid.
 

Variables

template<typename T>
static constexpr bool IsBMat = detail::IsBMatHelper<T>::value
 Helper to check if a type is BMat.
 

Typedef Documentation

◆ BMat

template<size_t R = 0, size_t C = R>
using BMat = std::conditional_t<R == 0 || C == 0, DynamicBMat, StaticBMat<R, C>>

Defined in matrix.hpp.

Alias template for boolean matrices.

Template Parameters
Rthe number of rows of the matrix. A value of 0 (the default value) indicates that the dimensions will be set at run time.
Cthe number of columns of the matrix. A value of 0 indicates that the dimensions will be set at run time (the default value is R).

◆ DynamicBMat

using DynamicBMat = DynamicMatrix<BooleanPlus, BooleanProd, BooleanZero, BooleanOne, int>

Defined in matrix.hpp.

Alias for the type of dynamic boolean matrices where the dimensions of the matrices can be defined at run time.

◆ StaticBMat

template<size_t R, size_t C>
using StaticBMat
Initial value:
R,
C,
int>
Static matrix class.
Definition matrix.hpp:1859
Function object for returning the multiplicative identity.
Definition matrix.hpp:3874
Function object for addition in the boolean semiring.
Definition matrix.hpp:3820
Function object for multiplication in the boolean semiring.
Definition matrix.hpp:3847
Function object for returning the additive identity.
Definition matrix.hpp:3899

Defined in matrix.hpp.

Alias for the type of static boolean matrices where the dimensions of the matrices are defined at compile time.

Template Parameters
Rthe number of rows.
Cthe number of columns.

Function Documentation

◆ throw_if_bad_entry() [1/2]

template<typename Mat>
std::enable_if_t< IsBMat< Mat > > throw_if_bad_entry ( Mat const & ,
typename Mat::scalar_type val )

Defined in matrix.hpp.

This function can be used to check that a matrix contains values in the underlying semiring.

Template Parameters
Matthe type of the 1st argument, must satisfy IsBMat<Mat>.
Parameters
valthe entry to check.
Exceptions
LibsemigroupsExceptionif val is not 0 or 1. The values in a boolean matrix are of type int, but a matrix shouldn't contain values except 0 and 1.

◆ throw_if_bad_entry() [2/2]

template<typename Mat>
std::enable_if_t< IsBMat< Mat > > throw_if_bad_entry ( Mat const & m)

Defined in matrix.hpp.

This function can be used to check that a matrix contains values in the underlying semiring.

Template Parameters
Matthe type of m, must satisfy IsBMat<Mat>.
Parameters
mthe boolean matrix to check.
Exceptions
LibsemigroupsExceptionif any of the entries in the matrix are not 0 or 1. The values in a boolean matrix are of type int, but a matrix shouldn't contain values except 0 and 1.

Variable Documentation

◆ IsBMat

template<typename T>
bool IsBMat = detail::IsBMatHelper<T>::value
staticconstexpr

Defined in matrix.hpp.

This variable has value true if the template parameter T is the same as BMat<R, C> for some values of R and C.

Template Parameters
Tthe type to check.