Validation¶
The function validate_matrix
can be used to check that a matrix is
valid (i.e. that its entries belong to the underlying semiring).

template<typename Mat>
void validate(Mat const &m)¶ Throws an exception if the matrix is invalid.
The overloaded static member functions
DynamicMatrix::make
andStaticMatrix::make
use this function to verify that the constructed matrix is valid. Template Parameters
Mat – a type for which
IsMatrix
istrue
. Parameters
m – the matrix to validate.
 Returns
(None).
 Throws
A
LibsemigroupsException
if the matrixm
is invalid. Complexity
At worst \(O(nk)\) where \(n\) is the number of rows in the matrix
m
and \(k\) is the number of columns.
Threshold and period¶

template<typename Mat>
typename Mat::scalar_type matrix_threshold(Mat const &m)¶ Returns the threshold of a matrix (if any).
This value is only defined for
MaxPlusTruncMat
,MinPlusTruncMat
, andNTPMat
. IfMat
is another type of matrix, thenUNDEFINED
is returned. Template Parameters
Mat – a type for which
IsMatrix
istrue
. Parameters
m – the matrix.
 Returns
A value of type
typename Mat::scalar_type
. Exceptions
This function is
noexcept
and is guaranteed never to throw. Complexity
Constant.

template<typename Mat>
typename Mat::scalar_type matrix_period(Mat const &m)¶ Returns the period of a matrix (if any).
This value is only defined for
NTPMat
. IfMat
is another type of matrix, thenUNDEFINED
is returned. Template Parameters
Mat – a type for which
IsMatrix
istrue
. Parameters
m – the matrix.
 Returns
A value of type
typename Mat::scalar_type
. Exceptions
This function is
noexcept
and is guaranteed never to throw. Complexity
Constant.