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 {
int ngens;
std::vector<std::vector<int>> _mults;
std::string name;
Group(const Group &) = default;
explicit Group(int ngens, const std::vector<Rel> &rels = {}, std::string name = "G")
: ngens(ngens), name(std::move(name)) {
explicit Group(int ngens, const std::vector<Rel> &rels = {})
: ngens(ngens) {
_mults.resize(ngens);
for (auto &mult: _mults) {
@@ -47,33 +46,6 @@ namespace tc {
[[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;
};

View File

@@ -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<int> &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.

View File

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

View File

@@ -3,118 +3,72 @@
#include <sstream>
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) {
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<int> &mults = std::vector<int>(dim - 1, 3);
return schlafli(mults, ss.str());
if (dim == 0) return Group(0);
return schlafli(std::vector<int>(dim - 1, 3));
}
Group B(const int dim) {
std::stringstream ss;
ss << "B(" << dim << ")";
std::vector<int> 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<int> 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<int> 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<int> 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);
}
}
}

View File

@@ -8,83 +8,83 @@
int main(int argc, char *argv[]) {
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
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;