diff --git a/include/libsemigroups/transf.hpp b/include/libsemigroups/transf.hpp index 091ce8237..2a56b1f63 100644 --- a/include/libsemigroups/transf.hpp +++ b/include/libsemigroups/transf.hpp @@ -50,7 +50,7 @@ #include "debug.hpp" // for LIBSEMIGROUPS_ASSERT #include "exception.hpp" // for LIBSEMIGROUPS_EXCEPTION #include "hpcombi.hpp" // for HPCombi::Transf16 -#include "types.hpp" // for SmallestInteger +#include "types.hpp" // for SmallestInteger, enable_if_is_same #include "detail/stl.hpp" // for is_array_v @@ -1058,57 +1058,6 @@ namespace libsemigroups { } }; - //! \relates Transf - //! - //! \brief Construct from universal reference container and validate. - //! - //! Constructs a \ref Transf initialized using the container \p cont as - //! follows: the image of the point \c i under the transformation is the value - //! in position \c i of the container \p cont. - //! - //! \tparam N the degree (default: \c 0) - //! \tparam Scalar an unsigned integer type (the type of the image values) - //! \tparam OtherContainer universal reference for the type of the container - //! (default: Container). - //! - //! \param cont the container. - //! - //! \returns A \ref Transf instance with degree \c N. - //! - //! \throw LibsemigroupsException if any of the following hold: - //! * the size of \p cont is incompatible with \ref container_type. - //! * any value in \p cont exceeds `cont.size()` and is not equal to - //! UNDEFINED. - //! - //! \complexity - //! Linear in the size of the container \p cont. - template < - size_t N = 0, - typename Scalar - = std::conditional_t::type>, - typename OtherContainer> - [[nodiscard]] Transf to_transf(OtherContainer&& cont) { - return Transf::template make>( - std::forward(cont)); - } - - //! \relates Transf - //! - //! \copydoc to_transf(OtherContainer&&) - //! - //! \throws LibsemigroupsException if the value \ref UNDEFINED belongs to \p - //! cont. - template < - size_t N = 0, - typename Scalar - = std::conditional_t::type>, - typename OtherScalar> - [[nodiscard]] Transf - to_transf(std::initializer_list cont) { - return to_transf>( - std::move(cont)); - } - namespace detail { template struct IsTransfHelper : std::false_type {}; @@ -1159,6 +1108,68 @@ namespace libsemigroups { template void validate(Transf const& f); + //////////////////////////////////////////////////////////////////////// + // to + //////////////////////////////////////////////////////////////////////// + + //! \relates Transf + //! + //! \brief Construct a \ref Transf from universal reference container and + //! validate. + //! + //! Constructs a \ref Transf initialized using the container \p cont as + //! follows: the image of the point \c i under the transformation is the value + //! in position \c i of the container \p cont. + //! + //! \tparam Return the return type. + //! \tparam OtherContainer universal reference for the type of the container. + //! + //! \param cont the container. + //! + //! \returns A \ref Transf instance with degree \c N. + //! + //! \throw LibsemigroupsException if any of the following hold: + //! * the size of \p cont is incompatible with \ref container_type. + //! * any value in \p cont exceeds `cont.size()` and is not equal to + //! UNDEFINED. + //! + //! \complexity + //! Linear in the size of the container \p cont. + template + [[nodiscard]] std::enable_if_t, Return> + to(OtherContainer&& cont) { + return Return::template make(std::forward(cont)); + } + + //! \relates Transf + //! + //! \brief Construct a \ref Transf from initializer list and validate. + //! + //! Constructs a \ref Transf initialized using the initializer list \p cont as + //! follows: the image of the point \c i under the transformation is the value + //! in position \c i of the container \p cont. + //! + //! \tparam Return the return type. + //! \tparam OtherContainer universal reference for the type of the container. + //! + //! \param cont the container. + //! + //! \returns A \ref Transf instance with degree \c N. + //! + //! \throw LibsemigroupsException if any of the following hold: + //! * the size of \p cont is incompatible with \ref container_type. + //! * any value in \p cont exceeds `cont.size()` and is not equal to + //! UNDEFINED. + //! * the value \ref UNDEFINED belongs to \p cont. + //! + //! \complexity + //! Linear in the size of the container \p cont. + template + [[nodiscard]] std::enable_if_t, Return> + to(std::initializer_list cont) { + return to>(std::move(cont)); + } + //////////////////////////////////////////////////////////////////////// // PPerm //////////////////////////////////////////////////////////////////////// @@ -1231,9 +1242,6 @@ namespace libsemigroups { //! //! \warning //! No checks whatsoever are performed on the validity of the arguments. - //! - //! \sa - //! \ref to_pperm. // // Note: we use vectors here not container_type (which might be array), // because the length of dom and img might not equal degree(). @@ -1276,103 +1284,6 @@ namespace libsemigroups { } }; - //! \relates PPerm - //! - //! \brief Construct from universal reference container and validate. - //! - //! Constructs a \ref PPerm initialized using the container \p cont as - //! follows: the image of the point \c i under the partial permutation is the - //! value in position \c i of the container \p cont. - //! - //! \tparam N the degree (default: \c 0) - //! \tparam Scalar an unsigned integer type (the type of the image values) - //! \tparam OtherContainer universal reference for the type of the container - //! (default: Container). - //! - //! \param cont the container. - //! - //! \returns A \ref PPerm instance with degree \c N. - //! - //! \throw LibsemigroupsException if any of the following hold: - //! * the size of \p cont is incompatible with \ref container_type. - //! * any value in \p cont exceeds `cont.size()` and is not equal to - //! UNDEFINED. - //! - //! \complexity - //! Linear in the size of the container \p cont. - template < - size_t N = 0, - typename Scalar - = std::conditional_t::type>, - typename OtherContainer> - [[nodiscard]] PPerm to_pperm(OtherContainer&& cont) { - return PPerm::template make>( - std::forward(cont)); - } - - //! \relates PPerm - //! - //! \copydoc to_pperm(OtherContainer&&) - template < - size_t N = 0, - typename Scalar - = std::conditional_t::type>> - [[nodiscard]] PPerm - to_pperm(std::initializer_list::point_type> cont) { - return to_pperm< - N, - Scalar, - std::initializer_list::point_type>>( - std::move(cont)); - } - - //! \relates PPerm - //! - //! \brief Construct from domain, range, and degree, and validate - //! - //! Constructs a partial perm of degree \p M such that `f[dom[i]] = - //! ran[i]` for all \c i and which is \ref UNDEFINED on every other value - //! in the range \f$[0, M)\f$. - //! - //! \param dom the domain - //! \param ran the range - //! \param M the degree - //! - //! \throws LibsemigroupsException if any of the following fail to hold: - //! * the value \p M is not compatible with the template parameter \p N - //! * \p dom and \p ran do not have the same size - //! * any value in \p dom or \p ran is greater than \p M - //! * there are repeated entries in \p dom or \p ran. - //! - //! \complexity - //! Linear in the size of \p dom. - template < - size_t N = 0, - typename Scalar - = std::conditional_t::type>> - [[nodiscard]] PPerm - to_pperm(std::vector::point_type> const& dom, - std::vector::point_type> const& ran, - size_t M); - - //! \relates PPerm - //! - //! \copydoc to_pperm(std::vector::point_type> - //! const&,std::vector::point_type> const&,size_t) - template < - size_t N = 0, - typename Scalar - = std::conditional_t::type>> - [[nodiscard]] PPerm - to_pperm(std::initializer_list::point_type> dom, - std::initializer_list::point_type> ran, - size_t M) { - return to_pperm( - std::vector::point_type>(dom), - std::vector::point_type>(ran), - M); - } - namespace detail { //! No doc // TODO to tpp @@ -1468,6 +1379,137 @@ namespace libsemigroups { detail::validate_no_duplicates(f.begin(), f.end()); } + //////////////////////////////////////////////////////////////////////// + // to + //////////////////////////////////////////////////////////////////////// + + //! \relates PPerm + //! + //! \brief Construct a \ref PPerm from universal reference container and + //! validate. + //! + //! Constructs a \ref PPerm initialized using the container \p cont as + //! follows: the image of the point \c i under the partial permutation is the + //! value in position \c i of the container \p cont. + //! + //! \tparam Return the return type. + //! \tparam N the degree (default: \c 0). + //! \tparam Scalar an unsigned integer type (the type of the image values). + //! \tparam OtherContainer universal reference for the type of the container. + //! + //! \param cont the container. + //! + //! \returns A \ref PPerm instance with degree \c N. + //! + //! \throw LibsemigroupsException if any of the following hold: + //! * the size of \p cont is incompatible with \ref container_type. + //! * any value in \p cont exceeds `cont.size()` and is not equal to + //! UNDEFINED. + //! + //! \complexity + //! Linear in the size of the container \p cont. + template + [[nodiscard]] std::enable_if_t, Return> + to(OtherContainer&& cont) { + return Return::template make(std::forward(cont)); + } + + //! \relates PPerm + //! + //! \brief Construct a \ref PPerm from initializer list and validate. + //! + //! Constructs a \ref PPerm initialized using the container \p cont as + //! follows: the image of the point \c i under the partial permutation is the + //! value in position \c i of the container \p cont. + //! + //! \tparam Return the return type. + //! \tparam N the degree (default: \c 0). + //! \tparam Scalar an unsigned integer type (the type of the image values). + //! + //! \param cont the container. + //! + //! \returns A \ref PPerm instance with degree \c N. + //! + //! \throw LibsemigroupsException if any of the following hold: + //! * the size of \p cont is incompatible with \ref container_type. + //! * any value in \p cont exceeds `cont.size()` and is not equal to + //! UNDEFINED. + //! + //! \complexity + //! Linear in the size of the container \p cont. + template + [[nodiscard]] std::enable_if_t, Return> + to(std::initializer_list cont) { + return to>( + std::move(cont)); + } + + //! \relates PPerm + //! + //! \brief Construct a \ref PPerm from domain, range, and degree, and + //! validate. + //! + //! Constructs a partial perm of degree \p M such that `f[dom[i]] = + //! ran[i]` for all \c i and which is \ref UNDEFINED on every other value + //! in the range \f$[0, M)\f$. + //! + //! \tparam Return the return type. + //! \tparam N the degree (default: \c 0). + //! \tparam Scalar an unsigned integer type (the type of the image values). + //! + //! \param dom the domain + //! \param ran the range + //! \param M the degree + //! + //! \throws LibsemigroupsException if any of the following fail to hold: + //! * the value \p M is not compatible with the template parameter \p N + //! * \p dom and \p ran do not have the same size + //! * any value in \p dom or \p ran is greater than \p M + //! * there are repeated entries in \p dom or \p ran. + //! + //! \complexity + //! Linear in the size of \p dom. + template + [[nodiscard]] std::enable_if_t, Return> + to(std::vector const& dom, + std::vector const& ran, + size_t M); + + //! \relates PPerm + //! + //! \brief Construct a \ref PPerm from domain, range, and degree, and + //! validate. + //! + //! Constructs a partial perm of degree \p M such that `f[dom[i]] = + //! ran[i]` for all \c i and which is \ref UNDEFINED on every other value + //! in the range \f$[0, M)\f$. + //! + //! \tparam Return the return type. + //! \tparam N the degree (default: \c 0). + //! \tparam Scalar an unsigned integer type (the type of the image values). + //! + //! \param dom the domain + //! \param ran the range + //! \param M the degree + //! + //! \throws LibsemigroupsException if any of the following fail to hold: + //! * the value \p M is not compatible with the template parameter \p N + //! * \p dom and \p ran do not have the same size + //! * any value in \p dom or \p ran is greater than \p M + //! * there are repeated entries in \p dom or \p ran. + //! + //! \complexity + //! Linear in the size of \p dom. + template + [[nodiscard]] std::enable_if_t, Return> + to(std::initializer_list dom, + std::initializer_list ran, + size_t M) { + return to(std::vector(dom), + std::vector(ran), + M); + } + //////////////////////////////////////////////////////////////////////// // Perm //////////////////////////////////////////////////////////////////////// @@ -1525,56 +1567,6 @@ namespace libsemigroups { } }; - //! \relates Perm - //! - //! \brief Construct from universal reference container and validate. - //! - //! Constructs a \ref Perm initialized using the container \p cont as - //! follows: the image of the point \c i under the permutation is the value in - //! position \c i of the container \p cont. - //! - //! \tparam N the degree (default: \c 0) - //! \tparam Scalar an unsigned integer type (the type of the image values) - //! \tparam OtherContainer universal reference for the type of the container - //! (default: Container). - //! - //! \param cont the container. - //! - //! \returns A \ref Perm instance with degree \c N. - //! - //! \throw LibsemigroupsException if any of the following hold: - //! * the size of \p cont is incompatible with \ref container_type. - //! * any value in \p cont exceeds `cont.size()` and is not equal to - //! UNDEFINED. - //! * there are repeated values in \p cont. - //! - //! \complexity - //! Linear in the size of the container \p cont. - template < - size_t N = 0, - typename Scalar - = std::conditional_t::type>, - typename OtherContainer> - [[nodiscard]] Perm to_perm(OtherContainer&& cont) { - return Perm::template make>( - std::forward(cont)); - } - - //! \relates Perm - //! - //! \copydoc to_perm(OtherContainer&&) - template < - size_t N = 0, - typename Scalar - = std::conditional_t::type>> - [[nodiscard]] Perm - to_perm(std::initializer_list::point_type> cont) { - return to_perm::point_type>>( - std::move(cont)); - } - //////////////////////////////////////////////////////////////////////// // Perm helpers //////////////////////////////////////////////////////////////////////// @@ -1620,6 +1612,68 @@ namespace libsemigroups { detail::validate_no_duplicates(f.begin(), f.end()); } + //////////////////////////////////////////////////////////////////////// + // to + //////////////////////////////////////////////////////////////////////// + + //! \relates Perm + //! + //! \brief Construct from universal reference container and validate. + //! + //! Constructs a \ref Perm initialized using the container \p cont as + //! follows: the image of the point \c i under the permutation is the value in + //! position \c i of the container \p cont. + //! + //! \tparam Return the return type. + //! \tparam OtherContainer universal reference for the type of the container. + //! + //! \param cont the container. + //! + //! \returns A \ref Perm instance with degree \c N. + //! + //! \throw LibsemigroupsException if any of the following hold: + //! * the size of \p cont is incompatible with \ref container_type. + //! * any value in \p cont exceeds `cont.size()` and is not equal to + //! UNDEFINED. + //! * there are repeated values in \p cont. + //! + //! \complexity + //! Linear in the size of the container \p cont. + template + [[nodiscard]] std::enable_if_t, Return> + to(OtherContainer&& cont) { + return Return::template make(std::forward(cont)); + } + + //! \relates Perm + //! + //! \brief Construct from universal reference container and validate. + //! + //! Constructs a \ref Perm initialized using the container \p cont as + //! follows: the image of the point \c i under the permutation is the value in + //! position \c i of the container \p cont. + //! + //! \tparam Return the return type. + //! + //! \param cont the container. + //! + //! \returns A \ref Perm instance with degree \c N. + //! + //! \throw LibsemigroupsException if any of the following hold: + //! * the size of \p cont is incompatible with \ref container_type. + //! * any value in \p cont exceeds `cont.size()` and is not equal to + //! UNDEFINED. + //! * there are repeated values in \p cont. + //! + //! \complexity + //! Linear in the size of the container \p cont. + template + [[nodiscard]] std::enable_if_t, Return> + to(std::initializer_list cont) { + return to>( + std::move(cont)); + } + //////////////////////////////////////////////////////////////////////// // Helper functions //////////////////////////////////////////////////////////////////////// diff --git a/include/libsemigroups/transf.tpp b/include/libsemigroups/transf.tpp index 1010f4f7e..a04397dfc 100644 --- a/include/libsemigroups/transf.tpp +++ b/include/libsemigroups/transf.tpp @@ -172,14 +172,13 @@ namespace libsemigroups { detail::validate_no_duplicates(ran.cbegin(), ran.cend(), seen); } - // STATIC - template - [[nodiscard]] PPerm - to_pperm(std::vector::point_type> const& dom, - std::vector::point_type> const& ran, - size_t const M) { + template + [[nodiscard]] std::enable_if_t, Return> + to(std::vector const& dom, + std::vector const& ran, + size_t const M) { detail::validate_args(dom, ran, M); - PPerm result(dom, ran, M); + Return result(dom, ran, M); validate(result); return result; } diff --git a/tests/test-transf.cpp b/tests/test-transf.cpp index 092525846..ae92f2abb 100644 --- a/tests/test-transf.cpp +++ b/tests/test-transf.cpp @@ -62,7 +62,7 @@ namespace libsemigroups { } else { REQUIRE_THROWS_AS(x.increase_degree_by(10), LibsemigroupsException); } - auto t = to_transf({9, 7, 3, 5, 3, 4, 2, 7, 7, 1}); + auto t = to>({9, 7, 3, 5, 3, 4, 2, 7, 7, 1}); REQUIRE(t.hash_value() != 0); REQUIRE_NOTHROW(t.undef()); } @@ -137,18 +137,19 @@ namespace libsemigroups { "[quick][transf]") { using point_type = typename Transf<>::point_type; REQUIRE_NOTHROW(Transf()); - REQUIRE_NOTHROW(to_transf({0})); - REQUIRE_THROWS_AS(to_transf({1}), LibsemigroupsException); + REQUIRE_NOTHROW(to>({0})); + REQUIRE_THROWS_AS(to>({1}), LibsemigroupsException); - REQUIRE_NOTHROW(to_transf({0, 1, 2})); - REQUIRE_NOTHROW(to_transf(std::initializer_list({0, 1, 2}))); - REQUIRE_NOTHROW(to_transf({0, 1, 2})); + REQUIRE_NOTHROW(to>({0, 1, 2})); + REQUIRE_NOTHROW(to>(std::initializer_list({0, 1, 2}))); + REQUIRE_NOTHROW(to>({0, 1, 2})); - REQUIRE_THROWS_AS(to_transf({1, 2, 3}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_transf(std::initializer_list({1, 2, 3})), - LibsemigroupsException); + REQUIRE_THROWS_AS(to>({1, 2, 3}), LibsemigroupsException); + REQUIRE_THROWS_AS( + to>(std::initializer_list({1, 2, 3})), + LibsemigroupsException); - REQUIRE_THROWS_AS(to_transf(std::initializer_list( + REQUIRE_THROWS_AS(to>(std::initializer_list( {UNDEFINED, UNDEFINED, UNDEFINED})), LibsemigroupsException); } @@ -157,15 +158,15 @@ namespace libsemigroups { "003", "exceptions (static)", "[quick][transf]") { - REQUIRE_NOTHROW(to_transf({0})); - REQUIRE_THROWS_AS(to_transf({1}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_transf({1}), LibsemigroupsException); + REQUIRE_NOTHROW(to>({0})); + REQUIRE_THROWS_AS(to>({1}), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({1}), LibsemigroupsException); - REQUIRE_NOTHROW(to_transf({0, 1, 2})); + REQUIRE_NOTHROW(to>({0, 1, 2})); - REQUIRE_THROWS_AS(to_transf({1, 2, 3}), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({1, 2, 3}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_transf({UNDEFINED, UNDEFINED, UNDEFINED}), + REQUIRE_THROWS_AS(to>({UNDEFINED, UNDEFINED, UNDEFINED}), LibsemigroupsException); } @@ -180,41 +181,41 @@ namespace libsemigroups { "[quick][pperm]") { using point_type = typename Transf<>::point_type; REQUIRE_NOTHROW(PPerm<>()); - REQUIRE_NOTHROW(to_pperm({0})); - REQUIRE_NOTHROW(to_pperm({UNDEFINED})); - REQUIRE_THROWS_AS(to_pperm({1}), LibsemigroupsException); + REQUIRE_NOTHROW(to>({0})); + REQUIRE_NOTHROW(to>({UNDEFINED})); + REQUIRE_THROWS_AS(to>({1}), LibsemigroupsException); - REQUIRE_NOTHROW(to_pperm({0, 1, 2})); - REQUIRE_NOTHROW(to_pperm(std::initializer_list({0, 1, 2}))); - REQUIRE_NOTHROW(to_pperm({0, UNDEFINED, 2})); - REQUIRE_NOTHROW(to_pperm({0, UNDEFINED, 5, UNDEFINED, UNDEFINED, 1})); + REQUIRE_NOTHROW(to>({0, 1, 2})); + REQUIRE_NOTHROW(to>(std::initializer_list({0, 1, 2}))); + REQUIRE_NOTHROW(to>({0, UNDEFINED, 2})); + REQUIRE_NOTHROW(to>({0, UNDEFINED, 5, UNDEFINED, UNDEFINED, 1})); - REQUIRE_THROWS_AS(to_pperm({1, 2, 3}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_pperm({UNDEFINED, UNDEFINED, 3}), + REQUIRE_THROWS_AS(to>({1, 2, 3}), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({UNDEFINED, UNDEFINED, 3}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_pperm({1, UNDEFINED, 1}), LibsemigroupsException); - REQUIRE_THROWS_AS( - to_pperm(std::vector({3, UNDEFINED, 2, 1, UNDEFINED, 3})), - LibsemigroupsException); - REQUIRE_THROWS_AS(to_pperm(std::initializer_list({1, 2, 3})), + REQUIRE_THROWS_AS(to>({1, UNDEFINED, 1}), LibsemigroupsException); + REQUIRE_THROWS_AS(to>(std::vector( + {3, UNDEFINED, 2, 1, UNDEFINED, 3})), + LibsemigroupsException); + REQUIRE_THROWS_AS(to>(std::initializer_list({1, 2, 3})), LibsemigroupsException); - REQUIRE_NOTHROW(to_pperm(std::initializer_list({1, 2}), - std::initializer_list({0, 3}), - 5)); - REQUIRE_NOTHROW(to_pperm<5, uint32_t>({1, 2}, {0, 3}, 5)); + REQUIRE_NOTHROW(to>(std::initializer_list({1, 2}), + std::initializer_list({0, 3}), + 5)); + REQUIRE_NOTHROW(to>({1, 2}, {0, 3}, 5)); REQUIRE_NOTHROW(PPerm<5, uint32_t>({1, 2}, {0, 3}, 5)); REQUIRE_NOTHROW(PPerm<>({1, 2}, {0, 3}, 5)); - REQUIRE_NOTHROW(to_pperm({1, 2}, {0, 5}, 6)); - REQUIRE_THROWS_AS(to_pperm({1, 2}, {0}, 5), LibsemigroupsException); - REQUIRE_THROWS_AS(to_pperm({1, 2}, {0, 5}, 4), LibsemigroupsException); - REQUIRE_THROWS_AS(to_pperm({1, 5}, {0, 2}, 4), LibsemigroupsException); - - REQUIRE_THROWS_AS(to_pperm({1, 1}, {0, 2}, 3), LibsemigroupsException); - REQUIRE_THROWS_AS(to_pperm({1, 0}, {2, 2}, 3), LibsemigroupsException); - REQUIRE_THROWS_AS(to_pperm({1, 2}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_pperm({1, 0, 3}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_pperm({1, 0, 3, 6, 4}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_pperm({1, 5, 0, 3, 2}), LibsemigroupsException); + REQUIRE_NOTHROW(to>({1, 2}, {0, 5}, 6)); + REQUIRE_THROWS_AS(to>({1, 2}, {0}, 5), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({1, 2}, {0, 5}, 4), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({1, 5}, {0, 2}, 4), LibsemigroupsException); + + REQUIRE_THROWS_AS(to>({1, 1}, {0, 2}, 3), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({1, 0}, {2, 2}, 3), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({1, 2}), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({1, 0, 3}), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({1, 0, 3, 6, 4}), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({1, 5, 0, 3, 2}), LibsemigroupsException); } LIBSEMIGROUPS_TEST_CASE("PPerm", @@ -222,37 +223,37 @@ namespace libsemigroups { "exceptions (static)", "[quick][pperm]") { using point_type = typename PPerm<6>::point_type; - REQUIRE_NOTHROW(to_pperm<1>({0})); - REQUIRE_NOTHROW(to_pperm<1>({UNDEFINED})); - REQUIRE_THROWS_AS(to_pperm<1>({1}), LibsemigroupsException); + REQUIRE_NOTHROW(to>({0})); + REQUIRE_NOTHROW(to>({UNDEFINED})); + REQUIRE_THROWS_AS(to>({1}), LibsemigroupsException); - REQUIRE_NOTHROW(to_pperm<3>({0, 1, 2})); - REQUIRE_NOTHROW(to_pperm<3>({0, 1, 2})); - REQUIRE_NOTHROW(to_pperm<3>({0, UNDEFINED, 2})); - REQUIRE_NOTHROW(to_pperm<6>({0, UNDEFINED, 5, UNDEFINED, UNDEFINED, 1})); + REQUIRE_NOTHROW(to>({0, 1, 2})); + REQUIRE_NOTHROW(to>({0, 1, 2})); + REQUIRE_NOTHROW(to>({0, UNDEFINED, 2})); + REQUIRE_NOTHROW(to>({0, UNDEFINED, 5, UNDEFINED, UNDEFINED, 1})); - REQUIRE_THROWS_AS(to_pperm<3>({1, 2, 3}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_pperm<3>({UNDEFINED, UNDEFINED, 3}), + REQUIRE_THROWS_AS(to>({1, 2, 3}), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({UNDEFINED, UNDEFINED, 3}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_pperm<3>({1, UNDEFINED, 1}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_pperm<6>({3, UNDEFINED, 2, 1, UNDEFINED, 3}), + REQUIRE_THROWS_AS(to>({1, UNDEFINED, 1}), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({3, UNDEFINED, 2, 1, UNDEFINED, 3}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_pperm<3>({1, 2, 3}), LibsemigroupsException); - REQUIRE_NOTHROW(to_pperm<5>({1, 2}, {0, 3}, 5)); - REQUIRE_NOTHROW(to_pperm<6>({1, 2}, {0, 5}, 6)); - REQUIRE_THROWS_AS(to_pperm<5>({1, 2}, {0}, 5), LibsemigroupsException); - REQUIRE_THROWS_AS(to_pperm<4>({1, 2}, {0, 5}, 4), LibsemigroupsException); - REQUIRE_THROWS_AS(to_pperm<4>({1, 5}, {0, 2}, 4), LibsemigroupsException); - - REQUIRE_THROWS_AS(to_pperm<3>({1, 1}, {0, 2}, 3), LibsemigroupsException); - REQUIRE_THROWS_AS(to_pperm<3>({0, 2}, {1, 1}, 3), LibsemigroupsException); - - REQUIRE_THROWS_AS(to_pperm<1>({1, 2}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_pperm<2>({1, 2}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_pperm<3>({1, 0, 3}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_pperm<5>({1, 0, 3, 6, 4}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_pperm<5>({1, 5, 0, 3, 2}), LibsemigroupsException); - auto x = to_pperm<5>({0, 2}, {3, 0}, 5); + REQUIRE_THROWS_AS(to>({1, 2, 3}), LibsemigroupsException); + REQUIRE_NOTHROW(to>({1, 2}, {0, 3}, 5)); + REQUIRE_NOTHROW(to>({1, 2}, {0, 5}, 6)); + REQUIRE_THROWS_AS(to>({1, 2}, {0}, 5), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({1, 2}, {0, 5}, 4), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({1, 5}, {0, 2}, 4), LibsemigroupsException); + + REQUIRE_THROWS_AS(to>({1, 1}, {0, 2}, 3), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({0, 2}, {1, 1}, 3), LibsemigroupsException); + + REQUIRE_THROWS_AS(to>({1, 2}), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({1, 2}), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({1, 0, 3}), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({1, 0, 3, 6, 4}), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({1, 5, 0, 3, 2}), LibsemigroupsException); + auto x = to>({0, 2}, {3, 0}, 5); REQUIRE(image(x) == std::vector({0, 3})); REQUIRE(domain(x) == std::vector({0, 2})); } @@ -278,34 +279,34 @@ namespace libsemigroups { "008", "exceptions (dynamic)", "[quick][perm]") { - REQUIRE_NOTHROW(to_perm({})); - REQUIRE_NOTHROW(to_perm({0})); - REQUIRE_NOTHROW(to_perm({0, 1})); - REQUIRE_NOTHROW(to_perm({1, 0})); - REQUIRE_NOTHROW(to_perm({1, 4, 0, 3, 2})); - - REQUIRE_THROWS_AS(to_perm({1, 2}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_perm({1, 0, 3}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_perm({1, 0, 3, 6, 4}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_perm({1, 5, 0, 3, 2}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_perm({0, 1, 2, 3, 0}), LibsemigroupsException); + REQUIRE_NOTHROW(to>({})); + REQUIRE_NOTHROW(to>({0})); + REQUIRE_NOTHROW(to>({0, 1})); + REQUIRE_NOTHROW(to>({1, 0})); + REQUIRE_NOTHROW(to>({1, 4, 0, 3, 2})); + + REQUIRE_THROWS_AS(to>({1, 2}), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({1, 0, 3}), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({1, 0, 3, 6, 4}), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({1, 5, 0, 3, 2}), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({0, 1, 2, 3, 0}), LibsemigroupsException); } LIBSEMIGROUPS_TEST_CASE("Perm", "009", "exceptions (static)", "[quick][perm]") { - REQUIRE_NOTHROW(to_perm<1>({0})); - REQUIRE_NOTHROW(to_perm<2>({0, 1})); - REQUIRE_NOTHROW(to_perm<2>({1, 0})); - REQUIRE_NOTHROW(to_perm<5>({1, 4, 0, 3, 2})); - - REQUIRE_THROWS_AS(to_perm<1>({1, 2}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_perm<2>({1, 2}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_perm<3>({1, 0, 3}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_perm<5>({1, 0, 3, 6, 4}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_perm<5>({1, 5, 0, 3, 2}), LibsemigroupsException); - REQUIRE_THROWS_AS(to_perm<5>({0, 1, 2, 3, 0}), LibsemigroupsException); + REQUIRE_NOTHROW(to>({0})); + REQUIRE_NOTHROW(to>({0, 1})); + REQUIRE_NOTHROW(to>({1, 0})); + REQUIRE_NOTHROW(to>({1, 4, 0, 3, 2})); + + REQUIRE_THROWS_AS(to>({1, 2}), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({1, 2}), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({1, 0, 3}), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({1, 0, 3, 6, 4}), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({1, 5, 0, 3, 2}), LibsemigroupsException); + REQUIRE_THROWS_AS(to>({0, 1, 2, 3, 0}), LibsemigroupsException); REQUIRE_NOTHROW(PPerm<5>()); }