// // libsemigroups - C++ library for semigroups and monoids // Copyright (C) 2020 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. //
#include <algorithm> // for uniform_int_distribution #include <cstddef> // for size_t #include <iostream> // for std::cout
#include"bench-main.hpp"// for CATCH_CONFIG_ENABLE_BENCHMARKING #include"catch.hpp"// for BENCHMARK, REQUIRE, TEST_CASE
#include"libsemigroups/digraph.hpp"// for ActionDigraph #include"libsemigroups/types.hpp"// for word_type
namespace libsemigroups { // Old function for comparison with iterators template <typename T> using node_type = typename ActionDigraph<T>::node_type;
template <typename T> using label_type = typename ActionDigraph<T>::label_type;
template <typename T, typename S>
std::pair<std::vector<word_type>, std::vector<node_type<T>>>
paths_in_lex_order(ActionDigraph<T> const& ad,
S const root,
size_t min = 0,
size_t max = libsemigroups::POSITIVE_INFINITY) { using node_type = node_type<T>; using label_type = label_type<T>;
template <typename T, typename S>
std::vector<word_type>
paths_in_lex_order2(ActionDigraph<T> const& ad,
S const first,
S const last,
size_t min = 0,
size_t max = libsemigroups::POSITIVE_INFINITY) { using node_type = node_type<T>; using label_type = label_type<T>;
BENCHMARK("free function for comparison with const_panilo_iterator") {
std::pair<std::vector<word_type>, std::vector<node_type>> v
= paths_in_lex_order(ad, 0, 0, N);
REQUIRE(v.first.size() == 1048575);
};
}
TEST_CASE("const_pilo_iterator", "[quick][001]") { using node_type = size_t; auto ad = test_digraph();
size_t N = 20;
BENCHMARK("free function for comparison with const_pilo_iterator") {
std::pair<std::vector<word_type>, std::vector<node_type>> v
= paths_in_lex_order(ad, 0, 0, N);
REQUIRE(v.first.size() == 1048575);
};
}
TEST_CASE("const_pstilo_iterator", "[quick][002]") { auto ad = test_digraph();
size_t N = 20;
BENCHMARK("free function for comparison with const_pstilo_iterator") {
std::vector<word_type> v = paths_in_lex_order2(ad, 0, 4, 0, N);
REQUIRE(v.size() == 524277);
};
}
TEST_CASE("number_of_paths", "[quick][003]") { using node_type = size_t; auto ad = test_digraph();
BENCHMARK("number_of_paths (uses pstilo)") {
REQUIRE(ad.number_of_paths(0, 4, 0, 24) == 8388595);
};
BENCHMARK("free function for comparison with const_panislo_iterator") {
std::pair<std::vector<word_type>, std::vector<node_type>> v
= paths_in_shortlex_order(ad, 0, 0, N);
REQUIRE(v.first.size() == 1048575);
};
BENCHMARK( "const_panilo_iterator for comparison with const_panislo_iterator") {
std::vector<std::pair<word_type, node_type>> v(ad.cbegin_panilo(0, 0, N),
ad.cend_panilo());
REQUIRE(v.size() == 1048575);
};
}
TEST_CASE("const_pislo_iterator", "[quick][005]") { using node_type = size_t; auto ad = test_digraph();
size_t N = 20;
BENCHMARK("free function for comparison with const_pislo_iterator") {
std::pair<std::vector<word_type>, std::vector<node_type>> v
= paths_in_shortlex_order(ad, 0, 0, N);
REQUIRE(v.first.size() == 1048575);
};
BENCHMARK("const_pilo_iterator for comparison with const_pislo_iterator") {
std::vector<word_type> v(ad.cbegin_pilo(0, 0, N), ad.cend_pilo());
REQUIRE(v.size() == 1048575);
};
}
TEST_CASE("const_pstislo_iterator", "[quick][006]") { auto ad = test_digraph();
size_t N = 20;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.