Remove Group::name

This commit is contained in:
David Allemang
2022-09-13 21:34:30 -04:00
parent f606ea3b4b
commit c47c6262c0
5 changed files with 54 additions and 134 deletions

View File

@@ -9,12 +9,11 @@ namespace tc {
struct Group { struct Group {
int ngens; int ngens;
std::vector<std::vector<int>> _mults; std::vector<std::vector<int>> _mults;
std::string name;
Group(const Group &) = default; Group(const Group &) = default;
explicit Group(int ngens, const std::vector<Rel> &rels = {}, std::string name = "G") explicit Group(int ngens, const std::vector<Rel> &rels = {})
: ngens(ngens), name(std::move(name)) { : ngens(ngens) {
_mults.resize(ngens); _mults.resize(ngens);
for (auto &mult: _mults) { for (auto &mult: _mults) {
@@ -47,33 +46,6 @@ namespace tc {
[[nodiscard]] SubGroup subgroup(const std::vector<int> &gens) const; [[nodiscard]] SubGroup subgroup(const std::vector<int> &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<int> &sub_gens = {}) const; [[nodiscard]] Cosets solve(const std::vector<int> &sub_gens = {}) const;
}; };

View File

@@ -4,12 +4,6 @@
namespace tc { 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<int> &mults, const std::string &name);
/** /**
* Construct a group from a (simplified) Schlafli Symbol of the form [a, b, ..., c] * Construct a group from a (simplified) Schlafli Symbol of the form [a, b, ..., c]
* @param mults: The sequence of multiplicites between adjacent generators. * @param mults: The sequence of multiplicites between adjacent generators.

View File

@@ -2,6 +2,6 @@
namespace tc { namespace tc {
SubGroup Group::subgroup(const std::vector<int> &gens) const { SubGroup Group::subgroup(const std::vector<int> &gens) const {
return SubGroup(*this, gens); return {*this, gens};
} }
} }

View File

@@ -3,118 +3,72 @@
#include <sstream> #include <sstream>
namespace tc { namespace tc {
Group schlafli(const std::vector<int> &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<int> &mults) { Group schlafli(const std::vector<int> &mults) {
std::stringstream ss; Group res(mults.size() + 1);
ss << "["; for (int i = 0; i < mults.size(); ++i) {
if (!mults.empty()) { res.set(Rel{i, i + 1, mults[i]});
for (size_t i = 0; i < mults.size() - 1; ++i) {
ss << mults[i] << ",";
} }
ss << mults.back(); return res;
}
ss << "]";
return schlafli(mults, ss.str());
} }
namespace group { namespace group {
Group A(const int dim) { Group A(const int dim) {
std::stringstream ss; if (dim == 0) return Group(0);
ss << "A(" << dim << ")"; return schlafli(std::vector<int>(dim - 1, 3));
if (dim == 0)
return Group(0, {}, ss.str());
const std::vector<int> &mults = std::vector<int>(dim - 1, 3);
return schlafli(mults, ss.str());
} }
Group B(const int dim) { Group B(const int dim) {
std::stringstream ss;
ss << "B(" << dim << ")";
std::vector<int> mults(dim - 1, 3); std::vector<int> mults(dim - 1, 3);
mults[0] = 4; mults[0] = 4;
return schlafli(mults, ss.str()); return schlafli(mults);
} }
Group D(const int dim) { Group D(const int dim) {
std::stringstream ss;
ss << "D(" << dim << ")";
std::vector<int> mults(dim - 1, 3); std::vector<int> mults(dim - 1, 3);
mults[dim - 2] = 2; mults[dim - 2] = 2;
Group g = schlafli(mults, ss.str()); Group g = schlafli(mults);
g.set(Rel(1, dim - 1, 3)); g.set(Rel{1, dim - 1, 3});
return g; return g;
} }
Group E(const int dim) { Group E(const int dim) {
std::stringstream ss;
ss << "E(" << dim << ")";
std::vector<int> mults(dim - 1, 3); std::vector<int> mults(dim - 1, 3);
mults[dim - 2] = 2; mults[dim - 2] = 2;
Group g = schlafli(mults, ss.str()); Group g = schlafli(mults);
g.set(Rel(2, dim - 1, 3)); g.set(Rel{2, dim - 1, 3});
return g; return g;
} }
Group F4() { Group F4() {
return schlafli({3, 4, 3}, "F4"); return schlafli({3, 4, 3});
} }
Group G2() { Group G2() {
return schlafli({6}, "G2"); return schlafli({6});
} }
Group H(const int dim) { Group H(const int dim) {
std::stringstream ss;
ss << "H(" << dim << ")";
std::vector<int> mults(dim - 1, 3); std::vector<int> mults(dim - 1, 3);
mults[0] = 5; mults[0] = 5;
return schlafli(mults, ss.str()); return schlafli(mults);
} }
Group I2(const int n) { Group I2(const int n) {
std::stringstream ss; return schlafli({n});
ss << "I2(" << n << ")";
return schlafli({n}, ss.str());
} }
Group T(const int n, const int m) { Group T(const int n, const int m) {
std::stringstream ss; return schlafli({n, 2, m});
ss << "T(" << n << "," << m << ")";
return schlafli({n, 2, m}, ss.str());
} }
Group T(const int n) { Group T(const int n) {
std::stringstream ss; return T(n, n);
ss << "T(" << n << ")";
return schlafli({n, 2, n}, ss.str());
} }
} }
} }

View File

@@ -8,83 +8,83 @@
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
std::string key = argv[1]; std::string key = argv[1];
std::vector<std::pair<tc::Group, size_t>> groups; std::vector<std::tuple<std::string, tc::Group, size_t>> groups;
// See the group orders here https://en.wikipedia.org/wiki/Coxeter_group#Properties // See the group orders here https://en.wikipedia.org/wiki/Coxeter_group#Properties
if (key == "A") { if (key == "A") {
groups = { groups = {
{tc::group::A(1), 2}, {"A(1)", tc::group::A(1), 2},
{tc::group::A(2), 6}, {"A(2)", tc::group::A(2), 6},
{tc::group::A(3), 24}, {"A(3)", tc::group::A(3), 24},
{tc::group::A(4), 120}, {"A(4)", tc::group::A(4), 120},
}; };
} }
if (key == "B") { if (key == "B") {
groups = { groups = {
{tc::group::B(2), 8}, {"B(2)", tc::group::B(2), 8},
{tc::group::B(3), 48}, {"B(3)", tc::group::B(3), 48},
{tc::group::B(4), 384}, {"B(4)", tc::group::B(4), 384},
{tc::group::B(5), 3840}, {"B(5)", tc::group::B(5), 3840},
{tc::group::B(6), 46080}, {"B(6)", tc::group::B(6), 46080},
}; };
} }
if (key == "D") { if (key == "D") {
groups = { groups = {
{tc::group::D(2), 4}, {"D(2)", tc::group::D(2), 4},
{tc::group::D(3), 24}, {"D(3)", tc::group::D(3), 24},
{tc::group::D(4), 192}, {"D(4)", tc::group::D(4), 192},
{tc::group::D(5), 1920}, {"D(5)", tc::group::D(5), 1920},
{tc::group::D(6), 23040}, {"D(6)", tc::group::D(6), 23040},
}; };
} }
if (key == "E") { if (key == "E") {
groups = { groups = {
{tc::group::E(3), 12}, {"E(3)", tc::group::E(3), 12},
{tc::group::E(4), 120}, {"E(4)", tc::group::E(4), 120},
{tc::group::E(5), 1920}, {"E(5)", tc::group::E(5), 1920},
{tc::group::E(6), 51840}, {"E(6)", tc::group::E(6), 51840},
}; };
} }
if (key == "F") { if (key == "F") {
groups = { groups = {
{tc::group::F4(), 1152}, {"F4()", tc::group::F4(), 1152},
}; };
} }
if (key == "G") { if (key == "G") {
groups = { groups = {
{tc::group::G2(), 12}, {"G2()", tc::group::G2(), 12},
}; };
} }
if (key == "H") { if (key == "H") {
groups = { groups = {
{tc::group::H(2), 10}, {"H(2)", tc::group::H(2), 10},
{tc::group::H(3), 120}, {"H(3)", tc::group::H(3), 120},
{tc::group::H(4), 14400}, {"H(4)", tc::group::H(4), 14400},
}; };
} }
if (key == "I") { if (key == "I") {
groups = { groups = {
{tc::group::I2(2), 4}, {"I2(2)", tc::group::I2(2), 4},
{tc::group::I2(3), 6}, {"I2(3)", tc::group::I2(3), 6},
{tc::group::I2(4), 8}, {"I2(4)", tc::group::I2(4), 8},
{tc::group::I2(5), 10}, {"I2(5)", tc::group::I2(5), 10},
}; };
} }
if (key == "T") { if (key == "T") {
groups = { groups = {
{tc::group::T(3), 36}, {"T(3)", tc::group::T(3), 36},
{tc::group::T(4), 64}, {"T(4)", tc::group::T(4), 64},
{tc::group::T(400), 640000}, {"T(400)", tc::group::T(400), 640000},
{tc::group::T(400, 300), 480000}, {"T(400, 300)", tc::group::T(400, 300), 480000},
}; };
} }
int status = EXIT_SUCCESS; int status = EXIT_SUCCESS;
for (const auto &[group, expected]: groups) { for (const auto &[name, group, expected]: groups) {
auto cos = group.solve({}); auto cos = group.solve({});
auto actual = cos.size(); auto actual = cos.size();
std::cout << group.name << " : " << actual; std::cout << name << " : " << actual;
if (expected != actual) { if (expected != actual) {
std::cout << " (Expected " << expected << ")"; std::cout << " (Expected " << expected << ")";
status = EXIT_FAILURE; status = EXIT_FAILURE;