|
18 | 18 |
|
19 | 19 | // C++ stl headers.... |
20 | 20 | #include <string> // for string |
| 21 | +#include <vector> // for vector |
21 | 22 |
|
22 | 23 | // libsemigroups.... |
23 | 24 | #include <libsemigroups/order.hpp> // for *_cmp, Order |
@@ -260,6 +261,85 @@ Compare two words using reversed recursive-path ordering. |
260 | 261 | This will be removed from ``libsemigroups_pybind11`` in v2. Instead, use |
261 | 262 | :any:`rev_rpo_cmp`. |
262 | 263 | )pbdoc"); |
| 264 | + |
| 265 | + m.def( |
| 266 | + "wr_cmp", |
| 267 | + [](std::vector<size_t> const& levels, Word const& x, Word const& y) { |
| 268 | + return wr_cmp(levels, x, y); |
| 269 | + }, |
| 270 | + py::arg("levels"), |
| 271 | + py::arg("x"), |
| 272 | + py::arg("y"), |
| 273 | + R"pbdoc( |
| 274 | +:sig=(levels: list[int], x: str | list[int], y: str | list[int]) -> bool: |
| 275 | +:only-document-once: |
| 276 | +Compare two words using wreath-product ordering. |
| 277 | +
|
| 278 | +The *i*-th entry of *levels* is the level assigned to generator *i*. |
| 279 | +Differences at higher levels dominate differences at lower levels, and |
| 280 | +differences within one level are compared using len-lex ordering. |
| 281 | +
|
| 282 | +:param levels: the level assigned to each generator. |
| 283 | +:type levels: list[int] |
| 284 | +:param x: the first word. |
| 285 | +:type x: str | list[int] |
| 286 | +:param y: the second word. |
| 287 | +:type y: str | list[int] |
| 288 | +:returns: Whether *x* is less than *y*. |
| 289 | +:rtype: bool |
| 290 | +
|
| 291 | +:raises LibsemigroupsError: if a letter is not a valid index into *levels*. |
| 292 | +
|
| 293 | +.. doctest:: python |
| 294 | +
|
| 295 | + >>> from libsemigroups_pybind11 import wr_cmp |
| 296 | + >>> levels = [1, 1, 0] |
| 297 | + >>> wr_cmp(levels, [2, 1, 2, 2], [2, 2, 1, 2]) |
| 298 | + True |
| 299 | +)pbdoc"); |
| 300 | + |
| 301 | + m.def( |
| 302 | + "wr_cmp", |
| 303 | + [](Alphabet<Word> const& alphabet, |
| 304 | + std::vector<size_t> const& levels, |
| 305 | + Word const& x, |
| 306 | + Word const& y) { return wr_cmp(alphabet, levels, x, y); }, |
| 307 | + py::arg("alphabet"), |
| 308 | + py::arg("levels"), |
| 309 | + py::arg("x"), |
| 310 | + py::arg("y"), |
| 311 | + R"pbdoc( |
| 312 | +:sig=(alphabet: Alphabet, levels: list[int], x: str | list[int], y: str | list[int]) -> bool: |
| 313 | +:only-document-once: |
| 314 | +Compare two words using alphabet-aware wreath-product ordering. |
| 315 | +
|
| 316 | +Letters are mapped to their positions in *alphabet*, and the *i*-th entry of |
| 317 | +*levels* is the level assigned to the *i*-th letter of *alphabet*. |
| 318 | +Differences at higher levels dominate differences at lower levels, and |
| 319 | +differences within one level are compared using len-lex ordering. |
| 320 | +
|
| 321 | +:param alphabet: the ordered alphabet containing the letters of both words. |
| 322 | +:type alphabet: Alphabet |
| 323 | +:param levels: the level assigned to each letter of *alphabet*. |
| 324 | +:type levels: list[int] |
| 325 | +:param x: the first word. |
| 326 | +:type x: str | list[int] |
| 327 | +:param y: the second word. |
| 328 | +:type y: str | list[int] |
| 329 | +:returns: Whether *x* is less than *y*. |
| 330 | +:rtype: bool |
| 331 | +
|
| 332 | +:raises LibsemigroupsError: if a letter does not belong to *alphabet*, or its |
| 333 | + position in *alphabet* is not a valid index into *levels*. |
| 334 | +
|
| 335 | +.. doctest:: python |
| 336 | +
|
| 337 | + >>> from libsemigroups_pybind11 import Alphabet, wr_cmp |
| 338 | + >>> alphabet = Alphabet("bac") |
| 339 | + >>> levels = [1, 1, 0] |
| 340 | + >>> wr_cmp(alphabet, levels, "cbcc", "ccbc") |
| 341 | + True |
| 342 | +)pbdoc"); |
263 | 343 | } |
264 | 344 | } // namespace |
265 | 345 |
|
@@ -322,7 +402,7 @@ respectively, in new code. |
322 | 402 |
|
323 | 403 | The recursive-path ordering, as described in :cite:`Jantzen2012aa` |
324 | 404 | (Definition 1.2.14, page 24). |
325 | | - |
| 405 | +
|
326 | 406 | This is deprecated; use :any:`Order.rpo` instead. |
327 | 407 | )pbdoc") |
328 | 408 | .value("none", Order::none) |
|
0 commit comments