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. | |
| 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.
| Mat | a type such that IsBMat<Mat> is true. |
| Container | a container type such that Container::value_type is BitSet<M> or std::bitset<M> for some M. |
| rows | container of spanning rows represented by bit sets. |
std::decay_t<Container> containing the row basis consisting of bit sets.rows and \(c\) is the size of each bitset in rows. | 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.
| Mat | a type such that IsBMat<Mat> is true. |
| Container | a container type with Container::value_type being BitSet<M> or std::bitset<M> for some M. |
| rows | container of spanning rows represented by bit sets. |
| result | container for the resulting row basis. |
rows and \(c\) is the size of each bitset in rows. | 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.
| Mat | a type such that IsBMat<Mat> is true. |
| M | an 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(). |
| x | the boolean matrix. |
detail::StaticVector1<BitSet<M>, M>> containing the row basis of x consisting of bitsets.x and \(c\) is the number of columns in x. | 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.
| Mat | a type such that IsBMat<Mat> is true. |
| Container | a container type with Container::value_type equal to BitSet<M> or std::bitset<M> for some M. |
| x | the boolean matrix. |
| result | container for the resulting rowbasis. |
x and \(c\) is the number of columns in x. | 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.
| Mat | the type of matrix. This must be a type so that IsBMat<Mat> is true. |
| R | an upper bound for the number of rows in views. This value must be at most BitSet<1>::max_size(). |
| C | an upper bound for the number of columns in each row represented in views. This value must be at most BitSet<1>::max_size(). |
| Container | the type of the container views, should be std::vector or detail::StaticVector1. |
| views | a container of Mat::RowView or std::vector<bool>. |
detail::StaticVector1<BitSet<C>, R>.views and and \(n\) is the number of columns in any vector in views. | 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.
| Mat | the type of matrix. This must be a type so that IsBMat<Mat> is true. |
| R | an upper bound for the number of rows in views. This value must be at most BitSet<1>::max_size(). |
| C | an upper bound for the number of columns in each row represented in views. This value must be at most BitSet<1>::max_size(). |
| Container | the type of the container views, should be std::vector or detail::StaticVector1. |
| views | a container of Mat::RowView or std::vector<bool>. |
| result | a static vector of bit sets to contain the resulting bit sets. |
views and and \(n\) is the number of columns in any vector in views. | auto bitset_rows | ( | Mat const & | x | ) |
Defined in matrix.hpp.
This functions returns the rows of a boolean matrix as bit sets.
| Mat | the type of matrix. Must satisfy IsBMat<Mat>. |
| x | the boolean matrix. |
detail::StaticVector1<BitSet<C>, R>.x and and \(n\) is the number of columns in x. | 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.
| Mat | the type of matrix. This must be a type so that IsBMat<Mat> is true. |
| R | an upper bound for the number of rows in views. This value must be at most BitSet<1>::max_size(). |
| C | an upper bound for the number of columns in each row represented in views. This value must be at most BitSet<1>::max_size(). |
| x | the boolean matrix. |
| result | the container to append the rows of x to. |
x and and \(n\) is the number of columns in x.
|
constexprnoexcept |
Defined in matrix.hpp.
This function returns the template parameter P of a dynamic ntp matrix.
| T | the threshold. |
| P | the period. |
| Scalar | the type of the entries in the matrix. |
P.noexcept and is guaranteed never to throw.
|
noexcept |
Defined in matrix.hpp.
This function returns the period of the dynamic ntp matrix x using its underlying semiring.
| Scalar | the type of the entries in the matrix. |
| x | the dynamic ntp matrix. |
x.noexcept and is guaranteed never to throw.
|
constexprnoexcept |
Defined in matrix.hpp.
This function returns the template parameter P of a static ntp matrix.
| T | the threshold. |
| P | the period. |
| R | the number of rows. |
| C | the number of columns. |
| Scalar | the type of the entries in the matrix. |
P.noexcept and is guaranteed never to throw. | 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.
| Mat | the type of the matrix x, must satisfy IsMatrix<Mat>. |
| x | the matrix (must have equal number of rows and columns). |
| e | the exponent (must be \(\geq 0\)). |
x to the power e.| LibsemigroupsException | if Mat::scalar_type is a signed type and the parameter e is less than 0. |
| LibsemigroupsException | if x is not a square matrix. |
x and \(e\) is the parameter e.| 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.
| Mat | a type satisfying IsMatrix<Mat>. |
| Container | the type of the container rows (must have value_type equal to Mat::RowView). |
| rows | a container whose value_type is Mat::RowView. |
Container of Mat::RowView.| 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.
| Mat | a type satisfying IsMaxPlusTruncMat<Mat> or IsBMat<Mat>. |
| Container | a 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. |
| views | container of spanning row views or bit sets. |
| result | container for the resulting row basis. |
views and \(c\) is the size of each row view or bit set in views. | 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.
| Mat | a type satisfying IsBMat<Mat>. |
| Container | the type of a container for the rows. |
| views | the spanning set of rows. |
| result | the container to append the basis to the row space to. |
| 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.
| Mat | a type satisfying IsDynamicMatrix<Mat>. |
| x | the matrix. |
x.x and \(c\) is the number of columns in x. | 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.
| Mat | a type satisfying IsStaticMatrix<Mat>. |
| x | the matrix. |
Mat::RowView.x and \(c\) is the number of columns in x. | 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.
| Mat | a type satisfying IsMatrix<Mat>. |
| Container | a container type (such as std::vector). |
| x | the matrix. |
| result | the container to append the basis to the row space to. |
x and \(c\) is the number of columns in x. | 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>.
| Mat | the type of x, must satisfy IsBMat<Mat>. |
| x | the matrix. |
x.x and \(n\) is the size of the row space.x, then \(n\) can be as large as \(2 ^ k\).| 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.
| Mat | the type of x, must satisfy IsDynamicMatrix<Mat>. |
| x | the matrix. |
Mat::RowView of size x.number_of_rows().x. | 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.
| Mat | the type of x, must satisfy IsStaticMatrix<Mat>. |
| x | the matrix. |
Mat::RowView of size x.number_of_rows().x.
|
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.
| Mat | the type of the matrix. |
noexcept and is guaranteed never to throw.Defined in matrix.hpp.
This function returns the threshold of a matrix over a truncated semiring.
| Mat | the type of the matrix. |
Mat.noexcept and is guaranteed never to throw.
|
noexcept |
Defined in matrix.hpp.
This function returns the threshold of a matrix over a truncated semiring.
| Mat | the type of the matrix. |
| x | the matrix. |
x.noexcept and is guaranteed never to throw. | 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.
| Mat | the type of the arguments, must satisfy IsMatrix<Mat>. |
| x | the matrix. |
| r | the row index. |
| c | the column index. |
| LibsemigroupsException | if (r, c) does not index an entry in the matrix x. |
| 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.
| Mat | the type of the arguments, must satisfy IsMatrix<Mat>. |
| x | the first matrix to check. |
| y | the second matrix to check. |
| LibsemigroupsException | if 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. |
|
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.
| Mat | the type of the parameter (must satisfy IsProjMaxPlusMat<Mat>). |
| x | the matrix to check. |
| LibsemigroupsException | if throw_if_bad_entry(x.underlying_matrix()) throws. |
|
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.
| Mat | the type of the parameter (must satisfy IsProjMaxPlusMat<Mat>). |
| x | the matrix. |
| val | the entry. |
| LibsemigroupsException | if throw_if_bad_entry(x.underlying_matrix(), val) throws. |
| 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.
| Mat | the type of the argument, must satisfy IsMatrix<Mat>. |
| x | the matrix to check. |
| LibsemigroupsException | if the number of rows in x does not equal the number of columns. |