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

This namespace contains various helper functions for the various matrix classes in libsemigroups. These functions could have been member functions of the matrix classes but they only use public member functions, and so they are declared as free functions instead.

Functions

template<typename Mat, typename Container>
std::decay_t< Container > bitset_row_basis (Container &&rows)
 Returns a basis for the space spanned by some bit sets.
 
template<typename Mat, typename Container>
void bitset_row_basis (Container &&rows, std::decay_t< Container > &result)
 Appends a basis for the space spanned by some bitsets to a container.
 
template<typename Mat, size_t M = detail::BitSetCapacity<Mat>::value>
detail::StaticVector1< BitSet< M >, M > bitset_row_basis (Mat const &x)
 Returns a basis for the space spanned by the rows of the boolean matrix.
 
template<typename Mat, typename Container>
void bitset_row_basis (Mat const &x, Container &result)
 Appends a basis for the rowspace of a boolean matrix to a container.
 
template<typename Mat, size_t R, size_t C, typename Container>
auto bitset_rows (Container &&views)
 Converts a container of row views of a boolean matrix to bit sets, and return them.
 
template<typename Mat, size_t R, size_t C, typename Container>
void bitset_rows (Container &&views, detail::StaticVector1< BitSet< C >, R > &result)
 Converts a container of row views of a boolean matrix to bit sets, and append them to another container.
 
template<typename Mat>
auto bitset_rows (Mat const &x)
 Computes the rows of a boolean matrix as bit sets.
 
template<typename Mat, size_t R, size_t C>
void bitset_rows (Mat const &x, detail::StaticVector1< BitSet< C >, R > &result)
 Computes the rows of a boolean matrix as bit sets and appends them to a container.
 
template<size_t T, size_t P, typename Scalar>
constexpr Scalar period (DynamicNTPMatWithoutSemiring< T, P, Scalar > const &) noexcept
 Returns the period of a dynamic ntp matrix.
 
template<typename Scalar>
Scalar period (DynamicNTPMatWithSemiring< Scalar > const &x) noexcept
 Returns the period of a dynamic ntp matrix.
 
template<size_t T, size_t P, size_t R, size_t C, typename Scalar>
constexpr Scalar period (StaticNTPMat< T, P, R, C, Scalar > const &) noexcept
 Returns the period of a static ntp matrix.
 
template<typename Mat>
Mat pow (Mat const &x, typename Mat::scalar_type e)
 Returns a power of a matrix.
 
template<typename Mat, typename Container>
std::decay_t< Container > row_basis (Container &&rows)
 Returns a row basis for the space spanned by a container of row views.
 
template<typename Mat, typename Container>
std::enable_if_t< IsMaxPlusTruncMat< Mat > > row_basis (Container &&views, std::decay_t< Container > &result)
 Appends a basis for a space spanned by row views or bit sets to a container.
 
template<typename Mat, typename Container>
std::enable_if_t< IsBMat< Mat > > row_basis (Container &&views, std::decay_t< Container > &result)
 Appends a row space basis (consisting of row views) for the row space spanned by some rows.
 
template<typename Mat, typename = std::enable_if_t<IsDynamicMatrix<Mat>>>
std::vector< typename Mat::RowView > row_basis (Mat const &x)
 Returns a row space basis of a dynamic matrix as a std::vector of row views.
 
template<typename Mat, typename = std::enable_if_t<IsStaticMatrix<Mat>>>
detail::StaticVector1< typename Mat::RowView, Mat::nr_rows > row_basis (Mat const &x)
 Returns a row space basis of a static matrix as a static vector of row views.
 
template<typename Mat, typename Container, typename = std::enable_if_t<IsMatrix<Mat>>>
void row_basis (Mat const &x, Container &result)
 Appends a basis (consisting of row views) for the row space of a matrix to a container.
 
template<typename Mat, typename = std::enable_if_t<IsBMat<Mat>>>
size_t row_space_size (Mat const &x)
 Returns the size of the row space of a boolean matrix.
 
template<typename Mat, typename = std::enable_if_t<IsDynamicMatrix<Mat>>>
std::vector< typename Mat::RowView > rows (Mat const &x)
 Returns a std::vector of row views into the rows of a dynamic matrix.
 
template<typename Mat, typename = std::enable_if_t<IsStaticMatrix<Mat>>>
detail::StaticVector1< typename Mat::RowView, Mat::nr_rows > rows (Mat const &x)
 Returns a static vector of row views into the rows of a static matrix.
 
template<typename Mat>
constexpr auto threshold (Mat const &) noexcept -> std::enable_if_t<!detail::IsTruncMat< Mat >, typename Mat::scalar_type >
 Returns the threshold of a matrix.
 
template<typename Mat>
auto threshold (Mat const &x) noexcept -> std::enable_if_t< detail::IsTruncMat< Mat > &&IsMatWithSemiring< Mat >, typename Mat::scalar_type >
 Returns the threshold of a matrix over a truncated semiring.
 
template<typename Mat>
auto throw_if_bad_coords (Mat const &x, size_t r, size_t c) -> std::enable_if_t< IsMatrix< Mat > >
 Throws the arguments do not index an entry of a matrix.
 
template<typename Mat>
auto throw_if_bad_dim (Mat const &x, Mat const &y) -> std::enable_if_t< IsMatrix< Mat > >
 Throws if two matrices do not have the same dimensions.
 
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< IsIntMat< Mat > > throw_if_bad_entry (Mat const &, typename Mat::scalar_type val)
 Check that an entry in an integer matrix is valid.
 
template<typename Mat>
std::enable_if_t< IsMaxPlusMat< Mat > > throw_if_bad_entry (Mat const &, typename Mat::scalar_type val)
 Check that an entry in a max-plus matrix is valid.
 
template<typename Mat>
std::enable_if_t< IsMinPlusMat< Mat > > throw_if_bad_entry (Mat const &, typename Mat::scalar_type val)
 Check that an entry in a min-plus 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.
 
template<typename Mat>
std::enable_if_t< IsMaxPlusTruncMat< Mat > > throw_if_bad_entry (Mat const &m)
 Check that a truncated max-plus matrix is valid.
 
template<typename Mat>
std::enable_if_t< IsMinPlusTruncMat< Mat > > throw_if_bad_entry (Mat const &m)
 Check that a truncated min-plus matrix is valid.
 
template<typename Mat>
std::enable_if_t< IsNTPMat< Mat > > throw_if_bad_entry (Mat const &m)
 Check that the entries in an ntp matrix are valid.
 
template<typename Mat>
std::enable_if_t< IsMaxPlusTruncMat< Mat > > throw_if_bad_entry (Mat const &m, typename Mat::scalar_type val)
 Check that an entry in a truncated max-plus matrix is valid.
 
template<typename Mat>
std::enable_if_t< IsMinPlusTruncMat< Mat > > throw_if_bad_entry (Mat const &m, typename Mat::scalar_type val)
 Check that an entry in a truncated min-plus matrix is valid.
 
template<typename Mat>
std::enable_if_t< IsNTPMat< Mat > > throw_if_bad_entry (Mat const &m, typename Mat::scalar_type val)
 Check that an entry in an ntp matrix is valid.
 
template<typename Mat>
std::enable_if_t< IsIntMat< Mat > > throw_if_bad_entry (Mat const &x)
 Check that an integer matrix is valid.
 
template<typename Mat>
std::enable_if_t< IsMinPlusMat< Mat > > throw_if_bad_entry (Mat const &x)
 Check that a min-plus matrix is valid.
 
template<typename Mat>
constexpr std::enable_if_t< IsProjMaxPlusMat< Mat > > throw_if_bad_entry (Mat const &x)
 Check that the entries in a projective max-plus matrix are valid.
 
template<typename Mat>
auto throw_if_bad_entry (Mat const &x) -> std::enable_if_t< IsMaxPlusMat< Mat > >
 Check that a max-plus matrix is valid.
 
template<typename Mat>
constexpr std::enable_if_t< IsProjMaxPlusMat< Mat > > throw_if_bad_entry (Mat const &x, typename Mat::scalar_type val)
 Check that an entry in a projective max-plus matrix is valid.
 
template<typename Mat>
auto throw_if_not_square (Mat const &x) -> std::enable_if_t< IsMatrix< Mat > >
 Throws if a matrix is not square.
 

Function Documentation

◆ bitset_row_basis() [1/4]

template<typename Mat, typename Container>
std::decay_t< Container > bitset_row_basis ( Container && rows)

Defined in matrix.hpp.

Returns a basis for the space spanned by the bit sets in rows.

Template Parameters
Mata type such that IsBMat<Mat> is true.
Containera container type such that Container::value_type is BitSet<M> or std::bitset<M> for some M.
Parameters
rowscontainer of spanning rows represented by bit sets.
Returns
A container of type std::decay_t<Container> containing the row basis consisting of bit sets.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
\(O(r ^ 2 c)\) where \(r\) is the size of rows and \(c\) is the size of each bitset in rows.

◆ bitset_row_basis() [2/4]

template<typename Mat, typename Container>
void bitset_row_basis ( Container && rows,
std::decay_t< Container > & result )

Defined in matrix.hpp.

Appends a basis for the space spanned by the bitsets in rows to the container result.

Template Parameters
Mata type such that IsBMat<Mat> is true.
Containera container type with Container::value_type being BitSet<M> or std::bitset<M> for some M.
Parameters
rowscontainer of spanning rows represented by bit sets.
resultcontainer for the resulting row basis.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
\(O(r ^ 2 c)\) where \(r\) is the size of rows and \(c\) is the size of each bitset in rows.

◆ bitset_row_basis() [3/4]

template<typename Mat, size_t M = detail::BitSetCapacity<Mat>::value>
detail::StaticVector1< BitSet< M >, M > bitset_row_basis ( Mat const & x)

Defined in matrix.hpp.

This function returns a basis for the space spanned by the rows of the boolean matrix x.

Template Parameters
Mata type such that IsBMat<Mat> is true.
Man upper bound for the dimensions of the returned container. If IsStaticMatrix<Mat> is true, then M is the number of rows (or columns) in the square matrix x. Otherwise, if IsDynamicMatrix<Mat> is true, then M is BitSet<1>::max_size().
Parameters
xthe boolean matrix.
Returns
A container of type detail::StaticVector1<BitSet<M>, M>> containing the row basis of x consisting of bitsets.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
\(O(r ^ 2 c)\) where \(r\) is the number of rows in x and \(c\) is the number of columns in x.

◆ bitset_row_basis() [4/4]

template<typename Mat, typename Container>
void bitset_row_basis ( Mat const & x,
Container & result )

Defined in matrix.hpp.

This function appends a basis for the rowspace of the boolean matrix x to the container result.

Template Parameters
Mata type such that IsBMat<Mat> is true.
Containera container type with Container::value_type equal to BitSet<M> or std::bitset<M> for some M.
Parameters
xthe boolean matrix.
resultcontainer for the resulting rowbasis.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
\(O(r ^ 2 c)\) where \(r\) is the number of rows in x and \(c\) is the number of columns in x.

◆ bitset_rows() [1/4]

template<typename Mat, size_t R, size_t C, typename Container>
auto bitset_rows ( Container && views)

Defined in matrix.hpp.

This function converts the container of row views views of a boolean matrix to bit sets, and return them.

Template Parameters
Matthe type of matrix. This must be a type so that IsBMat<Mat> is true.
Ran upper bound for the number of rows in views. This value must be at most BitSet<1>::max_size().
Can upper bound for the number of columns in each row represented in views. This value must be at most BitSet<1>::max_size().
Containerthe type of the container views, should be std::vector or detail::StaticVector1.
Parameters
viewsa container of Mat::RowView or std::vector<bool>.
Returns
A value of type detail::StaticVector1<BitSet<C>, R>.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
\(O(mn)\) where \(m\) is the number of rows in views and and \(n\) is the number of columns in any vector in views.

◆ bitset_rows() [2/4]

template<typename Mat, size_t R, size_t C, typename Container>
void bitset_rows ( Container && views,
detail::StaticVector1< BitSet< C >, R > & result )

Defined in matrix.hpp.

This function converts the row views (of a boolean matrix) in a container to bit sets and appends them to result.

Template Parameters
Matthe type of matrix. This must be a type so that IsBMat<Mat> is true.
Ran upper bound for the number of rows in views. This value must be at most BitSet<1>::max_size().
Can upper bound for the number of columns in each row represented in views. This value must be at most BitSet<1>::max_size().
Containerthe type of the container views, should be std::vector or detail::StaticVector1.
Parameters
viewsa container of Mat::RowView or std::vector<bool>.
resulta static vector of bit sets to contain the resulting bit sets.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
\(O(mn)\) where \(m\) is the number of rows in views and and \(n\) is the number of columns in any vector in views.

◆ bitset_rows() [3/4]

template<typename Mat>
auto bitset_rows ( Mat const & x)

Defined in matrix.hpp.

This functions returns the rows of a boolean matrix as bit sets.

Template Parameters
Matthe type of matrix. Must satisfy IsBMat<Mat>.
Parameters
xthe boolean matrix.
Returns
A value of type detail::StaticVector1<BitSet<C>, R>.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
\(O(mn)\) where \(m\) is the number of rows in x and and \(n\) is the number of columns in x.

◆ bitset_rows() [4/4]

template<typename Mat, size_t R, size_t C>
void bitset_rows ( Mat const & x,
detail::StaticVector1< BitSet< C >, R > & result )

Defined in matrix.hpp.

Computes the rows of the matrix x as bit sets and appends them to result.

Template Parameters
Matthe type of matrix. This must be a type so that IsBMat<Mat> is true.
Ran upper bound for the number of rows in views. This value must be at most BitSet<1>::max_size().
Can upper bound for the number of columns in each row represented in views. This value must be at most BitSet<1>::max_size().
Parameters
xthe boolean matrix.
resultthe container to append the rows of x to.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
\(O(mn)\) where \(m\) is the number of rows in x and and \(n\) is the number of columns in x.

◆ period() [1/3]

template<size_t T, size_t P, typename Scalar>
Scalar period ( DynamicNTPMatWithoutSemiring< T, P, Scalar > const & )
constexprnoexcept

Defined in matrix.hpp.

This function returns the template parameter P of a dynamic ntp matrix.

Template Parameters
Tthe threshold.
Pthe period.
Scalarthe type of the entries in the matrix.
Returns
The template parameter P.
Exceptions
This function is noexcept and is guaranteed never to throw.

◆ period() [2/3]

template<typename Scalar>
Scalar period ( DynamicNTPMatWithSemiring< Scalar > const & x)
noexcept

Defined in matrix.hpp.

This function returns the period of the dynamic ntp matrix x using its underlying semiring.

Template Parameters
Scalarthe type of the entries in the matrix.
Parameters
xthe dynamic ntp matrix.
Returns
The period of the matrix x.
Exceptions
This function is noexcept and is guaranteed never to throw.

◆ period() [3/3]

template<size_t T, size_t P, size_t R, size_t C, typename Scalar>
Scalar period ( StaticNTPMat< T, P, R, C, Scalar > const & )
constexprnoexcept

Defined in matrix.hpp.

This function returns the template parameter P of a static ntp matrix.

Template Parameters
Tthe threshold.
Pthe period.
Rthe number of rows.
Cthe number of columns.
Scalarthe type of the entries in the matrix.
Returns
The template parameter P.
Exceptions
This function is noexcept and is guaranteed never to throw.

◆ pow()

template<typename Mat>
Mat pow ( Mat const & x,
typename Mat::scalar_type e )

Defined in matrix.hpp.

This function returns the matrix x to the power e. If e is 0, then the identity matrix is returned; if e is 1, then a copy of the parameter x is returned.

Template Parameters
Matthe type of the matrix x, must satisfy IsMatrix<Mat>.
Parameters
xthe matrix (must have equal number of rows and columns).
ethe exponent (must be \(\geq 0\)).
Returns
The matrix x to the power e.
Exceptions
LibsemigroupsExceptionif Mat::scalar_type is a signed type and the parameter e is less than 0.
LibsemigroupsExceptionif x is not a square matrix.
Complexity
\(O(m\log_2(e))\) where \(m\) is the dimension of the matrix x and \(e\) is the parameter e.
Example
auto x == make<ProjMaxPlusMat<>>({{-2, 2, 0}, {-1, 0, 0}, {1, -3,
1}}));
// returns {{-1, 0, -1}, {-2, -1, -2}, {-1, 0, -1}}
matrix::pow(x, 100);
enable_if_is_same< Return, Blocks > make(Container const &cont)
Check the arguments, construct a Blocks object, and check it.
Definition bipart.hpp:798
Mat pow(Mat const &x, typename Mat::scalar_type e)
Returns a power of a matrix.
Definition matrix.hpp:7144

◆ row_basis() [1/6]

template<typename Mat, typename Container>
std::decay_t< Container > row_basis ( Container && rows)

Defined in matrix.hpp.

This function returns a row space basis for the space spanned by the container rows of row views.

Template Parameters
Mata type satisfying IsMatrix<Mat>.
Containerthe type of the container rows (must have value_type equal to Mat::RowView).
Parameters
rowsa container whose value_type is Mat::RowView.
Returns
A container of type Container of Mat::RowView.
Exceptions
This function guarantees not to throw a LibsemigroupsException.

◆ row_basis() [2/6]

template<typename Mat, typename Container>
std::enable_if_t< IsMaxPlusTruncMat< Mat > > row_basis ( Container && views,
std::decay_t< Container > & result )

Defined in matrix.hpp.

This function appends a basis for the space spanned by the row views or bit sets in views to the container result.

Template Parameters
Mata type satisfying IsMaxPlusTruncMat<Mat> or IsBMat<Mat>.
Containera container type (such as std::vector, for example). The Container::value_type must be Mat::RowView, or if Mat is BMat<N> for some N, then Container::value_type can additionally be BitSet<M> or std::bitset<M> where M is greater than or equal to N.
Parameters
viewscontainer of spanning row views or bit sets.
resultcontainer for the resulting row basis.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
\(O(r ^ 2 c)\) where \(r\) is the size of views and \(c\) is the size of each row view or bit set in views.

◆ row_basis() [3/6]

template<typename Mat, typename Container>
std::enable_if_t< IsBMat< Mat > > row_basis ( Container && views,
std::decay_t< Container > & result )

Defined in matrix.hpp.

This function appends a basis (consisting of row views) for the row space spanned by the rows in views to the container result.

Template Parameters
Mata type satisfying IsBMat<Mat>.
Containerthe type of a container for the rows.
Parameters
viewsthe spanning set of rows.
resultthe container to append the basis to the row space to.
Exceptions
This function guarantees not to throw a LibsemigroupsException.

◆ row_basis() [4/6]

template<typename Mat, typename = std::enable_if_t<IsDynamicMatrix<Mat>>>
std::vector< typename Mat::RowView > row_basis ( Mat const & x)

Defined in matrix.hpp.

This function returns a row space basis of the dynamic matrix x as a std::vector of row views.

Template Parameters
Mata type satisfying IsDynamicMatrix<Mat>.
Parameters
xthe matrix.
Returns
The row space basis of x.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
\(O(r ^ 2 c)\) where \(r\) is the number of rows in x and \(c\) is the number of columns in x.

◆ row_basis() [5/6]

template<typename Mat, typename = std::enable_if_t<IsStaticMatrix<Mat>>>
detail::StaticVector1< typename Mat::RowView, Mat::nr_rows > row_basis ( Mat const & x)

Defined in matrix.hpp.

This function returns a row space basis of the static matrix x as a static vector of row views.

Template Parameters
Mata type satisfying IsStaticMatrix<Mat>.
Parameters
xthe matrix.
Returns
A static vector of Mat::RowView.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
\(O(r ^ 2 c)\) where \(r\) is the number of rows in x and \(c\) is the number of columns in x.

◆ row_basis() [6/6]

template<typename Mat, typename Container, typename = std::enable_if_t<IsMatrix<Mat>>>
void row_basis ( Mat const & x,
Container & result )

Defined in matrix.hpp.

This function appends a basis (consisting of row views) for the row space of the matrix x to the container result.

Template Parameters
Mata type satisfying IsMatrix<Mat>.
Containera container type (such as std::vector).
Parameters
xthe matrix.
resultthe container to append the basis to the row space to.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
\(O(r ^ 2 c)\) where \(r\) is the number of rows in x and \(c\) is the number of columns in x.

◆ row_space_size()

template<typename Mat, typename = std::enable_if_t<IsBMat<Mat>>>
size_t row_space_size ( Mat const & x)

Defined in matrix.hpp.

This function returns the size of the row space of the boolean matrix x. This is currently only implemented for types of matrix Mat satisfying IsBMat<Mat>.

Template Parameters
Matthe type of x, must satisfy IsBMat<Mat>.
Parameters
xthe matrix.
Returns
The size of the row space of the matrix x.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
\(O(mn)\) where \(m\) is the size of the row basis of x and \(n\) is the size of the row space.
Warning
If \(k\) is the number of rows of the matrix x, then \(n\) can be as large as \(2 ^ k\).
Example
auto x = make<BMat<>>({{1, 0, 0}, {0, 0, 1}, {0, 1, 0}});
matrix::row_space_size(x); // returns 7
size_t row_space_size(Mat const &x)
Returns the size of the row space of a boolean matrix.
Definition matrix.hpp:7888

◆ rows() [1/2]

template<typename Mat, typename = std::enable_if_t<IsDynamicMatrix<Mat>>>
std::vector< typename Mat::RowView > rows ( Mat const & x)

Defined in matrix.hpp.

Returns a std::vector of row views into the rows of the dynamic matrix x.

Template Parameters
Matthe type of x, must satisfy IsDynamicMatrix<Mat>.
Parameters
xthe matrix.
Returns
A std::vector of Mat::RowView of size x.number_of_rows().
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
\(O(m)\) where \(m\) is the number of rows in the matrix x.

◆ rows() [2/2]

template<typename Mat, typename = std::enable_if_t<IsStaticMatrix<Mat>>>
detail::StaticVector1< typename Mat::RowView, Mat::nr_rows > rows ( Mat const & x)

Defined in matrix.hpp.

Returns a static vector of row views into the rows of the static matrix x.

Template Parameters
Matthe type of x, must satisfy IsStaticMatrix<Mat>.
Parameters
xthe matrix.
Returns
A static vector of Mat::RowView of size x.number_of_rows().
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Complexity
\(O(m)\) where \(m\) is the number of rows in the matrix x.

◆ threshold() [1/2]

template<typename Mat>
auto threshold ( Mat const & ) -> std::enable_if_t<!detail::IsTruncMat<Mat>, typename Mat::scalar_type>
constexprnoexcept

Returns the threshold of a matrix over a truncated semiring.

Defined in matrix.hpp.

The threshold of a matrix that does not have entries in a truncated semiring is UNDEFINED, and this function returns this value.

Template Parameters
Matthe type of the matrix.
Returns
The value UNDEFINED.
Exceptions
This function is noexcept and is guaranteed never to throw.

Defined in matrix.hpp.

This function returns the threshold of a matrix over a truncated semiring.

Template Parameters
Matthe type of the matrix.
Returns
The threshold of any matrix of type Mat.
Exceptions
This function is noexcept and is guaranteed never to throw.

◆ threshold() [2/2]

template<typename Mat>
auto threshold ( Mat const & x) -> std::enable_if_t<detail::IsTruncMat<Mat> && IsMatWithSemiring<Mat>, typename Mat::scalar_type>
noexcept

Defined in matrix.hpp.

This function returns the threshold of a matrix over a truncated semiring.

Template Parameters
Matthe type of the matrix.
Parameters
xthe matrix.
Returns
The threshold of x.
Exceptions
This function is noexcept and is guaranteed never to throw.

◆ throw_if_bad_coords()

template<typename Mat>
auto throw_if_bad_coords ( Mat const & x,
size_t r,
size_t c ) -> std::enable_if_t<IsMatrix<Mat>>

This function throws a LibsemigroupsException if r is not less than the number of rows of x; or if c is not less than the number of columns of x.

Template Parameters
Matthe type of the arguments, must satisfy IsMatrix<Mat>.
Parameters
xthe matrix.
rthe row index.
cthe column index.
Exceptions
LibsemigroupsExceptionif (r, c) does not index an entry in the matrix x.

◆ throw_if_bad_dim()

template<typename Mat>
auto throw_if_bad_dim ( Mat const & x,
Mat const & y ) -> std::enable_if_t<IsMatrix<Mat>>

This function throws a LibsemigroupsException if the matrices x and y do not have equal dimensions.

Template Parameters
Matthe type of the arguments, must satisfy IsMatrix<Mat>.
Parameters
xthe first matrix to check.
ythe second matrix to check.
Exceptions
LibsemigroupsExceptionif the number of rows in x does not equal the number of rows of y; or the number of columns of x does not equal the number of columns of y.

◆ throw_if_bad_entry() [1/2]

template<typename Mat>
std::enable_if_t< IsProjMaxPlusMat< Mat > > throw_if_bad_entry ( Mat const & x)
constexpr

Defined in matrix.hpp.

This function can be used to check that the matrix x contains values in the underlying semiring, by checking the underlying matrix.

Template Parameters
Matthe type of the parameter (must satisfy IsProjMaxPlusMat<Mat>).
Parameters
xthe matrix to check.
Exceptions
LibsemigroupsExceptionif throw_if_bad_entry(x.underlying_matrix()) throws.

◆ throw_if_bad_entry() [2/2]

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

Defined in matrix.hpp.

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

Template Parameters
Matthe type of the parameter (must satisfy IsProjMaxPlusMat<Mat>).
Parameters
xthe matrix.
valthe entry.
Exceptions
LibsemigroupsExceptionif throw_if_bad_entry(x.underlying_matrix(), val) throws.

◆ throw_if_not_square()

template<typename Mat>
auto throw_if_not_square ( Mat const & x) -> std::enable_if_t<IsMatrix<Mat>>

This function throws a LibsemigroupsException if the matrix x is not square.

Template Parameters
Matthe type of the argument, must satisfy IsMatrix<Mat>.
Parameters
xthe matrix to check.
Exceptions
LibsemigroupsExceptionif the number of rows in x does not equal the number of columns.