diff --git a/include/vect16.hpp b/include/vect16.hpp index cfc54f26..ff72a4c9 100644 --- a/include/vect16.hpp +++ b/include/vect16.hpp @@ -24,7 +24,7 @@ namespace HPCombi { struct alignas(16) Vect16 { - static constexpr size_t Size() { return 16; } + static constexpr size_t size() { return 16; } using array = decltype(Epu8)::array; epu8 v; @@ -46,23 +46,23 @@ struct alignas(16) Vect16 { const uint8_t &operator[](uint64_t i) const { return as_array()[i]; } uint8_t &operator[](uint64_t i) { return as_array()[i]; } - size_t first_diff(const Vect16 &u, size_t bound = Size()) const { + size_t first_diff(const Vect16 &u, size_t bound = size()) const { return HPCombi::first_diff(v, u.v, bound); } - size_t last_diff(const Vect16 &u, size_t bound = Size()) const { + size_t last_diff(const Vect16 &u, size_t bound = size()) const { return HPCombi::last_diff(v, u.v, bound); } - size_t first_zero(size_t bound = Size()) const { + size_t first_zero(size_t bound = size()) const { return HPCombi::first_zero(v, bound); } - size_t last_zero(size_t bound = Size()) const { + size_t last_zero(size_t bound = size()) const { return HPCombi::last_zero(v, bound); } - size_t first_non_zero(size_t bound = Size()) const { + size_t first_non_zero(size_t bound = size()) const { return HPCombi::first_non_zero(v, bound); } - size_t last_non_zero(size_t bound = Size()) const { + size_t last_non_zero(size_t bound = size()) const { return HPCombi::last_non_zero(v, bound); } diff --git a/include/vect_generic.hpp b/include/vect_generic.hpp index e7806ad6..40d6309a 100644 --- a/include/vect_generic.hpp +++ b/include/vect_generic.hpp @@ -35,7 +35,7 @@ std::array sorted_vect(std::array v) { /** A generic class for combinatorial integer vectors. */ template struct VectGeneric { - static constexpr size_t Size() { return _Size; } + static constexpr size_t size() { return _Size; } using array = std::array; array v; diff --git a/tests/test_perm_all.cpp b/tests/test_perm_all.cpp index ab8be3ae..3264ed4b 100644 --- a/tests/test_perm_all.cpp +++ b/tests/test_perm_all.cpp @@ -48,7 +48,7 @@ template struct Fixture1 { const std::vector Vlist; // some tests assume that the size is at least 6 - static_assert(VectType::Size() >= 6, "Minimum size for tests"); + static_assert(VectType::size() >= 6, "Minimum size for tests"); }; } // namespace @@ -61,8 +61,8 @@ template struct Fixture1 { TEMPLATE_TEST_CASE_METHOD(Fixture1, "sizeof", "[PermAll][000]", PermTypes) { CHECK(sizeof(Fixture1::zero) == - Fixture1::VectType::Size() * - sizeof(Fixture1::zero[0])); + Fixture1::VectType::size() * + sizeof(Fixture1::zero[0])); } TEMPLATE_TEST_CASE_METHOD(Fixture1, "operator==", "[PermAll][001]", PermTypes) { @@ -72,10 +72,10 @@ TEMPLATE_TEST_CASE_METHOD(Fixture1, "operator==", "[PermAll][001]", PermTypes) { for (unsigned j = 0; j < Fixture1::Plist.size(); j++) { if (i == j) { CHECK(Fixture1::Plist[i] == - Fixture1::Plist[j]); + Fixture1::Plist[j]); } else { CHECK(Fixture1::Plist[i] != - Fixture1::Plist[j]); + Fixture1::Plist[j]); } } } @@ -85,10 +85,10 @@ TEMPLATE_TEST_CASE_METHOD(Fixture1, "operator[] const", "[PermAll][002]", PermTypes) { CHECK(Fixture1::czero[0] == 0u); CHECK(Fixture1::czero[1] == 0u); - if (Fixture1::czero.Size() > 12) { + if (Fixture1::czero.size() > 12) { CHECK(Fixture1::czero[12] == 0u); } - if (Fixture1::czero.Size() > 15) { + if (Fixture1::czero.size() > 15) { CHECK(Fixture1::czero[15] == 0u); } CHECK(Fixture1::cV01[0] == 0u); @@ -99,10 +99,10 @@ TEMPLATE_TEST_CASE_METHOD(Fixture1, "operator[] const", "[PermAll][002]", TEMPLATE_TEST_CASE_METHOD(Fixture1, "operator[]", "[PermAll][003]", PermTypes) { CHECK(Fixture1::zero[0] == 0u); CHECK(Fixture1::zero[1] == 0u); - if (Fixture1::czero.Size() > 12) { + if (Fixture1::czero.size() > 12) { CHECK(Fixture1::zero[12] == 0u); } - if (Fixture1::czero.Size() > 15) { + if (Fixture1::czero.size() > 15) { CHECK(Fixture1::zero[15] == 0u); } CHECK(Fixture1::V01[0] == 0u); @@ -113,10 +113,10 @@ TEMPLATE_TEST_CASE_METHOD(Fixture1, "operator[]", "[PermAll][003]", PermTypes) { Fixture1::zero[0] = 3; CHECK(Fixture1::zero[0] == 3u); CHECK(Fixture1::zero[1] == 0u); - if (Fixture1::czero.Size() > 12) { + if (Fixture1::czero.size() > 12) { CHECK(Fixture1::zero[12] == 0u); } - if (Fixture1::czero.Size() > 15) { + if (Fixture1::czero.size() > 15) { CHECK(Fixture1::zero[15] == 0u); } Fixture1::PPa[2] = 0; @@ -130,10 +130,10 @@ TEMPLATE_TEST_CASE_METHOD(Fixture1, "operator<", "[AllPerm][004]", PermTypes) { for (unsigned j = 0; j < Fixture1::Plist.size(); j++) { if (i < j) { CHECK(Fixture1::Plist[i] < - Fixture1::Plist[j]); + Fixture1::Plist[j]); } else { CHECK(!(Fixture1::Plist[i] < - Fixture1::Plist[j])); + Fixture1::Plist[j])); } } } @@ -153,37 +153,33 @@ TEMPLATE_TEST_CASE_METHOD(Fixture1, "less_partial", "[AllPerm][005]", } CHECK(Fixture1::zero.less_partial(Fixture1::V01, 1) == - 0); + 0); CHECK(Fixture1::V01.less_partial(Fixture1::zero, 1) == - 0); + 0); CHECK(Fixture1::zero.less_partial(Fixture1::V01, 2) < - 0); + 0); CHECK(Fixture1::V01.less_partial(Fixture1::zero, 2) > - 0); + 0); CHECK(Fixture1::zero.less_partial(Fixture1::V10, 1) < - 0); + 0); CHECK(Fixture1::zero.less_partial(Fixture1::V10, 2) < - 0); + 0); CHECK(Fixture1::V10.less_partial(Fixture1::zero, 1) > - 0); + 0); CHECK(Fixture1::V10.less_partial(Fixture1::zero, 2) > - 0); + 0); CHECK(Fixture1::PPa.less_partial(Fixture1::PPb, 1) == - 0); + 0); CHECK(Fixture1::PPa.less_partial(Fixture1::PPb, 2) == - 0); + 0); CHECK(Fixture1::PPa.less_partial(Fixture1::PPb, 3) == - 0); - CHECK(Fixture1::PPa.less_partial(Fixture1::PPb, 4) < - 0); - CHECK(Fixture1::PPa.less_partial(Fixture1::PPb, 5) < - 0); - CHECK(Fixture1::PPb.less_partial(Fixture1::PPa, 4) > - 0); - CHECK(Fixture1::PPb.less_partial(Fixture1::PPa, 5) > - 0); + 0); + CHECK(Fixture1::PPa.less_partial(Fixture1::PPb, 4) < 0); + CHECK(Fixture1::PPa.less_partial(Fixture1::PPb, 5) < 0); + CHECK(Fixture1::PPb.less_partial(Fixture1::PPa, 4) > 0); + CHECK(Fixture1::PPb.less_partial(Fixture1::PPa, 5) > 0); } TEMPLATE_TEST_CASE_METHOD(Fixture1, "first_zero", "[AllPerm][006]", PermTypes) { @@ -192,39 +188,39 @@ TEMPLATE_TEST_CASE_METHOD(Fixture1, "first_zero", "[AllPerm][006]", PermTypes) { CHECK(Fixture1::PPa.first_zero() == 4u); CHECK(Fixture1::V10.first_zero() == 1u); CHECK(Fixture1::V1.first_zero() == - Fixture1::VectType::Size()); + Fixture1::VectType::size()); CHECK(Fixture1::V10.first_zero(1) == - Fixture1::VectType::Size()); + Fixture1::VectType::size()); CHECK(Fixture1::PPa.first_zero(5) == 4u); CHECK(Fixture1::PPa.first_zero(3) == - Fixture1::VectType::Size()); + Fixture1::VectType::size()); } TEMPLATE_TEST_CASE_METHOD(Fixture1, "last_zero", "[AllPerm][007]", PermTypes) { CHECK(Fixture1::zero.last_zero() == - Fixture1::VectType::Size() - 1); + Fixture1::VectType::size() - 1); CHECK(Fixture1::V01.last_zero() == - Fixture1::VectType::Size() - 1); + Fixture1::VectType::size() - 1); CHECK(Fixture1::PPa.last_zero() == 4u); CHECK(Fixture1::V1.last_zero() == - Fixture1::VectType::Size()); + Fixture1::VectType::size()); CHECK(Fixture1::V01.last_zero(1) == 0u); CHECK(Fixture1::V10.last_zero(1) == - Fixture1::VectType::Size()); + Fixture1::VectType::size()); CHECK(Fixture1::PPa.last_zero(5) == 4u); CHECK(Fixture1::PPa.last_zero(3) == - Fixture1::VectType::Size()); + Fixture1::VectType::size()); } TEMPLATE_TEST_CASE_METHOD(Fixture1, "first_non_zero", "[AllPerm][008]", PermTypes) { CHECK(Fixture1::zero.first_non_zero() == - Fixture1::VectType::Size()); + Fixture1::VectType::size()); CHECK(Fixture1::V01.first_non_zero() == 1u); CHECK(Fixture1::PPa.first_non_zero() == 0u); CHECK(Fixture1::V01.first_non_zero() == 1u); CHECK(Fixture1::V01.first_non_zero(1) == - Fixture1::VectType::Size()); + Fixture1::VectType::size()); CHECK(Fixture1::PPa.first_non_zero(5) == 0u); CHECK(Fixture1::PPa.first_non_zero(3) == 0u); } @@ -232,28 +228,28 @@ TEMPLATE_TEST_CASE_METHOD(Fixture1, "first_non_zero", "[AllPerm][008]", TEMPLATE_TEST_CASE_METHOD(Fixture1, "last_non_zero", "[AllPerm][009]", PermTypes) { CHECK(Fixture1::zero.last_non_zero() == - Fixture1::VectType::Size()); + Fixture1::VectType::size()); CHECK(Fixture1::V01.last_non_zero() == 1u); CHECK(Fixture1::PPa.last_non_zero() == - Fixture1::VectType::Size() - 1); + Fixture1::VectType::size() - 1); CHECK(Fixture1::V01.last_non_zero() == 1u); CHECK(Fixture1::V01.last_non_zero(1) == - Fixture1::VectType::Size()); + Fixture1::VectType::size()); CHECK(Fixture1::PPa.last_non_zero(5) == 3u); CHECK(Fixture1::PPa.last_non_zero(3) == 2u); } TEMPLATE_TEST_CASE_METHOD(Fixture1, "permuted", "[AllPerm][010]", PermTypes) { CHECK(Fixture1::zero.permuted(Fixture1::zero) == - Fixture1::zero); + Fixture1::zero); CHECK(Fixture1::V01.permuted(Fixture1::V01) == - Fixture1::V01); + Fixture1::V01); CHECK(Fixture1::V10.permuted(Fixture1::V10) == - typename Fixture1::VectType({0, 1}, 1)); + typename Fixture1::VectType({0, 1}, 1)); CHECK(Fixture1::V10.permuted(Fixture1::V01) == - typename Fixture1::VectType({1, 0}, 1)); + typename Fixture1::VectType({1, 0}, 1)); CHECK(Fixture1::V01.permuted(Fixture1::V10) == - Fixture1::V10); + Fixture1::V10); } TEMPLATE_TEST_CASE_METHOD(Fixture1, "operator_insert", "[AllPerm][011]", @@ -261,7 +257,7 @@ TEMPLATE_TEST_CASE_METHOD(Fixture1, "operator_insert", "[AllPerm][011]", std::ostringstream out, out2; out << Fixture1::zero; out2 << "{ 0"; - for (size_t i = 1; i < Fixture1::VectType::Size(); i++) + for (size_t i = 1; i < Fixture1::VectType::size(); i++) out2 << ", 0"; out2 << "}"; CHECK(out.str() == out2.str()); @@ -270,7 +266,7 @@ TEMPLATE_TEST_CASE_METHOD(Fixture1, "operator_insert", "[AllPerm][011]", out2.str(""); out << Fixture1::V01; out2 << "{ 0, 1"; - for (size_t i = 2; i < Fixture1::VectType::Size(); i++) + for (size_t i = 2; i < Fixture1::VectType::size(); i++) out2 << ", 0"; out2 << "}"; CHECK(out.str() == out2.str()); @@ -279,7 +275,7 @@ TEMPLATE_TEST_CASE_METHOD(Fixture1, "operator_insert", "[AllPerm][011]", out2.str(""); out << Fixture1::PPa; out2 << "{ 1, 2, 3, 4, 0"; - for (size_t i = 5; i < Fixture1::VectType::Size(); i++) + for (size_t i = 5; i < Fixture1::VectType::size(); i++) out2 << "," << std::setw(2) << i; out2 << "}"; CHECK(out.str() == out2.str()); @@ -292,8 +288,8 @@ TEMPLATE_TEST_CASE_METHOD(Fixture1, "is_permutation", "[AllPerm][012]", CHECK(!Fixture1::PPb.is_permutation()); CHECK(Fixture1::RandPerm.is_permutation()); CHECK(!typename Fixture1::VectType( - {3, 1, 0, 9, 3, 10, 2, 11, 6, 7, 4, 8}) - .is_permutation()); + {3, 1, 0, 9, 3, 10, 2, 11, 6, 7, 4, 8}) + .is_permutation()); CHECK(Fixture1::PPa.is_permutation(16)); CHECK(!Fixture1::RandPerm.is_permutation(4)); CHECK(Fixture1::PPa.is_permutation(5)); @@ -346,7 +342,7 @@ TEMPLATE_TEST_CASE_METHOD(Fixture2, "std::hash", "[AllPerm][014]", PermTypes) { TEMPLATE_TEST_CASE_METHOD(Fixture2, "mult_coxeter", "[AllPerm][015]", PermTypes) { - const size_t n = TestType::Size() - 1; + const size_t n = TestType::size() - 1; for (uint64_t i = 0; i < n; i++) { auto si = TestType::elementary_transposition(i); @@ -369,7 +365,7 @@ TEMPLATE_TEST_CASE_METHOD(Fixture2, "mult", "[AllPerm][016]", PermTypes) { CHECK(x * Fixture2::id == x); } CHECK(Fixture2::RandPerm * Fixture2::RandPerm == - TestType({5, 1, 3, 2, 8, 0, 9, 11, 6, 10, 7, 4})); + TestType({5, 1, 3, 2, 8, 0, 9, 11, 6, 10, 7, 4})); for (auto x : Fixture2::Plist) { for (auto y : Fixture2::Plist) {