From c47c6262c073331b7c6484bef94b47c00a469b86 Mon Sep 17 00:00:00 2001 From: David Allemang Date: Tue, 13 Sep 2022 21:34:30 -0400 Subject: [PATCH] Remove Group::name --- tc/include/tc/group.hpp | 32 +--------------- tc/include/tc/groups.hpp | 6 --- tc/src/core.cpp | 2 +- tc/src/groups.cpp | 80 +++++++++------------------------------- tc/test/tctest.cpp | 68 +++++++++++++++++----------------- 5 files changed, 54 insertions(+), 134 deletions(-) diff --git a/tc/include/tc/group.hpp b/tc/include/tc/group.hpp index 82f9410..bf6992b 100644 --- a/tc/include/tc/group.hpp +++ b/tc/include/tc/group.hpp @@ -9,12 +9,11 @@ namespace tc { struct Group { int ngens; std::vector> _mults; - std::string name; Group(const Group &) = default; - explicit Group(int ngens, const std::vector &rels = {}, std::string name = "G") - : ngens(ngens), name(std::move(name)) { + explicit Group(int ngens, const std::vector &rels = {}) + : ngens(ngens) { _mults.resize(ngens); for (auto &mult: _mults) { @@ -47,33 +46,6 @@ namespace tc { [[nodiscard]] SubGroup subgroup(const std::vector &gens) const; - [[nodiscard]] Group product(const Group &other) const { - std::stringstream ss; - ss << name << "*" << other.name; - - Group g(ngens + other.ngens, rels(), ss.str()); - - for (const auto &rel: other.rels()) { - g.set(rel.shift(ngens)); - } - - return g; - } - - [[nodiscard]] Group power(int p) const { - std::stringstream ss; - ss << name << "^" << p; - - Group g(ngens * p, {}, ss.str()); - for (const auto &rel: rels()) { - for (int off = 0; off < g.ngens; off += ngens) { - g.set(rel.shift(off)); - } - } - - return g; - } - [[nodiscard]] Cosets solve(const std::vector &sub_gens = {}) const; }; diff --git a/tc/include/tc/groups.hpp b/tc/include/tc/groups.hpp index 7a3e421..436469b 100644 --- a/tc/include/tc/groups.hpp +++ b/tc/include/tc/groups.hpp @@ -4,12 +4,6 @@ namespace tc { - /** - * Construct a group from a (simplified) Schlafli Symbol of the form [a, b, ..., c] - * @param mults: The sequence of multiplicites between adjacent generators. - */ - Group schlafli(const std::vector &mults, const std::string &name); - /** * Construct a group from a (simplified) Schlafli Symbol of the form [a, b, ..., c] * @param mults: The sequence of multiplicites between adjacent generators. diff --git a/tc/src/core.cpp b/tc/src/core.cpp index 1f71b90..221fc41 100644 --- a/tc/src/core.cpp +++ b/tc/src/core.cpp @@ -2,6 +2,6 @@ namespace tc { SubGroup Group::subgroup(const std::vector &gens) const { - return SubGroup(*this, gens); + return {*this, gens}; } } diff --git a/tc/src/groups.cpp b/tc/src/groups.cpp index 1cebc12..f327fe0 100644 --- a/tc/src/groups.cpp +++ b/tc/src/groups.cpp @@ -3,118 +3,72 @@ #include namespace tc { - Group schlafli(const std::vector &mults, const std::string &name) { - int ngens = (int) mults.size() + 1; - - Group g(ngens, {}, name); - - for (int i = 0; i < (int) mults.size(); i++) { - g.set(Rel(i, i + 1, mults[i])); - } - - return g; - } - Group schlafli(const std::vector &mults) { - std::stringstream ss; - ss << "["; - if (!mults.empty()) { - for (size_t i = 0; i < mults.size() - 1; ++i) { - ss << mults[i] << ","; - } - ss << mults.back(); + Group res(mults.size() + 1); + for (int i = 0; i < mults.size(); ++i) { + res.set(Rel{i, i + 1, mults[i]}); } - ss << "]"; - - return schlafli(mults, ss.str()); + return res; } namespace group { Group A(const int dim) { - std::stringstream ss; - ss << "A(" << dim << ")"; - - if (dim == 0) - return Group(0, {}, ss.str()); - - const std::vector &mults = std::vector(dim - 1, 3); - - return schlafli(mults, ss.str()); + if (dim == 0) return Group(0); + return schlafli(std::vector(dim - 1, 3)); } Group B(const int dim) { - std::stringstream ss; - ss << "B(" << dim << ")"; - std::vector mults(dim - 1, 3); mults[0] = 4; - return schlafli(mults, ss.str()); + return schlafli(mults); } Group D(const int dim) { - std::stringstream ss; - ss << "D(" << dim << ")"; - std::vector mults(dim - 1, 3); mults[dim - 2] = 2; - Group g = schlafli(mults, ss.str()); - g.set(Rel(1, dim - 1, 3)); + Group g = schlafli(mults); + g.set(Rel{1, dim - 1, 3}); return g; } Group E(const int dim) { - std::stringstream ss; - ss << "E(" << dim << ")"; - std::vector mults(dim - 1, 3); mults[dim - 2] = 2; - Group g = schlafli(mults, ss.str()); - g.set(Rel(2, dim - 1, 3)); + Group g = schlafli(mults); + g.set(Rel{2, dim - 1, 3}); return g; } Group F4() { - return schlafli({3, 4, 3}, "F4"); + return schlafli({3, 4, 3}); } Group G2() { - return schlafli({6}, "G2"); + return schlafli({6}); } Group H(const int dim) { - std::stringstream ss; - ss << "H(" << dim << ")"; - std::vector mults(dim - 1, 3); mults[0] = 5; - return schlafli(mults, ss.str()); + return schlafli(mults); } Group I2(const int n) { - std::stringstream ss; - ss << "I2(" << n << ")"; - - return schlafli({n}, ss.str()); + return schlafli({n}); } Group T(const int n, const int m) { - std::stringstream ss; - ss << "T(" << n << "," << m << ")"; - - return schlafli({n, 2, m}, ss.str()); + return schlafli({n, 2, m}); } Group T(const int n) { - std::stringstream ss; - ss << "T(" << n << ")"; - - return schlafli({n, 2, n}, ss.str()); + return T(n, n); } } } diff --git a/tc/test/tctest.cpp b/tc/test/tctest.cpp index bb0fed6..171e3db 100644 --- a/tc/test/tctest.cpp +++ b/tc/test/tctest.cpp @@ -8,83 +8,83 @@ int main(int argc, char *argv[]) { std::string key = argv[1]; - std::vector> groups; + std::vector> groups; // See the group orders here https://en.wikipedia.org/wiki/Coxeter_group#Properties if (key == "A") { groups = { - {tc::group::A(1), 2}, - {tc::group::A(2), 6}, - {tc::group::A(3), 24}, - {tc::group::A(4), 120}, + {"A(1)", tc::group::A(1), 2}, + {"A(2)", tc::group::A(2), 6}, + {"A(3)", tc::group::A(3), 24}, + {"A(4)", tc::group::A(4), 120}, }; } if (key == "B") { groups = { - {tc::group::B(2), 8}, - {tc::group::B(3), 48}, - {tc::group::B(4), 384}, - {tc::group::B(5), 3840}, - {tc::group::B(6), 46080}, + {"B(2)", tc::group::B(2), 8}, + {"B(3)", tc::group::B(3), 48}, + {"B(4)", tc::group::B(4), 384}, + {"B(5)", tc::group::B(5), 3840}, + {"B(6)", tc::group::B(6), 46080}, }; } if (key == "D") { groups = { - {tc::group::D(2), 4}, - {tc::group::D(3), 24}, - {tc::group::D(4), 192}, - {tc::group::D(5), 1920}, - {tc::group::D(6), 23040}, + {"D(2)", tc::group::D(2), 4}, + {"D(3)", tc::group::D(3), 24}, + {"D(4)", tc::group::D(4), 192}, + {"D(5)", tc::group::D(5), 1920}, + {"D(6)", tc::group::D(6), 23040}, }; } if (key == "E") { groups = { - {tc::group::E(3), 12}, - {tc::group::E(4), 120}, - {tc::group::E(5), 1920}, - {tc::group::E(6), 51840}, + {"E(3)", tc::group::E(3), 12}, + {"E(4)", tc::group::E(4), 120}, + {"E(5)", tc::group::E(5), 1920}, + {"E(6)", tc::group::E(6), 51840}, }; } if (key == "F") { groups = { - {tc::group::F4(), 1152}, + {"F4()", tc::group::F4(), 1152}, }; } if (key == "G") { groups = { - {tc::group::G2(), 12}, + {"G2()", tc::group::G2(), 12}, }; } if (key == "H") { groups = { - {tc::group::H(2), 10}, - {tc::group::H(3), 120}, - {tc::group::H(4), 14400}, + {"H(2)", tc::group::H(2), 10}, + {"H(3)", tc::group::H(3), 120}, + {"H(4)", tc::group::H(4), 14400}, }; } if (key == "I") { groups = { - {tc::group::I2(2), 4}, - {tc::group::I2(3), 6}, - {tc::group::I2(4), 8}, - {tc::group::I2(5), 10}, + {"I2(2)", tc::group::I2(2), 4}, + {"I2(3)", tc::group::I2(3), 6}, + {"I2(4)", tc::group::I2(4), 8}, + {"I2(5)", tc::group::I2(5), 10}, }; } if (key == "T") { groups = { - {tc::group::T(3), 36}, - {tc::group::T(4), 64}, - {tc::group::T(400), 640000}, - {tc::group::T(400, 300), 480000}, + {"T(3)", tc::group::T(3), 36}, + {"T(4)", tc::group::T(4), 64}, + {"T(400)", tc::group::T(400), 640000}, + {"T(400, 300)", tc::group::T(400, 300), 480000}, }; } int status = EXIT_SUCCESS; - for (const auto &[group, expected]: groups) { + for (const auto &[name, group, expected]: groups) { auto cos = group.solve({}); auto actual = cos.size(); - std::cout << group.name << " : " << actual; + std::cout << name << " : " << actual; if (expected != actual) { std::cout << " (Expected " << expected << ")"; status = EXIT_FAILURE;