libsemigroups  v3.6.0
C++ library for semigroups and monoids
Loading...
Searching...
No Matches
max-plus-trunc-mat.hpp
1// libsemigroups - C++ library for semigroups and monoids
2// Copyright (C) 2021-5 Finn Smith
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16//
17
18#ifndef LIBSEMIGROUPS_MAX_PLUS_TRUNC_MAT_HPP_
19#define LIBSEMIGROUPS_MAX_PLUS_TRUNC_MAT_HPP_
20
21#include <cstddef> // for size_t
22#include <numeric> // for inner_product
23#include <type_traits> // for enable_if_t, enable_if
24#include <unordered_set> // for unordered_set
25#include <utility> // for move
26
27#include "action.hpp" // for RightAction
28#include "adapters.hpp" // for ImageRightAction
29#include "matrix.hpp" // for MaxPlusTruncMat
30
31#include "detail/containers.hpp" // for StaticVector1
32
33namespace libsemigroups {
34 // ////////////////////////////////////////////////////////////////////////
35 // // ImageRight/LeftAction - MaxPlusTruncMat
36 // ////////////////////////////////////////////////////////////////////////
37
42 template <typename Mat>
43 struct ImageRightAction<Mat,
44 typename LambdaValue<Mat>::type,
45 std::enable_if_t<IsMaxPlusTruncMat<Mat>>> {
50 result_type const& pt,
51 Mat const& x) const;
52 };
53
58 template <typename Mat>
59 struct ImageLeftAction<Mat,
60 typename RhoValue<Mat>::type,
61 std::enable_if_t<IsMaxPlusTruncMat<Mat>>> {
64 // not noexcept because the constructor of std::vector isn't
67 result_type const& pt,
68 Mat const& x) const {
69 const_cast<Mat*>(&x)->transpose();
71 const_cast<Mat*>(&x)->transpose();
72 }
73 };
74
76 // Lambda/Rho - MaxPlusTruncMat
78
83 template <typename Mat>
84 struct LambdaValue<Mat, std::enable_if_t<IsMaxPlusTruncMat<Mat>>> {
85 using type =
86 typename detail::StaticVector1<typename Mat::Row, Mat::nr_rows>;
87 };
88
93 template <typename Mat>
94 struct RhoValue<Mat, std::enable_if_t<IsMaxPlusTruncMat<Mat>>> {
98 using type =
99 typename detail::StaticVector1<typename Mat::Row, Mat::nr_rows>;
100 };
101
106 template <typename Mat>
107 struct Lambda<Mat,
108 typename LambdaValue<Mat>::type,
109 std::enable_if_t<IsMaxPlusTruncMat<Mat>>> {
113 void operator()(result_type& res, Mat const& x) const {
114 res.clear();
115 matrix::row_basis_rows<Mat>(x, res);
116 }
117 };
118
123 template <typename Mat>
124 struct Rho<Mat,
125 typename RhoValue<Mat>::type,
126 std::enable_if_t<IsMaxPlusTruncMat<Mat>>> {
127 using result_type = typename RhoValue<Mat>::type;
129 void operator()(result_type& res, Mat const& x) const {
130 // TODO this is inefficient
131 const_cast<Mat*>(&x)->transpose();
132 Lambda<Mat, result_type>()(res, x);
133 const_cast<Mat*>(&x)->transpose();
134 }
135 };
136
138 // Rank - MaxPlusTruncMat
140
144 template <typename Mat>
145 struct Rank<Mat, RankState<Mat>, std::enable_if_t<IsMaxPlusTruncMat<Mat>>> {
147 size_t operator()(Mat const& x) const;
148 };
149} // namespace libsemigroups
150
151#include "max-plus-trunc-mat.tpp"
152
153#endif // LIBSEMIGROUPS_MAX_PLUS_TRUNC_MAT_HPP_
Base class for states for ranks.
Definition adapters.hpp:882
Namespace for everything in the libsemigroups library.
Definition action.hpp:44
typename RhoValue< Mat >::type result_type
The type of the result.
Definition max-plus-trunc-mat.hpp:63
void operator()(result_type &res, result_type const &pt, Mat const &x) const
Stores the image of pt under the left action of p in res.
Definition max-plus-trunc-mat.hpp:66
Adapter for the value of a left action.
Definition adapters.hpp:355
typename LambdaValue< Mat >::type result_type
The type of the result.
Definition max-plus-trunc-mat.hpp:47
void operator()(result_type &res, result_type const &pt, Mat const &x) const
Stores the image of pt under the right action of p in res.
Adapter for the value of a right action.
Definition adapters.hpp:397
Adapter for lambda functions.
Definition adapters.hpp:798
typename LambdaValue< Mat >::type result_type
The type of the result.
Definition max-plus-trunc-mat.hpp:111
void operator()(result_type &res, Mat const &x) const
Modifies res to contain the row space basis of x.
Definition max-plus-trunc-mat.hpp:113
Adapter for the action on LambdaValue's.
Definition adapters.hpp:838
size_t operator()(Mat const &x) const
Returns the size of the row space of x.
Adapter for calculating ranks.
Definition adapters.hpp:935
typename detail::StaticVector1< typename Mat::Row, Mat::nr_rows > type
Definition max-plus-trunc-mat.hpp:98
Adapter for rho functions.
Definition adapters.hpp:817
void operator()(result_type &res, Mat const &x) const
Modifies res to contain the column space basis of x.
Definition max-plus-trunc-mat.hpp:129
Adapter for the action on RhoValue's.
Definition adapters.hpp:859