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 and StaticMatrix::make use this function to verify that the constructed matrix is valid.

Template Parameters:

Mat – a type for which IsMatrix is true.

Parameters:

m – the matrix to validate.

Returns:

(None).

Throws:

A LibsemigroupsException if the matrix m 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, and NTPMat. If Mat is another type of matrix, then UNDEFINED is returned.

Template Parameters:

Mat – a type for which IsMatrix is true.

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. If Mat is another type of matrix, then UNDEFINED is returned.

Template Parameters:

Mat – a type for which IsMatrix is true.

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.