Skip to content

Commit 427167c

Browse files
sims1: add support for Sims1
1 parent 8707115 commit 427167c

File tree

5 files changed

+535
-0
lines changed

5 files changed

+535
-0
lines changed

libsemigroups_pybind11/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
tril,
3535
wilo,
3636
wislo,
37+
Sims1,
3738
)
3839

3940
from .froidure_pin import FroidurePin

src/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ namespace libsemigroups {
123123

124124
init_froidure_pin(m);
125125
init_present(m);
126+
init_sims1(m);
126127

127128
#ifdef VERSION_INFO
128129
m.attr("__version__") = VERSION_INFO;

src/main.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ namespace libsemigroups {
3535
void init_matrix(py::module&);
3636
void init_pbr(py::module&);
3737
void init_present(py::module&);
38+
void init_sims1(py::module&);
3839
void init_todd_coxeter(py::module&);
3940
void init_transf(py::module&);
4041
void init_words(py::module&);

src/sims1.cpp

Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
//
2+
// libsemigroups_pybind11
3+
// Copyright (C) 2022 James D. Mitchell
4+
//
5+
// This program is free software: you can redistribute it and/or modify
6+
// it under the terms of the GNU General Public License as published by
7+
// the Free Software Foundation, either version 3 of the License, or
8+
// (at your option) any later version.
9+
//
10+
// This program is distributed in the hope that it will be useful,
11+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
// GNU General Public License for more details.
14+
//
15+
// You should have received a copy of the GNU General Public License
16+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
//
18+
19+
// TODO:
20+
// * iwyu
21+
// * Sims1::find_if
22+
// * Sims1::for_each
23+
// * Sims1Stats
24+
// * RepOrc
25+
// * MinimalRepOrc
26+
27+
// C std headers....
28+
#include <stddef.h> // for size_t
29+
#include <stdint.h> // for int32_t, size_t
30+
31+
// C++ stl headers....
32+
#include <initializer_list> // for initializer_list
33+
#include <vector> // for vector
34+
35+
// libsemigroups....
36+
#include <libsemigroups/present.hpp> // for Presentation
37+
#include <libsemigroups/sims1.hpp> // for Sims1
38+
39+
// pybind11....
40+
#include <pybind11/pybind11.h> // for class_, init, module
41+
#include <pybind11/stl.h>
42+
43+
// libsemigroups_pybind11....
44+
#include "main.hpp" // for init_sims1
45+
46+
namespace py = pybind11;
47+
48+
namespace libsemigroups {
49+
void init_sims1(py::module& m) {
50+
py::class_<Sims1Stats>(m, "Sims1Stats")
51+
.def_readonly("max_pending", &Sims1Stats::max_pending)
52+
.def_readonly("total_pending", &Sims1Stats::total_pending);
53+
54+
py::class_<Sims1<size_t>>(m, "Sims1")
55+
.def(py::init<congruence_kind>())
56+
.def(py::init<Sims1<size_t> const&>())
57+
.def("number_of_threads",
58+
py::overload_cast<size_t>(&Sims1<size_t>::number_of_threads),
59+
py::arg("val"),
60+
R"pbdoc(
61+
Set the number of threads.
62+
63+
:Parameters: **val** (int) - the maximum number of threads to use.
64+
65+
:Returns: ``self``.
66+
)pbdoc")
67+
.def("number_of_threads",
68+
py::overload_cast<>(&Sims1<size_t>::number_of_threads, py::const_),
69+
R"pbdoc(
70+
Returns the current number of threads.
71+
72+
:Parameters: None
73+
74+
:Returns: An ``int``.
75+
)pbdoc")
76+
.def("report_interval",
77+
py::overload_cast<>(&Sims1<size_t>::report_interval, py::const_),
78+
R"pbdoc(
79+
Returns the current report interval.
80+
81+
:Parameters: None
82+
83+
:Returns: A ``int``.
84+
)pbdoc")
85+
.def("report_interval",
86+
py::overload_cast<size_t>(&Sims1<size_t>::report_interval),
87+
py::arg("val"),
88+
R"pbdoc(
89+
Set the report interval.
90+
91+
:Parameters: **val** (int) - the new value for the report interval.
92+
93+
:Returns: ``self``.
94+
)pbdoc")
95+
.def(
96+
"short_rules",
97+
[](Sims1<size_t> const& s) { return s.short_rules(); },
98+
R"pbdoc(
99+
Returns the current short rules.
100+
101+
:Parameters: None
102+
103+
:Returns: A ``Presentation``.
104+
)pbdoc")
105+
.def("short_rules",
106+
&Sims1<size_t>::short_rules<Presentation<word_type>>,
107+
py::arg("p"),
108+
R"pbdoc(
109+
Set the short rules.
110+
111+
:Parameters: **p** (Presentation) - the presentation.
112+
113+
:Returns: ``self``.
114+
)pbdoc")
115+
.def("short_rules",
116+
&Sims1<size_t>::short_rules<Presentation<std::string>>,
117+
py::arg("p"),
118+
R"pbdoc(
119+
Set the short rules.
120+
121+
:Parameters: **p** (Presentation) - the presentation.
122+
123+
:Returns: ``self``.
124+
)pbdoc")
125+
.def(
126+
"long_rules",
127+
[](Sims1<size_t> const& s) { return s.long_rules(); },
128+
R"pbdoc(
129+
Returns the current long rules.
130+
131+
:Parameters: None
132+
133+
:Returns: A ``Presentation``.
134+
)pbdoc")
135+
.def("long_rules",
136+
&Sims1<size_t>::long_rules<Presentation<word_type>>,
137+
py::arg("p"),
138+
R"pbdoc(
139+
Set the long rules.
140+
141+
:Parameters: **p** (Presentation) - the presentation.
142+
143+
:Returns: ``self``.
144+
)pbdoc")
145+
.def("long_rules",
146+
&Sims1<size_t>::long_rules<Presentation<std::string>>,
147+
py::arg("p"),
148+
R"pbdoc(
149+
Set the long rules.
150+
151+
:Parameters: **p** (Presentation) - the presentation.
152+
153+
:Returns: ``self``.
154+
)pbdoc")
155+
.def("stats",
156+
py::overload_cast<>(&Sims1<size_t>::stats, py::const_),
157+
R"pbdoc(
158+
Returns the current stats object.
159+
160+
:Parameters: None
161+
162+
:Returns: A ``Sims1Stats`` object.
163+
)pbdoc")
164+
.def("split_at",
165+
&Sims1<size_t>::split_at,
166+
py::arg("val"),
167+
R"pbdoc(
168+
Split the rules in short_rules and long_rules.
169+
170+
:param val: the relation to split at.
171+
:type val: int
172+
173+
:return: (None)
174+
)pbdoc")
175+
.def("long_rule_length",
176+
&Sims1<size_t>::long_rule_length,
177+
py::arg("val"),
178+
R"pbdoc(
179+
Define the long rule length.
180+
181+
:param val: the value of the long rule length.
182+
:type val: int
183+
184+
:return: ``self``.
185+
)pbdoc")
186+
.def(
187+
"extra",
188+
[](Sims1<size_t> const& s) { return s.extra(); },
189+
R"pbdoc(
190+
Returns the additional defining pairs.
191+
192+
:Parameters: None
193+
194+
:Returns: A ``Presentation``.
195+
)pbdoc")
196+
.def("extra",
197+
&Sims1<size_t>::extra<Presentation<word_type>>,
198+
py::arg("p"),
199+
R"pbdoc(
200+
Set the extra rules.
201+
202+
:Parameters: **p** (Presentation) - the presentation.
203+
204+
:Returns: ``self``.
205+
)pbdoc")
206+
.def("extra",
207+
&Sims1<size_t>::extra<Presentation<std::string>>,
208+
py::arg("p"),
209+
R"pbdoc(
210+
Set the extra rules.
211+
212+
:Parameters: **p** (Presentation) - the presentation.
213+
214+
:Returns: ``self``.
215+
)pbdoc")
216+
.def(
217+
"iterator",
218+
[](Sims1<size_t> const& s, size_t n) {
219+
return py::make_iterator(s.cbegin(n), s.cend(n));
220+
},
221+
R"pbdoc(
222+
Returns an iterator pointing at the first congruence.
223+
224+
:param n: the maximum number of classes in a congruence.
225+
:type n: int
226+
227+
:return: An iterator pointing to an ActionDigraph with at most n nodes.
228+
)pbdoc")
229+
.def("number_of_congruences",
230+
&Sims1<size_t>::number_of_congruences,
231+
py::arg("n"),
232+
R"pbdoc(
233+
Returns the number of one-sided congruences with up to a given number of classes.
234+
235+
:param n: the maximum number of congruence classes.
236+
:type n: int
237+
238+
:return: A value of type uint64_t.
239+
)pbdoc");
240+
}
241+
} // namespace libsemigroups

0 commit comments

Comments
 (0)