forked from mirror/toddcox-faster
refactor into cmake project, tweak api
This commit is contained in:
5
example/CMakeLists.txt
Normal file
5
example/CMakeLists.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
add_executable(bench bench.cpp)
|
||||
target_link_libraries(bench PRIVATE tc)
|
||||
|
||||
add_executable(path path.cpp)
|
||||
target_link_libraries(path PRIVATE tc)
|
||||
35
example/bench.cpp
Normal file
35
example/bench.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include "tc/core.hpp"
|
||||
#include "tc/groups.hpp"
|
||||
|
||||
#include <ctime>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
std::vector<tc::Group> groups = {
|
||||
tc::group::H(2),
|
||||
tc::group::H(3),
|
||||
tc::group::H(4),
|
||||
tc::group::T(100),
|
||||
tc::group::T(500),
|
||||
tc::group::T(1000),
|
||||
tc::group::E(6),
|
||||
tc::group::E(7),
|
||||
tc::group::B(6),
|
||||
tc::group::B(7),
|
||||
tc::group::B(8),
|
||||
};
|
||||
|
||||
for (const auto &group : groups) {
|
||||
auto s = std::clock(); // to measure CPU time
|
||||
auto cosets = group.solve();
|
||||
auto e = std::clock();
|
||||
|
||||
double diff = (double) (e - s) / CLOCKS_PER_SEC;
|
||||
int order = cosets.size();
|
||||
|
||||
std::cout << group.name << "," << order << "," << diff << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
17
example/path.cpp
Normal file
17
example/path.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include "tc/solver.h"
|
||||
#include "tc/groups.h"
|
||||
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
auto cube = tc::group::B(3);
|
||||
auto vars = tc::solve(cube, {});
|
||||
|
||||
for (int target = 1; target < vars.len; target++) {
|
||||
auto &action = vars.path[target];
|
||||
std::cout << action.coset << " " << action.gen << " " << target << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user