diff --git a/include/tc/core.hpp b/include/tc/core.hpp index d69f1b0..d2bd17f 100644 --- a/include/tc/core.hpp +++ b/include/tc/core.hpp @@ -6,6 +6,13 @@ #include namespace tc { + struct Action; + struct Path; + struct Cosets; + struct Rel; + struct Group; + struct SubGroup; + struct Action { int from_idx = -1; int gen = -1; @@ -18,9 +25,10 @@ namespace tc { }; struct Path { + const tc::Group &context; std::vector path; - Path() = default; + explicit Path(const tc::Group &context); Path(const Path &) = default; @@ -71,13 +79,14 @@ namespace tc { }; struct Cosets { - int ngens; + const tc::Group &context; + std::vector data; Path path; Cosets(const Cosets &) = default; - explicit Cosets(int ngens); + explicit Cosets(const tc::Group &context); void add_row(); @@ -105,8 +114,6 @@ namespace tc { [[nodiscard]] Rel shift(int off) const; }; - struct SubGroup; - struct Group { const int ngens; std::vector> _mults; diff --git a/src/core.cpp b/src/core.cpp index 09ff19d..ac90397 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -9,6 +9,10 @@ namespace tc { : from_idx(from_idx), gen(gen) { } + Path::Path(const tc::Group &context) + : context(context), path() { + } + void Path::add_row() { path.resize(path.size() + 1); } @@ -25,18 +29,18 @@ namespace tc { return path.size(); } - Cosets::Cosets(int ngens) - : ngens(ngens) { + Cosets::Cosets(const tc::Group &context) + : path(context), context(context), data() { } void Cosets::add_row() { - data.resize(data.size() + ngens, -1); + data.resize(data.size() + context.ngens, -1); path.add_row(); } void Cosets::put(int coset, int gen, int target) { - data[coset * ngens + gen] = target; - data[target * ngens + gen] = coset; + data[coset * context.ngens + gen] = target; + data[target * context.ngens + gen] = coset; if (path.get(target).from_idx == -1) { path.put(coset, gen, target); @@ -44,10 +48,10 @@ namespace tc { } void Cosets::put(int idx, int target) { - int coset = idx / ngens; - int gen = idx % ngens; + int coset = idx / context.ngens; + int gen = idx % context.ngens; data[idx] = target; - data[target * ngens + gen] = coset; + data[target * context.ngens + gen] = coset; if (path.get(target).from_idx == -1) { path.put(coset, gen, target); @@ -55,7 +59,7 @@ namespace tc { } int Cosets::get(int coset, int gen) const { - return data[coset * ngens + gen]; + return data[coset * context.ngens + gen]; } int Cosets::get(int idx) const { diff --git a/src/solve.cpp b/src/solve.cpp index 0c144f0..10343ba 100644 --- a/src/solve.cpp +++ b/src/solve.cpp @@ -65,7 +65,7 @@ namespace tc { }; Cosets Group::solve(const std::vector &sub_gens) const { - Cosets cosets(ngens); + Cosets cosets(*this); cosets.add_row(); if (ngens == 0) {