From 4b2971d54d042163f8e4f28fdbdd73fb1ebb5810 Mon Sep 17 00:00:00 2001 From: chn Date: Thu, 12 Oct 2023 17:31:58 +0800 Subject: [PATCH] add solver.cpp --- CMakeLists.txt | 2 +- include/ufo/solver.hpp | 14 ++------------ src/solver.cpp | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 src/solver.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e4e573..0d84b3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ find_package(glad REQUIRED) find_package(Matplot++ REQUIRED) find_path(ZPP_BITS_INCLUDE_DIR zpp_bits.h REQUIRED) -add_executable(ufo src/fold.cpp src/unfold.cpp src/plot.cpp src/main.cpp) +add_executable(ufo src/solver.cpp src/fold.cpp src/unfold.cpp src/plot.cpp src/main.cpp) target_include_directories(ufo PRIVATE ${PROJECT_SOURCE_DIR}/include ${ZPP_BITS_INCLUDE_DIR}) target_link_libraries(ufo PRIVATE yaml-cpp Eigen3::Eigen fmt::fmt concurrencpp::concurrencpp HighFive_HighFive TBB::tbb Matplot++::matplot diff --git a/include/ufo/solver.hpp b/include/ufo/solver.hpp index d598ed6..391a012 100644 --- a/include/ufo/solver.hpp +++ b/include/ufo/solver.hpp @@ -62,18 +62,8 @@ namespace ufo virtual Solver& operator()() = 0; virtual ~Solver() = default; - inline static concurrencpp::generator, unsigned>> - triplet_sequence(Eigen::Vector range) - { - for (unsigned x = 0; x < range[0]; x++) - for (unsigned y = 0; y < range[1]; y++) - for (unsigned z = 0; z < range[2]; z++) - co_yield - { - Eigen::Vector{{x}, {y}, {z}}, - x * range[1] * range[2] + y * range[2] + z - }; - } + static concurrencpp::generator, unsigned>> + triplet_sequence(Eigen::Vector range); template inline static void zpp_write(const T& object, std::string filename) { diff --git a/src/solver.cpp b/src/solver.cpp new file mode 100644 index 0000000..a5e640d --- /dev/null +++ b/src/solver.cpp @@ -0,0 +1,17 @@ +# include + +namespace ufo +{ + concurrencpp::generator, unsigned>> Solver::triplet_sequence + (Eigen::Vector range) + { + for (unsigned x = 0; x < range[0]; x++) + for (unsigned y = 0; y < range[1]; y++) + for (unsigned z = 0; z < range[2]; z++) + co_yield + { + Eigen::Vector{{x}, {y}, {z}}, + x * range[1] * range[2] + y * range[2] + z + }; + } +}