forked from mirror/toddcox-faster
make 'examples' plural
This commit is contained in:
8
examples/CMakeLists.txt
Normal file
8
examples/CMakeLists.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
add_executable(bench bench.cpp)
|
||||
target_link_libraries(bench PRIVATE tc)
|
||||
|
||||
add_executable(path path.cpp)
|
||||
target_link_libraries(path PRIVATE tc)
|
||||
|
||||
add_executable(group group.cpp)
|
||||
target_link_libraries(group PRIVATE tc)
|
||||
38
examples/bench.cpp
Normal file
38
examples/bench.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
#include <tc/solver.hpp>
|
||||
#include <tc/groups.hpp>
|
||||
|
||||
template<class G>
|
||||
void test(const G &group) {
|
||||
auto s = std::clock();
|
||||
auto cosets = tc::solve(group, {0});
|
||||
auto e = std::clock();
|
||||
|
||||
double diff = (double) (e - s) / CLOCKS_PER_SEC;
|
||||
int order = cosets.order();
|
||||
|
||||
std::cout
|
||||
<< std::setw(7) << group.name << ", "
|
||||
<< std::setw(7) << order << ", "
|
||||
<< std::fixed << std::setprecision(6) << diff << "s"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
test(tc::group::H<2>());
|
||||
test(tc::group::H<3>());
|
||||
test(tc::group::H<4>());
|
||||
test(tc::group::T(100));
|
||||
test(tc::group::T(500));
|
||||
test(tc::group::T(1000));
|
||||
test(tc::group::E<6>());
|
||||
test(tc::group::E<7>());
|
||||
test(tc::group::B<6>());
|
||||
test(tc::group::B<7>());
|
||||
test(tc::group::B<8>());
|
||||
|
||||
return 0;
|
||||
}
|
||||
34
examples/group.cpp
Normal file
34
examples/group.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <iostream>
|
||||
|
||||
#include <tc/solver.hpp>
|
||||
#include <tc/groups.hpp>
|
||||
|
||||
int main() {
|
||||
constexpr unsigned int Rank = 5;
|
||||
constexpr unsigned int SRank = 3;
|
||||
|
||||
tc::Group<Rank> group = tc::schlafli<Rank>({5, 3, 2, 3});
|
||||
// tc::Group<Rank> group = tc::group::E<Rank>();
|
||||
|
||||
tc::SubGroups<Rank, SRank> subs = tc::subgroups<Rank, SRank>(group);
|
||||
|
||||
std::cout << "Group " << group.name << " (" << subs.size() << " subgroups)" << std::endl;
|
||||
std::cout << group << std::endl;
|
||||
|
||||
for (const auto &sub: subs) {
|
||||
for (int i = 0; i < SRank; ++i) {
|
||||
for (int j = 0; j < SRank; ++j) {
|
||||
auto sub_mult = sub(i, j);
|
||||
auto src_mult = group(sub.gens(i), sub.gens(j));
|
||||
|
||||
if (sub_mult != src_mult) {
|
||||
std::cout << "Incorrect subgroup " << sub.name << std::endl;
|
||||
std::cout << sub << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
21
examples/path.cpp
Normal file
21
examples/path.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include <tc/solver.hpp>
|
||||
#include <tc/groups.hpp>
|
||||
|
||||
int main() {
|
||||
auto cube = tc::group::B<3>();
|
||||
auto vars = tc::solve(cube);
|
||||
|
||||
std::string start;
|
||||
std::vector<std::string> names = {"a", "b", "c"};
|
||||
auto words = vars.path().walk(start, names, std::plus<>());
|
||||
|
||||
for (const auto &word: words) {
|
||||
std::cout << (word.empty() ? "-" : word) << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user