From 224d9841840dfd80800faab54ad4c2bf63108ccd Mon Sep 17 00:00:00 2001 From: David Allemang Date: Sat, 19 Nov 2022 12:31:46 -0500 Subject: [PATCH] wip - add Path<> stub; remove old. --- tc/CMakeLists.txt | 1 - tc/include/tc/core.hpp | 9 +++- tc/include/tc/util.hpp | 107 ----------------------------------------- tc/src/lang.cpp | 1 - 4 files changed, 8 insertions(+), 110 deletions(-) delete mode 100644 tc/include/tc/util.hpp diff --git a/tc/CMakeLists.txt b/tc/CMakeLists.txt index 5d632eb..f17105a 100644 --- a/tc/CMakeLists.txt +++ b/tc/CMakeLists.txt @@ -1,7 +1,6 @@ add_library(tc include/tc/core.hpp include/tc/groups.hpp - include/tc/util.hpp src/cosets.cpp src/group.cpp diff --git a/tc/include/tc/core.hpp b/tc/include/tc/core.hpp index db9fc6a..65f125a 100644 --- a/tc/include/tc/core.hpp +++ b/tc/include/tc/core.hpp @@ -44,6 +44,13 @@ namespace tc { template struct Group; + /** + * @brief Support generating values given a Cosets and transformation callback. + * @tparam Gen_ + */ + template + struct Path; // todo not yet implemented + template<> struct Index<> { size_t operator()(size_t const &idx) const { @@ -57,7 +64,7 @@ namespace tc { std::vector _gens{}; - explicit Index(std::vector gens) : _gens(gens) {} +// explicit Index(std::vector gens) : _gens(gens) {} size_t operator()(Gen const &gen) const { auto it = std::find(_gens.begin(), _gens.end(), gen); diff --git a/tc/include/tc/util.hpp b/tc/include/tc/util.hpp deleted file mode 100644 index 3387754..0000000 --- a/tc/include/tc/util.hpp +++ /dev/null @@ -1,107 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include - -namespace tc { -// using Mult = uint16_t; -// constexpr Mult FREE = 0; - - struct Action { - int from_idx = -1; - int gen = -1; - - Action() = default; - - Action(const Action &) = default; - - Action(int from_idx, int gen) - : from_idx(from_idx), gen(gen) { - } - }; - - struct Path { - std::vector path; - - Path() = default; - - Path(const Path &) = default; - - void add_row() { - path.resize(path.size() + 1); - } - - [[nodiscard]] Action get(int to_idx) const { - return path[to_idx]; - } - - void put(int from_idx, int gen, int to_idx) { - path[to_idx] = Action(from_idx, gen); - } - - template - void walk( - C &res, - T start, - std::vector gens, - std::function op - ) const { - size_t s = size(); - res.reserve(s); - res.push_back(start); - - for (int i = 1; i < s; ++i) { - auto &action = path[i]; - auto &from = res.get(action.from_idx); - auto &val = gens[action.gen]; - res.push_back(op(from, val)); - } - } - - template - [[nodiscard]] std::vector walk( - T start, - std::vector gens, - std::function op - ) const { - std::vector res; - res.reserve(size()); - res.push_back(start); - - for (int i = 1; i < size(); ++i) { - auto &action = path[i]; - auto &from = res[action.from_idx]; - auto &val = gens[action.gen]; - res.push_back(op(from, val)); - } - - return res; - } - - template - [[nodiscard]] std::vector walk( - T start, - std::function op - ) const { - std::vector res; - res.reserve(size()); - res.push_back(start); - - for (int i = 1; i < size(); ++i) { - auto &action = path[i]; - auto &from = res[action.from_idx]; - auto &val = action.gen; - res[i] = op(from, val); - } - - return res; - } - - [[nodiscard]] size_t size() const { - return path.size(); - } - }; -} diff --git a/tc/src/lang.cpp b/tc/src/lang.cpp index f6376ba..3b102cb 100644 --- a/tc/src/lang.cpp +++ b/tc/src/lang.cpp @@ -3,7 +3,6 @@ #include #include -#include #include #include