diff --git a/CMakeLists.txt b/CMakeLists.txt index 90de0e6..0a92a1d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.10) project(toddcox-faster) +set(CMAKE_CXX_STANDARD 17) + option(TC_BUILD_EXAMPLE "Build example executables" OFF) add_subdirectory(ext) diff --git a/include/tc/core.hpp b/include/tc/core.hpp index 4b6ed0d..7505211 100644 --- a/include/tc/core.hpp +++ b/include/tc/core.hpp @@ -1,5 +1,4 @@ #pragma once -#include "tc/core/rel.hpp" #include "tc/core/group.hpp" #include "tc/core/solver.hpp" diff --git a/include/tc/core/group.hpp b/include/tc/core/group.hpp index cc8629c..4e56033 100644 --- a/include/tc/core/group.hpp +++ b/include/tc/core/group.hpp @@ -7,8 +7,6 @@ #include #include -#include "rel.hpp" - #include #include @@ -65,16 +63,6 @@ namespace tc { typename Matrix::Scalar operator()(int a, int b) const { return _mults(a, b); } - - [[nodiscard]] std::vector get_rels() const { - std::vector res; - for (int i = 0; i < Rank - 1; ++i) { - for (int j = i + 1; j < Rank; ++j) { - res.emplace_back(i, j, _mults(i, j)); - } - } - return res; - } }; template @@ -121,12 +109,4 @@ namespace tc { return res; } - -// Group operator*(const Group &g, const Group &h) { -// return product(g, h); -// } -// -// Group operator^(const Group &g, int p) { -// return power(g, p); -// } } diff --git a/include/tc/core/rel.hpp b/include/tc/core/rel.hpp deleted file mode 100644 index d064428..0000000 --- a/include/tc/core/rel.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include - -struct Rel { - std::array gens; - int mult; - - Rel() = default; - - Rel(const Rel &) = default; - - Rel(int a, int b, int m) - : gens({a, b}), mult(m) { - } - - [[nodiscard]] Rel shift(int off) const { - return Rel(gens[0] + off, gens[1] + off, mult); - } -}; diff --git a/include/tc/core/solver.hpp b/include/tc/core/solver.hpp index 356857b..e9ff640 100644 --- a/include/tc/core/solver.hpp +++ b/include/tc/core/solver.hpp @@ -105,11 +105,13 @@ namespace { struct Table { private: public: - Rel rel; + int i, j, mult; + std::vector rows; public: - explicit Table(const Rel &rel) : rel(rel) { + explicit Table(int i, int j, int mult) : + i(i), j(j), mult(mult) { } }; @@ -159,13 +161,13 @@ namespace { public: explicit Tables(const tc::Group &group) { - const auto &rels = group.get_rels(); - for (int i = 0; i < Rels; ++i) { - const auto &rel = rels[i]; - auto table = std::make_shared(rel); - tables[i] = table; - deps[rel.gens[0]].push_back(table); - deps[rel.gens[1]].push_back(table); + for (int i = 0, irel = 0; i < Rank - 1; ++i) { + for (int j = i + 1; j < Rank; ++j, ++irel) { + auto table = std::make_shared
(i, j, group(i, j)); + tables[irel] = table; + deps[i].push_back(table); + deps[j].push_back(table); + } } } @@ -178,12 +180,11 @@ namespace { void initialize(int target, const tc::Cosets &cosets) { for (auto &table: tables) { - const Rel &rel = table->rel; Row &row = table->rows[target]; if (row.lst == nullptr) { - if (cosets.get(target, rel.gens[0]) != target and - cosets.get(target, rel.gens[1]) != target) { + if (cosets.get(target, table->i) != target and + cosets.get(target, table->j) != target) { row.lst = alloc(); row.gnr = 0; } else { @@ -212,7 +213,6 @@ namespace { for (auto &table: deps[gen]) { Row &target_row = table->rows[target]; Row &coset_row = table->rows[coset]; - const Rel &rel = table->rel; if (target_row.lst == nullptr) { target_row.lst = coset_row.lst; @@ -222,16 +222,16 @@ namespace { target_row.gnr -= 2; } - if (target_row.gnr == rel.mult) { + if (target_row.gnr == table->mult) { // forward learn int lst = *target_row.lst; - int gen_ = rel.gens[rel.gens[0] == gen]; + int gen_ = (table->i == gen) ? table->j : table->i; facts.push(lst * Rank + gen_); - } else if (target_row.gnr == -rel.mult) { + } else if (target_row.gnr == -table->mult) { // stationary learn - int gen_ = rel.gens[rel.gens[0] == gen]; + int gen_ = (table->i == gen) ? table->j : table->i; facts.push(target * Rank + gen_); - } else if (target_row.gnr == rel.mult - 1) { + } else if (target_row.gnr == table->mult - 1) { // determined family *target_row.lst = target; }