mirror of
https://github.com/allemangD/toddcox-visualize.git
synced 2026-01-24 14:39:21 -05:00
ENH: Remove template Group<> and Cosets<>
This commit is contained in:
@@ -1,54 +1,54 @@
|
||||
#include <tc/core.hpp>
|
||||
|
||||
namespace tc {
|
||||
Cosets<>::Cosets(size_t rank)
|
||||
Cosets::Cosets(size_t rank)
|
||||
: _rank(rank), _order(0), _complete(false), _data() {}
|
||||
|
||||
void Cosets<>::set(size_t coset, size_t gen, size_t target) {
|
||||
void Cosets::set(size_t coset, size_t gen, size_t target) {
|
||||
set(coset * rank() + gen, target);
|
||||
}
|
||||
|
||||
[[nodiscard]] size_t Cosets<>::get(size_t coset, size_t gen) const {
|
||||
[[nodiscard]] size_t Cosets::get(size_t coset, size_t gen) const {
|
||||
return get(coset * rank() + gen);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool Cosets<>::isset(size_t coset, size_t gen) const {
|
||||
[[nodiscard]] bool Cosets::isset(size_t coset, size_t gen) const {
|
||||
return isset(coset * rank() + gen);
|
||||
}
|
||||
|
||||
[[nodiscard]] size_t Cosets<>::rank() const {
|
||||
[[nodiscard]] size_t Cosets::rank() const {
|
||||
return _rank;
|
||||
}
|
||||
|
||||
[[nodiscard]] size_t Cosets<>::order() const {
|
||||
[[nodiscard]] size_t Cosets::order() const {
|
||||
return _order;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool Cosets<>::complete() const {
|
||||
[[nodiscard]] bool Cosets::complete() const {
|
||||
return _complete;
|
||||
}
|
||||
|
||||
[[nodiscard]] size_t Cosets<>::size() const {
|
||||
[[nodiscard]] size_t Cosets::size() const {
|
||||
return _data.size();
|
||||
}
|
||||
|
||||
void Cosets<>::add_row() {
|
||||
void Cosets::add_row() {
|
||||
_data.resize(_data.size() + rank(), UNSET);
|
||||
_order++;
|
||||
}
|
||||
|
||||
void Cosets<>::set(size_t idx, size_t target) {
|
||||
void Cosets::set(size_t idx, size_t target) {
|
||||
size_t coset = idx / rank();
|
||||
size_t gen = idx % rank();
|
||||
_data[idx] = target;
|
||||
_data[target * rank() + gen] = coset;
|
||||
}
|
||||
|
||||
[[nodiscard]] size_t Cosets<>::get(size_t idx) const {
|
||||
[[nodiscard]] size_t Cosets::get(size_t idx) const {
|
||||
return _data[idx];
|
||||
}
|
||||
|
||||
[[nodiscard]] bool Cosets<>::isset(size_t idx) const {
|
||||
[[nodiscard]] bool Cosets::isset(size_t idx) const {
|
||||
return get(idx) != UNSET;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
#include <cassert>
|
||||
|
||||
namespace tc {
|
||||
Group<>::Group(size_t rank) : _rank(rank), _mults(_rank * _rank, 2) {
|
||||
Group::Group(size_t rank) : _rank(rank), _mults(_rank * _rank, 2) {
|
||||
for (int idx = 0; idx < rank; ++idx) {
|
||||
set(idx, idx, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void Group<>::set(size_t u, size_t v, Mult m) {
|
||||
void Group::set(size_t u, size_t v, Mult m) {
|
||||
assert(u < rank());
|
||||
assert(v < rank());
|
||||
|
||||
@@ -17,19 +17,19 @@ namespace tc {
|
||||
_mults[v * rank() + u] = m;
|
||||
}
|
||||
|
||||
[[nodiscard]] Mult Group<>::get(size_t u, size_t v) const {
|
||||
[[nodiscard]] Mult Group::get(size_t u, size_t v) const {
|
||||
assert(u < rank());
|
||||
assert(v < rank());
|
||||
|
||||
return _mults[u * rank() + v];
|
||||
}
|
||||
|
||||
[[nodiscard]] size_t Group<>::rank() const {
|
||||
[[nodiscard]] size_t Group::rank() const {
|
||||
return _rank;
|
||||
}
|
||||
|
||||
[[nodiscard]] Group<> Group<>::sub(std::vector<size_t> const &idxs) const {
|
||||
Group<> res(idxs.size());
|
||||
[[nodiscard]] Group Group::sub(std::vector<size_t> const &idxs) const {
|
||||
Group res(idxs.size());
|
||||
|
||||
for (int i = 0; i < idxs.size(); ++i) {
|
||||
for (int j = i; j < idxs.size(); ++j) {
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
#include <numeric>
|
||||
|
||||
namespace tc {
|
||||
Group<> schlafli(const std::vector<unsigned int> &mults) {
|
||||
Group<> res(mults.size() + 1);
|
||||
Group schlafli(const std::vector<unsigned int> &mults) {
|
||||
Group res(mults.size() + 1);
|
||||
for (size_t i = 0; i < mults.size(); ++i) {
|
||||
res.set(i, i + 1, mults[i]);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
Group<> vcoxeter(const std::string &symbol, const std::vector<unsigned int> &values) {
|
||||
Group vcoxeter(const std::string &symbol, const std::vector<unsigned int> &values) {
|
||||
fmt::dynamic_format_arg_store<fmt::format_context> ds;
|
||||
|
||||
for (const auto &value: values) {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
struct Graph {
|
||||
size_t rank{};
|
||||
std::vector<tc::Group<>::Rel> edges{};
|
||||
std::vector<tc::Group::Rel> edges{};
|
||||
};
|
||||
|
||||
struct Op {
|
||||
@@ -287,10 +287,10 @@ Graph eval(const std::vector<Op> &ops) {
|
||||
}
|
||||
|
||||
namespace tc {
|
||||
Group<> coxeter(const std::string &symbol) {
|
||||
Group coxeter(const std::string &symbol) {
|
||||
auto ops = compile(symbol);
|
||||
auto diagram = eval(ops);
|
||||
Group<> res(diagram.rank);
|
||||
Group res(diagram.rank);
|
||||
for (const auto &[i, j, m]: diagram.edges) {
|
||||
res.set(i, j, m);
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@ namespace tc {
|
||||
};
|
||||
|
||||
struct Tables {
|
||||
std::vector<Group<>::Rel> rels;
|
||||
std::vector<Group::Rel> rels;
|
||||
std::vector<std::vector<Row>> rows;
|
||||
|
||||
explicit Tables(std::vector<Group<>::Rel> rels)
|
||||
explicit Tables(std::vector<Group::Rel> rels)
|
||||
: rels(std::move(rels)), rows() {
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ namespace tc {
|
||||
}
|
||||
};
|
||||
|
||||
[[nodiscard]] Cosets<> Group<>::solve(std::vector<size_t> const &idxs, size_t bound) const {
|
||||
[[nodiscard]] Cosets Group::solve(std::vector<size_t> const &idxs, size_t bound) const {
|
||||
// region Initialize Cosets Table
|
||||
Cosets<> cosets(rank());
|
||||
Cosets cosets(rank());
|
||||
cosets.add_row();
|
||||
|
||||
if (rank() == 0) {
|
||||
@@ -53,7 +53,7 @@ namespace tc {
|
||||
// endregion
|
||||
|
||||
// region Initialize Relation Tables
|
||||
std::vector<Group<>::Rel> rels;
|
||||
std::vector<Group::Rel> rels;
|
||||
for (int i = 0; i < rank(); ++i) {
|
||||
for (int j = i + 1; j < rank(); ++j) {
|
||||
// The algorithm only works for Coxeter groups; multiplicities m_ii=1 are assumed. Relation tables
|
||||
|
||||
Reference in New Issue
Block a user