mirror of
https://github.com/allemangD/toddcox-visualize.git
synced 2025-11-10 12:02:47 -05:00
correctly type Cosets methods
This commit is contained in:
@@ -10,5 +10,5 @@
|
|||||||
#include "group.hpp"
|
#include "group.hpp"
|
||||||
|
|
||||||
namespace tc {
|
namespace tc {
|
||||||
Cosets solve(const Group &group, const std::vector<Coset> &sub_gens);
|
Cosets solve(const Group &group, const std::vector<Gen> &sub_gens);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,55 +6,67 @@
|
|||||||
|
|
||||||
namespace tc {
|
namespace tc {
|
||||||
using Coset = uint32_t;
|
using Coset = uint32_t;
|
||||||
using Gen = uint16_t;
|
using Gen = uint8_t;
|
||||||
using Mult = uint16_t;
|
using Mult = uint16_t;
|
||||||
|
|
||||||
using Rel = std::tuple<Gen, Gen, Mult>;
|
using Rel = std::tuple<Gen, Gen, Mult>;
|
||||||
|
|
||||||
struct Cosets {
|
struct Cosets {
|
||||||
int ngens;
|
const Coset UNSET = Coset(-1);
|
||||||
|
|
||||||
|
Gen ngens;
|
||||||
std::vector<int> data;
|
std::vector<int> data;
|
||||||
Path path;
|
Path path;
|
||||||
|
|
||||||
Cosets(const Cosets &) = default;
|
Cosets(const Cosets &) = default;
|
||||||
|
|
||||||
explicit Cosets(int ngens)
|
explicit Cosets(Gen ngens)
|
||||||
: ngens(ngens) {
|
: ngens(ngens) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_row() {
|
void add_row() {
|
||||||
data.resize(data.size() + ngens, -1);
|
data.resize(data.size() + ngens, UNSET);
|
||||||
path.add_row();
|
path.add_row();
|
||||||
}
|
}
|
||||||
|
|
||||||
void put(int coset, int gen, int target) {
|
void put(Coset coset, Gen gen, Coset target) {
|
||||||
data[coset * ngens + gen] = target;
|
data[coset * ngens + gen] = target;
|
||||||
data[target * ngens + gen] = coset;
|
data[target * ngens + gen] = coset;
|
||||||
|
|
||||||
if (path.get(target).from_idx == -1) {
|
if (path.get(target).from_idx == UNSET) {
|
||||||
path.put(coset, gen, target);
|
path.put(coset, gen, target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void put(int idx, int target) {
|
void put(size_t idx, Coset target) {
|
||||||
int coset = idx / ngens;
|
Coset coset = idx / ngens;
|
||||||
int gen = idx % ngens;
|
Gen gen = idx % ngens;
|
||||||
|
|
||||||
data[idx] = target;
|
data[idx] = target;
|
||||||
data[target * ngens + gen] = coset;
|
data[target * ngens + gen] = coset;
|
||||||
|
|
||||||
if (path.get(target).from_idx == -1) {
|
if (path.get(target).from_idx == UNSET) {
|
||||||
path.put(coset, gen, target);
|
path.put(coset, gen, target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] int get(int coset, int gen) const {
|
[[nodiscard]] Coset get(Coset coset, Gen gen) const {
|
||||||
return data[coset * ngens + gen];
|
return data[coset * ngens + gen];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] int get(int idx) const {
|
[[nodiscard]] Coset get(size_t idx) const {
|
||||||
return data[idx];
|
return data[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool isset(Coset coset, Gen gen) const {
|
||||||
|
return get(coset, gen) != UNSET;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool isset(size_t idx) const {
|
||||||
|
return get(idx) != UNSET;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] size_t size() const {
|
[[nodiscard]] size_t size() const {
|
||||||
return path.size();
|
return path.size();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace tc {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Cosets solve(const Group &group, const std::vector<Coset> &sub_gens) {
|
Cosets solve(const Group &group, const std::vector<Gen> &sub_gens) {
|
||||||
auto ngens = group.ngens;
|
auto ngens = group.ngens;
|
||||||
|
|
||||||
// region Initialize Cosets Table
|
// region Initialize Cosets Table
|
||||||
@@ -75,7 +75,7 @@ namespace tc {
|
|||||||
const auto &[i, j, m] = rel_tables.rels[table_idx];
|
const auto &[i, j, m] = rel_tables.rels[table_idx];
|
||||||
Row &row = rel_tables.rows[0][table_idx];
|
Row &row = rel_tables.rows[0][table_idx];
|
||||||
|
|
||||||
if (cosets.get(i) + cosets.get(j) == -2) {
|
if (!cosets.isset(0, i) && !cosets.isset(0, j)) {
|
||||||
row.lst_idx = lst_vals.size();
|
row.lst_idx = lst_vals.size();
|
||||||
lst_vals.push_back(0);
|
lst_vals.push_back(0);
|
||||||
row.free = false;
|
row.free = false;
|
||||||
@@ -94,7 +94,7 @@ namespace tc {
|
|||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// find next unknown product
|
// find next unknown product
|
||||||
while (idx < cosets.data.size() and cosets.get(idx) >= 0)
|
while (idx < cosets.data.size() and cosets.isset(idx))
|
||||||
idx++;
|
idx++;
|
||||||
|
|
||||||
// if there are none, then return
|
// if there are none, then return
|
||||||
|
|||||||
@@ -8,7 +8,12 @@
|
|||||||
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::tuple<std::string, tc::Group, std::vector<tc::Coset>, size_t>> groups;
|
std::vector<std::tuple<
|
||||||
|
std::string,
|
||||||
|
tc::Group,
|
||||||
|
std::vector<tc::Gen>,
|
||||||
|
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") {
|
||||||
|
|||||||
@@ -9,7 +9,12 @@ int main(int argc, char *argv[]) {
|
|||||||
std::string key = argv[1];
|
std::string key = argv[1];
|
||||||
|
|
||||||
std::cerr << "Min. cos/s: " << MINIMUM_COS_PER_SEC << std::endl;
|
std::cerr << "Min. cos/s: " << MINIMUM_COS_PER_SEC << std::endl;
|
||||||
std::vector<std::tuple<std::string, tc::Group, std::vector<unsigned int>, size_t>> groups;
|
std::vector<std::tuple<
|
||||||
|
std::string,
|
||||||
|
tc::Group,
|
||||||
|
std::vector<tc::Gen>,
|
||||||
|
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 == "B") {
|
if (key == "B") {
|
||||||
|
|||||||
Reference in New Issue
Block a user