libsemigroups  v3.5.5
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>>> {
48 void operator()(result_type& res,
49 result_type const& pt,
50 Mat const& x) const;
51 };
52
57 template <typename Mat>
58 struct ImageLeftAction<Mat,
59 typename RhoValue<Mat>::type,
60 std::enable_if_t<IsMaxPlusTruncMat<Mat>>> {
61 // not noexcept because the constructor of std::vector isn't
64 void operator()(result_type& res,
65 result_type const& pt,
66 Mat const& x) const {
67 const_cast<Mat*>(&x)->transpose();
69 const_cast<Mat*>(&x)->transpose();
70 }
71 };
72
74 // Lambda/Rho - MaxPlusTruncMat
76
81 template <typename Mat>
82 struct LambdaValue<Mat, std::enable_if_t<IsMaxPlusTruncMat<Mat>>> {
83 using type =
84 typename detail::StaticVector1<typename Mat::Row, Mat::nr_rows>;
85 };
86
91 template <typename Mat>
92 struct RhoValue<Mat, std::enable_if_t<IsMaxPlusTruncMat<Mat>>> {
96 using type =
97 typename detail::StaticVector1<typename Mat::Row, Mat::nr_rows>;
98 };
99
104 template <typename Mat>
105 struct Lambda<Mat,
106 typename LambdaValue<Mat>::type,
107 std::enable_if_t<IsMaxPlusTruncMat<Mat>>> {
108 using result_type = typename LambdaValue<Mat>::type;
110 void operator()(result_type& res, Mat const& x) const {
111 res.clear();
112 matrix::row_basis_rows<Mat>(x, res);
113 }
114 };
115
120 template <typename Mat>
121 struct Rho<Mat,
122 typename RhoValue<Mat>::type,
123 std::enable_if_t<IsMaxPlusTruncMat<Mat>>> {
124 using result_type = typename RhoValue<Mat>::type;
126 void operator()(result_type& res, Mat const& x) const {
127 // TODO this is inefficient
128 const_cast<Mat*>(&x)->transpose();
129 Lambda<Mat, result_type>()(res, x);
130 const_cast<Mat*>(&x)->transpose();
131 }
132 };
133
135 // Rank - MaxPlusTruncMat
137
141 template <typename Mat>
142 struct Rank<Mat, RankState<Mat>, std::enable_if_t<IsMaxPlusTruncMat<Mat>>> {
144 size_t operator()(Mat const& x) const;
145 };
146} // namespace libsemigroups
147
148#include "max-plus-trunc-mat.tpp"
149
150#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
Stores the image of pt under the left action of p in res.
Definition max-plus-trunc-mat.hpp:63
Adapter for the value of a left action.
Definition adapters.hpp:355
typename LambdaValue< Mat >::type result_type
Stores the image of pt under the right action of p in res.
Definition max-plus-trunc-mat.hpp:47
Adapter for the value of a right action.
Definition adapters.hpp:397
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:110
Adapter for the action on LambdaValue's.
Definition adapters.hpp:838
Adapter for lambda functions.
Definition adapters.hpp:798
size_t operator()(Mat const &x) const
Returns the size of the row space of x.
Adapter for calculating ranks.
Definition adapters.hpp:935
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:126
Adapter for the action on RhoValue's.
Definition adapters.hpp:859
typename detail::StaticVector1< typename Mat::Row, Mat::nr_rows > type
Definition max-plus-trunc-mat.hpp:96
Adapter for rho functions.
Definition adapters.hpp:817