This page contains links to the documentation of the functionality in libsemigroups for matrices.
There are several different classes in libsemigroups
for representing matrices over various semirings. There are up to three different representations for every type of matrix:
- those whose dimension and arithmetic operations can be defined at compile time: StaticMatrix;
- those whose arithmetic operation can be defined at compile time but whose dimensions can be set at run time: DynamicMatrix (with compile-time arithmetic);
- those whose arithmetic operations and dimensions can be set at run time: DynamicMatrix (with run-time arithmetic).
It's unlikely that you will want to use the classes described on this page directly, but rather through the aliases described on the other matrix pages (such as, for example, BMat).
- Warning
- All of the matrices in
libsemigroups
have entries that are integer types, and the code does not currently attempt to detect overflows.
Over specific semirings
The following matrix classes are provided which define matrices over some specific semirings:
Over arbitrary semirings
The following general matrix classes are provided which can be used to define matrices over arbitrary semirings:
Row views
A row view is a lightweight representation of a row of a matrix. The following row view classes are provided:
Adapters
There are various specialisations of the adapters described on this page for the matrices described on this page:
|
template<typename Mat> |
auto | operator* (typename Mat::scalar_type a, Mat const &x) -> std::enable_if_t< IsMatrix< Mat >, Mat > |
| Multiply a matrix by a scalar.
|
|
template<typename Mat> |
auto | operator+ (typename Mat::scalar_type a, Mat const &x) -> std::enable_if_t< IsMatrix< Mat >, Mat > |
| Add a scalar to a matrix.
|
|
template<typename S, typename T> |
std::ostringstream & | operator<< (std::ostringstream &os, detail::RowViewCommon< S, T > const &x) |
| Insertion operator for row views.
|
|
template<typename Mat> |
auto | operator<< (std::ostringstream &os, Mat const &x) -> std::enable_if_t< IsMatrix< Mat >, std::ostringstream & > |
| Insertion operator for matrices.
|
|
template<typename Mat> |
auto | to_human_readable_repr (Mat const &x, std::string const &prefix, std::string const &short_name="", std::string const &braces="{}", size_t max_width=72) -> std::enable_if_t< IsMatrix< Mat >, std::string > |
| Returns a human readable representation of a matrix.
|
|
|
template<typename T> |
constexpr bool | IsDynamicMatrix = IsMatrix<T> && !IsStaticMatrix<T> |
| Helper variable template.
|
|
template<typename T> |
static constexpr bool | IsIntMat = detail::IsIntMatHelper<T>::value |
| Helper variable template.
|
|
template<typename T> |
constexpr bool | IsMatrix = detail::IsMatrixHelper<T>::value |
| Helper variable template.
|
|
template<typename T> |
static constexpr bool | IsMatWithSemiring = detail::IsMatWithSemiringHelper<T>::value |
| Helper variable template.
|
|
template<typename T> |
static constexpr bool | IsMaxPlusMat = detail::IsMaxPlusMatHelper<T>::value |
| Helper variable template.
|
|
template<typename T> |
static constexpr bool | IsMinPlusMat = detail::IsMinPlusMatHelper<T>::value |
| Helper variable template.
|
|
template<typename T> |
constexpr bool | IsStaticMatrix = detail::IsStaticMatrixHelper<T>::value |
| Helper variable template.
|
|
◆ operator*()
template<typename Mat>
auto operator* |
( |
typename Mat::scalar_type | a, |
|
|
Mat const & | x ) -> std::enable_if_t<IsMatrix<Mat>, Mat> |
This function returns the product of the matrix x
and the scalar a
.
- Template Parameters
-
- Parameters
-
a | the scalar to multiply. |
x | the matrix. |
- Returns
- The product of
a
and x
.
- Exceptions
- This function guarantees not to throw a LibsemigroupsException.
- Warning
- This function does not detect overflows of
Mat::scalar_type
.
◆ operator+()
template<typename Mat>
auto operator+ |
( |
typename Mat::scalar_type | a, |
|
|
Mat const & | x ) -> std::enable_if_t<IsMatrix<Mat>, Mat> |
This function returns the sum of the matrix x
and the scalar a
.
- Template Parameters
-
- Parameters
-
a | the scalar to add. |
x | the matrix. |
- Returns
- The sum of
a
and x
.
- Exceptions
- This function guarantees not to throw a LibsemigroupsException.
- Warning
- This function does not detect overflows of
Mat::scalar_type
.
◆ operator<<() [1/2]
template<typename S, typename T>
This function inserts a human readable representation of a row view into the string stream os
.
- Parameters
-
os | the string stream. |
x | the row view. |
- Exceptions
- This function guarantees not to throw a LibsemigroupsException.
◆ operator<<() [2/2]
This function inserts a human readable representation of a matrix into the string stream os
.
- Template Parameters
-
- Parameters
-
os | the string stream. |
x | the matrix. |
- Exceptions
- This function guarantees not to throw a LibsemigroupsException.
◆ to_human_readable_repr()
This function returns a human readable representation of a matrix.
- Template Parameters
-
- Parameters
-
x | the matrix. |
prefix | the prefix for the returned string. |
short_name | the short name of the type of matrix (default: "" ). |
braces | the braces to use to delineate rows (default: "{}" ). |
max_width | the maximum width of the returned representation (default: 72 ). |
- Exceptions
-
◆ IsDynamicMatrix
Defined in matrix.hpp
.
This variable has value true
if the template parameter T
is DynamicMatrix; and false
otherwise.
- Template Parameters
-
◆ IsIntMat
template<typename T>
bool IsIntMat = detail::IsIntMatHelper<T>::value |
|
staticconstexpr |
Defined in matrix.hpp
.
This variable has value true
if the template parameter T
is IntMat; and false
otherwise.
- Template Parameters
-
◆ IsMatrix
template<typename T>
bool IsMatrix = detail::IsMatrixHelper<T>::value |
|
constexpr |
◆ IsMatWithSemiring
template<typename T>
bool IsMatWithSemiring = detail::IsMatWithSemiringHelper<T>::value |
|
staticconstexpr |
◆ IsMaxPlusMat
template<typename T>
bool IsMaxPlusMat = detail::IsMaxPlusMatHelper<T>::value |
|
staticconstexpr |
Defined in matrix.hpp
.
This variable has value true
if the template parameter T
is MaxPlusMat; and false
otherwise.
- Template Parameters
-
◆ IsMinPlusMat
template<typename T>
bool IsMinPlusMat = detail::IsMinPlusMatHelper<T>::value |
|
staticconstexpr |
Defined in matrix.hpp
.
This variable has value true
if the template parameter T
is MinPlusMat; and false
otherwise.
- Template Parameters
-
◆ IsStaticMatrix
template<typename T>
bool IsStaticMatrix = detail::IsStaticMatrixHelper<T>::value |
|
constexpr |
Defined in matrix.hpp
.
This variable has value true
if the template parameter T
is StaticMatrix; and false
otherwise.
- Template Parameters
-