add complete named group list

This commit is contained in:
David Allemang
2022-09-23 16:53:59 -04:00
parent 26e0578421
commit c9cad8be8d
4 changed files with 100 additions and 29 deletions

View File

@@ -8,6 +8,8 @@
#include <tc/core.hpp> #include <tc/core.hpp>
#include <tc/groups.hpp> #include <tc/groups.hpp>
#define NAMED(x) #x, x
void bench( void bench(
const std::string &group_expr, const std::string &group_expr,
const std::string &symbol, const std::string &symbol,
@@ -34,36 +36,105 @@ void bench(
fmt::print("{}\n", row); fmt::print("{}\n", row);
} }
template<typename ...T>
tc::Group sch(T ...arg) {
std::vector<int> mults{arg...,};
return tc::schlafli(mults);
}
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
std::vector<std::string> args(argv + 1, argv + argc); std::vector<std::string> args(argv + 1, argv + argc);
fmt::print("{:>24},{:>10},{:>6},{:>9},{:>10}\n", "NAME", "ORDER", "COMPL", "TIME", "COS/S"); fmt::print("{:>24},{:>10},{:>6},{:>9},{:>10}\n", "NAME", "ORDER", "COMPL", "TIME", "COS/S");
bench("H2", "5", {}); // Finite Groups
bench("H3", "5 3", {});
bench("H4", "5 3 3", {});
bench("T100", "100 2 100", {}); // A_n: 3 * `n-1` ; n >= 1
bench("T500", "500 2 500", {}); bench("A_5", "3 * 4", {});
bench("T1000", "1000 2 1000", {}); bench("A_6", "3 * 5", {});
bench("A_7", "3 * 6", {});
bench("A_8", "3 * 7", {});
// B_n: 4 3 * `n-2` ; n >= 2
bench("B_5", "4 3 * 3", {});
bench("B_6", "4 3 * 4", {});
bench("B_7", "4 3 * 5", {});
bench("B_8", "4 3 * 6", {});
// D_n: 3 * [1 1 `n-3`] ; n >= 4
bench("D_5", "3 * [1 1 2]", {});
bench("D_6", "3 * [1 1 3]", {});
bench("D_7", "3 * [1 1 4]", {});
bench("D_8", "3 * [1 1 5]", {});
// E_n: 3 * [1 2 `n-4`] ; n >= 6
bench("E_6", "3 * [1 2 2]", {});
bench("E_7", "3 * [1 2 3]", {});
// bench("E_8", "3 * [1 2 4]", {}); // too big
// H_n: 5 3 * `n-2` ; n >= 2
bench("H_3", "5 3 * 0", {});
bench("H_4", "5 3 * 1", {});
bench("H_5", "5 3 * 2", {});
// grid: `p` `q` ; 2(p+q) > pq
// triangle: `p` `q` `r` ; 1/p + 1/q + 1/r > 1
bench("E6", "3 * [2 2 1]", {}); // Special Finite Groups
bench("E7", "3 * [3 2 1]", {}); bench("F_4", "3 4 3", {});
// bench("E8", "3 * [4 2 1]", {}); // too big bench("G_2", "6", {});
// I_2(p): `p` ; p >= 2
bench("I_2(100)", "100", {});
bench("I_2(1000)", "1000", {});
// "Torus": `p` 2 `q` ; p, q >= 2
bench("T(100)", "100 2 100", {});
bench("T(1000)", "1000 2 1000", {});
bench("B6", "4 3 * 4", {}); // Affine Groups
bench("B7", "4 3 * 5", {});
bench("B8", "4 3 * 6", {}); // ~A_n: {3 * `n+1`}
bench("~A_5", "{3 * 6}", {}, 1000000);
bench("~A3", "{3 * 4}", {}, 5000000); bench("~A_6", "{3 * 7}", {}, 1000000);
bench("~A4", "{3 * 5}", {}, 5000000); bench("~A_7", "{3 * 8}", {}, 1000000);
bench("~I1", "{- * 5}", {}, 5000000); bench("~A_8", "{3 * 9}", {}, 1000000);
// ~B_n: 4 3 * `n-3` 3 * [1 1]
bench("~B_5", "4 3 * 2 3 * [1 1]", {}, 1000000);
bench("~B_6", "4 3 * 3 3 * [1 1]", {}, 1000000);
bench("~B_7", "4 3 * 4 3 * [1 1]", {}, 1000000);
bench("~B_8", "4 3 * 5 3 * [1 1]", {}, 1000000);
// ~B_n: 4 3 * `n-2` 4
bench("~C_5", "4 3 * 3 4", {}, 1000000);
bench("~C_6", "4 3 * 4 4", {}, 1000000);
bench("~C_7", "4 3 * 5 4", {}, 1000000);
bench("~C_8", "4 3 * 6 4", {}, 1000000);
// ~D_n: 3 * [1 1] 3 * `n-4` 3 * [1 1]
bench("~D_5", "3 * [1 1] 3 * 1 3 * [1 1]", {}, 1000000);
bench("~D_6", "3 * [1 1] 3 * 2 3 * [1 1]", {}, 1000000);
bench("~D_7", "3 * [1 1] 3 * 3 3 * [1 1]", {}, 1000000);
bench("~D_8", "3 * [1 1] 3 * 4 3 * [1 1]", {}, 1000000);
// grid: `p` `q` ; 2(p+q) = pq
// triangle: `p` `q` `r` ; 1/p + 1/q + 1/r = 1
// Special Affine Groups
bench("~I_1", "-", {}, 1000000);
bench("~E_6", "3 * [2 2 2]", {}, 1000000);
bench("~E_7", "3 * [1 3 3]", {}, 1000000);
bench("~E_8", "3 * [1 2 5]", {}, 1000000);
// bench("E_9", "3 * [1 2 5]", {}, 1000000); // ~E_8 == E_9
bench("~F_4", "3 4 3 3", {}, 1000000);
bench("~G_2", "6 3", {}, 1000000);
// Hyperbolic Groups
// grid: `p` `q` ; 2(p+q) < pq
// triangle: `p` `q` `r` ; 1/p + 1/q + 1/r < 1
// Special Hyperbolic Groups
bench("-BH_3", "4 3 5", {}, 1000000);
bench("-K_3", "5 3 5", {}, 1000000);
bench("-J_3", "3 5 3", {}, 1000000);
// bench("~H_3", "3 5 3", {}, 1000000); // -J_3 == ~H_3
bench("-DH_3", "5 3 * [1 1]", {}, 1000000);
bench("^AB_3", "{3 3 3 4}", {}, 1000000);
bench("^AH_3", "{3 3 3 5}", {}, 1000000);
bench("^BB_3", "{3 4 3 4}", {}, 1000000);
bench("^BH_3", "{3 4 3 5}", {}, 1000000);
bench("^HH_3", "{3 5 3 5}", {}, 1000000);
bench("-H_4", "5 3 3 3", {}, 1000000);
// bench("~H_4", "5 3 3 3", {}, 1000000); // -H_4 == ~H_4 == H_5
// bench("H_5", "5 3 3 3", {}, 1000000);
bench("-BH_4", "4 3 3 5", {}, 1000000);
bench("-K_4", "5 3 3 5", {}, 1000000);
bench("-DH_4", "5 3 3 * [1 1]", {}, 1000000);
bench("^AF_4", "{3 3 3 3 4}", {}, 1000000);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@@ -9,15 +9,15 @@ namespace tc {
* 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.
*/ */
Group schlafli(const std::vector<int> &mults); Group schlafli(const std::vector<unsigned int> &mults);
Group coxeter(const std::string &symbol); Group coxeter(const std::string &symbol);
Group vcoxeter(const std::string &symbol, std::vector<int> &values); Group vcoxeter(const std::string &symbol, std::vector<unsigned int> &values);
template<typename ...Args> template<typename ...Args>
Group coxeter(const std::string &symbol, const Args &... args) { Group coxeter(const std::string &symbol, const Args &... args) {
std::vector<int> values = {{args...}}; std::vector<unsigned int> values = {{args...}};
return vcoxeter(symbol, values); return vcoxeter(symbol, values);
} }
} }

View File

@@ -4,15 +4,15 @@
#include <fmt/core.h> #include <fmt/core.h>
namespace tc { namespace tc {
Group schlafli(const std::vector<int> &mults) { Group schlafli(const std::vector<unsigned int> &mults) {
Group res(mults.size() + 1); Group res(mults.size() + 1);
for (int i = 0; i < mults.size(); ++i) { for (size_t i = 0; i < mults.size(); ++i) {
res.set(Rel{i, i + 1, mults[i]}); res.set(Rel{i, i + 1, mults[i]});
} }
return res; return res;
} }
Group v_coxeter(const std::string &symbol, std::vector<int> &values) { Group vcoxeter(const std::string &symbol, std::vector<unsigned int> &values) {
fmt::dynamic_format_arg_store<fmt::format_context> ds; fmt::dynamic_format_arg_store<fmt::format_context> ds;
for (const auto &value: values) { for (const auto &value: values) {

View File

@@ -211,7 +211,7 @@ std::vector<Op> compile(const std::string &source) {
std::shared_ptr<peg::Ast> ast; std::shared_ptr<peg::Ast> ast;
bool ast_ok = ast_parser.parse(source, ast); bool ast_ok = ast_parser.parse(source, ast);
assert(ast_ok); assert(ast_ok);
std::cout << peg::ast_to_s(ast) << std::endl; // std::cout << peg::ast_to_s(ast) << std::endl;
#endif #endif
static peg::parser parser = build_parser(); static peg::parser parser = build_parser();