Defined in matrix.hpp.
This is a class for matrices where both the arithmetic operations in the underlying semiring, and the dimensions of the matrices are known at compile time.
| PlusOp | a stateless type with a call operator of signature scalar_type operator()(scalar_type, scalar_type) implementing the addition of the semiring. |
| ProdOp | a stateless type with a call operator of signature scalar_type operator()(scalar_type, scalar_type) implementing the multiplication of the semiring. |
| ZeroOp | a stateless type with a call operator of signature scalar_type operator()() returning the zero of the semiring (the additive identity element). |
| OneOp | a stateless type with a call operator of signature scalar_type operator()() returning the one of the semiring (the multiplicative identity element). |
| R | the number of rows of the matrix. |
| C | the number of columns of the matrix. |
| Scalar | the type of the entries in the matrices (the type of elements in the underlying semiring). |
Public Types | |
| using | const_iterator = typename MatrixCommon::const_iterator |
| Alias for const iterators pointing at entries of a matrix. | |
| using | iterator = typename MatrixCommon::iterator |
| Alias for iterators pointing at entries of a matrix. | |
| using | One = OneOp |
Alias for the template parameter OneOp. | |
| using | Plus = PlusOp |
Alias for the template parameter PlusOp. | |
| using | Prod = ProdOp |
Alias for the template parameter ProdOp. | |
| using | Row = StaticMatrix<PlusOp, ProdOp, ZeroOp, OneOp, 1, C, Scalar> |
| Alias for the type of the rows of a StaticMatrix. | |
| using | RowView = StaticRowView<PlusOp, ProdOp, ZeroOp, OneOp, C, Scalar> |
| Alias for the type of row views of a StaticMatrix. | |
| using | scalar_const_reference = typename MatrixCommon::scalar_const_reference |
Alias for const references to the template parameter Scalar. | |
| using | scalar_reference = typename MatrixCommon::scalar_reference |
Alias for references to the template parameter Scalar. | |
| using | scalar_type = typename MatrixCommon::scalar_type |
Alias for the template parameter Scalar. | |
| using | Zero = ZeroOp |
Alias for the template parameter ZeroOp. | |
Public Member Functions | |
| StaticMatrix ()=default | |
| Default constructor. | |
| StaticMatrix (RowView const &rv) | |
| Construct a row from a row view. | |
| StaticMatrix (StaticMatrix &&)=default | |
| Default move constructor. | |
| StaticMatrix (StaticMatrix const &)=default | |
| Default copy constructor. | |
| StaticMatrix (std::initializer_list< scalar_type > const &c) | |
| Construct a row (from std::initializer_list). | |
| StaticMatrix (std::initializer_list< std::initializer_list< scalar_type > > const &m) | |
| Construct a matrix. | |
| StaticMatrix (std::vector< std::vector< scalar_type > > const &m) | |
| Construct a matrix. | |
| scalar_reference | at (size_t r, size_t c) |
| Returns a reference to the specified entry of the matrix. | |
| scalar_const_reference | at (size_t r, size_t c) const |
| Returns a const reference to the specified entry of the matrix. | |
| iterator | begin () noexcept |
| Returns an iterator pointing at the first entry. | |
| const_iterator | cbegin () const noexcept |
| Returns a const iterator pointing at the first entry. | |
| const_iterator | cend () |
| Returns a const iterator pointing one beyond the last entry in the matrix. | |
| std::pair< scalar_type, scalar_type > | coords (const_iterator it) const |
| Get the coordinates of an iterator. | |
| iterator | end () |
| Returns an iterator pointing one beyond the last entry in the matrix. | |
| size_t | hash_value () const |
| Return a hash value of a matrix. | |
| size_t | number_of_cols () const noexcept |
| Returns the number of columns of the matrix. | |
| size_t | number_of_rows () const noexcept |
| Returns the number of rows of the matrix. | |
| bool | operator!= (RowView const &that) const |
| Inequality operator. | |
| bool | operator!= (StaticMatrix const &that) const |
| Inequality operator. | |
| scalar_reference | operator() (size_t r, size_t c) |
| Returns a reference to the specified entry of the matrix. | |
| scalar_const_reference | operator() (size_t r, size_t c) const |
| Returns a const reference to the specified entry of the matrix. | |
| StaticMatrix | operator* (scalar_type a) |
| Multiply a matrix by a scalar. | |
| StaticMatrix | operator* (StaticMatrix const &that) |
| Returns the product of two matrices. | |
| void | operator*= (scalar_type a) |
| Multiplies every entry of a matrix by a scalar in-place. | |
| StaticMatrix | operator+ (scalar_type a) |
| Add a scalar to a matrix. | |
| StaticMatrix | operator+ (StaticMatrix const &that) |
| Returns the sum of two matrices. | |
| void | operator+= (RowView const &that) |
| Add a matrix to another matrix in-place. | |
| void | operator+= (scalar_type a) |
| Adds a scalar to every entry of the matrix in-place. | |
| void | operator+= (StaticMatrix const &that) |
| Add a matrix to another matrix in-place. | |
| bool | operator< (RowView const &that) const |
| Less than operator. | |
| bool | operator< (StaticMatrix const &that) const |
| Less than operator. | |
| template<typename U> | |
| bool | operator<= (U const &that) const |
| Less than or equal operator. | |
| StaticMatrix & | operator= (StaticMatrix &&)=default |
| Default move assignment operator. | |
| StaticMatrix & | operator= (StaticMatrix const &)=default |
| Default copy assignment operator. | |
| bool | operator== (RowView const &that) const |
| Equality operator. | |
| bool | operator== (StaticMatrix const &that) const |
| Equality operator. | |
| bool | operator> (StaticMatrix const &that) const |
| Greater than operator. | |
| template<typename U> | |
| bool | operator>= (U const &that) const |
| Greater than or equal operator. | |
| void | product_inplace_no_checks (StaticMatrix const &x, StaticMatrix const &y) |
Multiplies x and y and stores the result in this. | |
| RowView | row (size_t i) const |
| Returns a view into a row. | |
| RowView | row_no_checks (size_t i) const |
| Returns a view into a row. | |
| template<typename T> | |
| void | rows (T &x) const |
| Add row views for every row in the matrix to a container. | |
| scalar_type | scalar_one () const noexcept |
| Returns the multiplicative identity of the underlying semiring. | |
| scalar_type | scalar_zero () const noexcept |
| Returns the additive identity of the underlying semiring. | |
| semiring_type const * | semiring () const noexcept |
| Returns the underlying semiring. | |
| void | swap (StaticMatrix &that) noexcept |
Swaps the contents of *this with the contents of that. | |
| void | transpose () |
| Transpose a matrix in-place. | |
| void | transpose_no_checks () |
| Transpose a matrix in-place. | |
Static Public Member Functions | |
| static StaticMatrix | one () const |
| Returns an identity matrix. | |
|
inlineexplicit |
Construct a row from an std::initializer_list.
| c | the values to be copied into the row. |
R is 1.
|
inlineexplicit |
Construct a matrix from an std::initializer_list of std::initializer_list.
| m | the values to be copied into the matrix. |
R and \(n\) is the template parameter C.
|
inlineexplicit |
Construct a matrix from an std::vector of std::vector.
| m | the values to be copied into the matrix. |
R and \(n\) is the template parameter C.
|
inlineexplicit |
Construct a row from a row view.
| rv | the row view. |
R is 1.
|
default |
Default constructor.
|
default |
Default copy constructor.
|
default |
Default move constructor.
| scalar_reference at | ( | size_t | r, |
| size_t | c ) |
Returns a reference to the specified entry of the matrix.
| r | the index of the row of the entry. |
| c | the index of the column of the entry. |
| LibsemigroupsException | if r or c is out of bounds. |
| scalar_const_reference at | ( | size_t | r, |
| size_t | c ) const |
Returns a const reference to the specified entry of the matrix.
| r | the index of the row of the entry. |
| c | the index of the column of the entry. |
| LibsemigroupsException | if r or c is out of bounds. |
|
noexcept |
This function returns a random access iterator point at the first entry of the matrix.
noexcept and is guaranteed never to throw.
|
noexcept |
This function returns a const (random access) iterator pointing at the first entry in the matrix.
noexcept and is guaranteed never to throw.| const_iterator cend | ( | ) |
This function returns a const (random access) iterator pointing one passed the last entry of the matrix.
noexcept and is guaranteed never to throw.| std::pair< scalar_type, scalar_type > coords | ( | const_iterator | it | ) | const |
This function returns a pair containing the row and columns corresponding to a const_iterator pointing into a matrix.
| it | the const_iterator. |
std::pair<scalar_type, scalar_type>.| iterator end | ( | ) |
noexcept and is guaranteed never to throw.| size_t hash_value | ( | ) | const |
This function returns a hash value for a matrix. The return value is recomputed every time this function is called.
this.noexcept and is guaranteed never to throw.
|
noexcept |
This function returns the number of columns of the matrix.
size_t.noexcept and is guaranteed never to throw.
|
noexcept |
This function returns the number of rows of the matrix.
size_t.noexcept and is guaranteed never to throw.
|
static |
This function returns an R times R identity matrix.
R rows and R columns.R. | bool operator!= | ( | RowView const & | that | ) | const |
This function returns true if *this is not equal to that; and false otherwise.
| that | the matrix or row view for comparison. |
operator==(that).| bool operator!= | ( | StaticMatrix< PlusOp, ProdOp, ZeroOp, OneOp, R, C, Scalar > const & | that | ) | const |
This function returns true if *this is not equal to that; and false otherwise.
| that | the matrix or row view for comparison. |
operator==(that).| scalar_reference operator() | ( | size_t | r, |
| size_t | c ) |
Returns a reference to the specified entry of the matrix.
| r | the index of the row of the entry. |
| c | the index of the column of the entry. |
r and c are performed. | scalar_const_reference operator() | ( | size_t | r, |
| size_t | c ) const |
Returns a const reference to the specified entry of the matrix.
| r | the index of the row of the entry. |
| c | the index of the column of the entry. |
r and c are performed. | StaticMatrix operator* | ( | scalar_type | a | ) |
This function returns the product of the matrix *this and the scalar a.
| a | the scalar to add. |
*this and a.| StaticMatrix operator* | ( | StaticMatrix< PlusOp, ProdOp, ZeroOp, OneOp, R, C, Scalar > const & | that | ) |
This function returns the product of two matrices.
| that | the matrix to multiply by this. |
| void operator*= | ( | scalar_type | a | ) |
This function multiplies every entry of a matrix by a scalar in-place.
| a | the scalar to multiply every entry by. |
| StaticMatrix operator+ | ( | scalar_type | a | ) |
This function returns the sum of the matrix *this and the scalar a.
| a | the scalar to add. |
*this and a.| StaticMatrix operator+ | ( | StaticMatrix< PlusOp, ProdOp, ZeroOp, OneOp, R, C, Scalar > const & | that | ) |
This function returns the sum of two matrices.
| that | the matrix to add to this. |
| void operator+= | ( | RowView const & | that | ) |
This function adds a matrix (or the row represented by a RowView) to another matrix of the same shape in-place.
| that | the matrix or row view to add. |
| void operator+= | ( | scalar_type | a | ) |
This function adds a scalar to every entry of the matrix in-place.
| a | the scalar_type to add to a StaticMatrix. |
| void operator+= | ( | StaticMatrix< PlusOp, ProdOp, ZeroOp, OneOp, R, C, Scalar > const & | that | ) |
This function adds a matrix (or the row represented by a RowView) to another matrix of the same shape in-place.
| that | the matrix or row view to add. |
| bool operator< | ( | RowView const & | that | ) | const |
This operator defines a total order on the set of matrices of the same type.
| that | the matrix or row view for comparison. |
true if *this is less than that and false if it is not.| bool operator< | ( | StaticMatrix< PlusOp, ProdOp, ZeroOp, OneOp, R, C, Scalar > const & | that | ) | const |
This operator defines a total order on the set of matrices of the same type.
| that | the matrix or row view for comparison. |
true if *this is less than that and false if it is not.| bool operator<= | ( | U const & | that | ) | const |
This operator defines a total order on the set of matrices of the same type.
| U | the type of the argument that. |
| that | the matrix or row view for comparison. |
true if *this is less than or equal to that and false if it is not.
|
default |
Default move assignment operator.
|
default |
Default copy assignment operator.
| bool operator== | ( | RowView const & | that | ) | const |
This function returns true if *this is equal to that; and false otherwise.
| that | matrix or row view for comparison. |
true if *this and that are equal and false if they are not.| bool operator== | ( | StaticMatrix< PlusOp, ProdOp, ZeroOp, OneOp, R, C, Scalar > const & | that | ) | const |
This function returns true if *this is equal to that; and false otherwise.
| that | matrix or row view for comparison. |
true if *this and that are equal and false if they are not.| bool operator> | ( | StaticMatrix< PlusOp, ProdOp, ZeroOp, OneOp, R, C, Scalar > const & | that | ) | const |
This operator defines a total order on the set of matrices of the same type.
| that | the matrix for comparison. |
true if *this is less than that and false if it is not.| bool operator>= | ( | U const & | that | ) | const |
This operator defines a total order on the set of matrices of the same type.
| U | the type of the argument that. |
| that | the matrix or row view for comparison. |
true if *this is greater than or equal to that and false if it is not.| void product_inplace_no_checks | ( | StaticMatrix< PlusOp, ProdOp, ZeroOp, OneOp, R, C, Scalar > const & | x, |
| StaticMatrix< PlusOp, ProdOp, ZeroOp, OneOp, R, C, Scalar > const & | y ) |
This function redefines this to be the product of x and y. This is in-place multiplication to avoid allocation of memory for products which do not need to be stored for future use.
| x | the first matrix to multiply. |
| y | the second matrix to multiply. |
| RowView row | ( | size_t | i | ) | const |
This function returns a RowView into the row with index i.
| i | the index of the row. |
| LibsemigroupsException | if i is greater than or equal to number_of_rows. |
| RowView row_no_checks | ( | size_t | i | ) | const |
This function returns a RowView into the row with index i.
| i | the index of the row. |
i. | void rows | ( | T & | x | ) | const |
This function adds a RowView for each row in the matrix to the container x.
| T | the type of the container. |
| x | a container. |
R.
|
noexcept |
This function returns the multiplicative identity of the underlying semiring of a matrix.
noexcept and is guaranteed never to throw.
|
noexcept |
This function returns the additive identity of the underlying semiring of a matrix.
noexcept and is guaranteed never to throw.
|
noexcept |
Returns a const pointer to the underlying semiring (if any).
Semiring const*.noexcept and is guaranteed never to throw.
|
noexcept |
This function swaps the contents of *this with the contents of that.
| that | the matrix to swap contents with. |
noexcept and is guaranteed never to throw.| void transpose | ( | ) |
This function transpose a matrix object in-place.
| LibsemigroupsException | if the matrix isn't square. |
| void transpose_no_checks | ( | ) |
This function transpose a matrix object in-place.