This commit is contained in:
2019-11-13 17:15:25 -05:00
commit 19f551ea92
4 changed files with 214 additions and 0 deletions

51
.gitignore vendored Normal file
View File

@@ -0,0 +1,51 @@
.idea/
*.iml
# Created by .ignore support plugin (hsz.mobi)
### CMake template
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
### C++ template
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app

6
CMakeLists.txt Normal file
View File

@@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 3.14)
project(hpc)
set(CMAKE_CXX_STANDARD 17)
add_executable(hpc main.cpp)

90
cmake-build-debug/hpc.cbp Normal file
View File

@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6"/>
<Project>
<Option title="hpc"/>
<Option makefile_is_custom="1"/>
<Option compiler="gcc"/>
<Option virtualFolders="CMake Files\;"/>
<Build>
<Target title="all">
<Option working_dir="C:/Users/allem/CLionProjects/hpc/cmake-build-debug"/>
<Option type="4"/>
<MakeCommands>
<Build command="C:/MinGW/bin/mingw32-make.exe -f &quot;C:/Users/allem/CLionProjects/hpc/cmake-build-debug/Makefile&quot; VERBOSE=1 all"/>
<CompileFile command="C:/MinGW/bin/mingw32-make.exe -f &quot;C:/Users/allem/CLionProjects/hpc/cmake-build-debug/Makefile&quot; VERBOSE=1 &quot;$file&quot;"/>
<Clean command="C:/MinGW/bin/mingw32-make.exe -f &quot;C:/Users/allem/CLionProjects/hpc/cmake-build-debug/Makefile&quot; VERBOSE=1 clean"/>
<DistClean command="C:/MinGW/bin/mingw32-make.exe -f &quot;C:/Users/allem/CLionProjects/hpc/cmake-build-debug/Makefile&quot; VERBOSE=1 clean"/>
</MakeCommands>
</Target>
<Target title="hpc">
<Option output="C:/Users/allem/CLionProjects/hpc/cmake-build-debug/hpc.exe" prefix_auto="0" extension_auto="0"/>
<Option working_dir="C:/Users/allem/CLionProjects/hpc/cmake-build-debug"/>
<Option object_output="./"/>
<Option type="1"/>
<Option compiler="gcc"/>
<Compiler>
<Add directory="c:\mingw\bin\../lib/gcc/mingw32/8.2.0/include/c++"/>
<Add directory="c:\mingw\bin\../lib/gcc/mingw32/8.2.0/include/c++/mingw32"/>
<Add directory="c:\mingw\bin\../lib/gcc/mingw32/8.2.0/include/c++/backward"/>
<Add directory="c:\mingw\bin\../lib/gcc/mingw32/8.2.0/include"/>
<Add directory="c:\mingw\bin\../lib/gcc/mingw32/8.2.0/../../../../include"/>
<Add directory="c:\mingw\bin\../lib/gcc/mingw32/8.2.0/include-fixed"/>
</Compiler>
<MakeCommands>
<Build command="C:/MinGW/bin/mingw32-make.exe -f &quot;C:/Users/allem/CLionProjects/hpc/cmake-build-debug/Makefile&quot; VERBOSE=1 hpc"/>
<CompileFile command="C:/MinGW/bin/mingw32-make.exe -f &quot;C:/Users/allem/CLionProjects/hpc/cmake-build-debug/Makefile&quot; VERBOSE=1 &quot;$file&quot;"/>
<Clean command="C:/MinGW/bin/mingw32-make.exe -f &quot;C:/Users/allem/CLionProjects/hpc/cmake-build-debug/Makefile&quot; VERBOSE=1 clean"/>
<DistClean command="C:/MinGW/bin/mingw32-make.exe -f &quot;C:/Users/allem/CLionProjects/hpc/cmake-build-debug/Makefile&quot; VERBOSE=1 clean"/>
</MakeCommands>
</Target>
<Target title="hpc/fast">
<Option output="C:/Users/allem/CLionProjects/hpc/cmake-build-debug/hpc.exe" prefix_auto="0" extension_auto="0"/>
<Option working_dir="C:/Users/allem/CLionProjects/hpc/cmake-build-debug"/>
<Option object_output="./"/>
<Option type="1"/>
<Option compiler="gcc"/>
<Compiler>
<Add directory="c:\mingw\bin\../lib/gcc/mingw32/8.2.0/include/c++"/>
<Add directory="c:\mingw\bin\../lib/gcc/mingw32/8.2.0/include/c++/mingw32"/>
<Add directory="c:\mingw\bin\../lib/gcc/mingw32/8.2.0/include/c++/backward"/>
<Add directory="c:\mingw\bin\../lib/gcc/mingw32/8.2.0/include"/>
<Add directory="c:\mingw\bin\../lib/gcc/mingw32/8.2.0/../../../../include"/>
<Add directory="c:\mingw\bin\../lib/gcc/mingw32/8.2.0/include-fixed"/>
</Compiler>
<MakeCommands>
<Build command="C:/MinGW/bin/mingw32-make.exe -f &quot;C:/Users/allem/CLionProjects/hpc/cmake-build-debug/Makefile&quot; VERBOSE=1 hpc/fast"/>
<CompileFile command="C:/MinGW/bin/mingw32-make.exe -f &quot;C:/Users/allem/CLionProjects/hpc/cmake-build-debug/Makefile&quot; VERBOSE=1 &quot;$file&quot;"/>
<Clean command="C:/MinGW/bin/mingw32-make.exe -f &quot;C:/Users/allem/CLionProjects/hpc/cmake-build-debug/Makefile&quot; VERBOSE=1 clean"/>
<DistClean command="C:/MinGW/bin/mingw32-make.exe -f &quot;C:/Users/allem/CLionProjects/hpc/cmake-build-debug/Makefile&quot; VERBOSE=1 clean"/>
</MakeCommands>
</Target>
<Target title="edit_cache">
<Option working_dir="C:/Users/allem/CLionProjects/hpc/cmake-build-debug"/>
<Option type="4"/>
<MakeCommands>
<Build command="C:/MinGW/bin/mingw32-make.exe -f &quot;C:/Users/allem/CLionProjects/hpc/cmake-build-debug/Makefile&quot; VERBOSE=1 edit_cache"/>
<CompileFile command="C:/MinGW/bin/mingw32-make.exe -f &quot;C:/Users/allem/CLionProjects/hpc/cmake-build-debug/Makefile&quot; VERBOSE=1 &quot;$file&quot;"/>
<Clean command="C:/MinGW/bin/mingw32-make.exe -f &quot;C:/Users/allem/CLionProjects/hpc/cmake-build-debug/Makefile&quot; VERBOSE=1 clean"/>
<DistClean command="C:/MinGW/bin/mingw32-make.exe -f &quot;C:/Users/allem/CLionProjects/hpc/cmake-build-debug/Makefile&quot; VERBOSE=1 clean"/>
</MakeCommands>
</Target>
<Target title="rebuild_cache">
<Option working_dir="C:/Users/allem/CLionProjects/hpc/cmake-build-debug"/>
<Option type="4"/>
<MakeCommands>
<Build command="C:/MinGW/bin/mingw32-make.exe -f &quot;C:/Users/allem/CLionProjects/hpc/cmake-build-debug/Makefile&quot; VERBOSE=1 rebuild_cache"/>
<CompileFile command="C:/MinGW/bin/mingw32-make.exe -f &quot;C:/Users/allem/CLionProjects/hpc/cmake-build-debug/Makefile&quot; VERBOSE=1 &quot;$file&quot;"/>
<Clean command="C:/MinGW/bin/mingw32-make.exe -f &quot;C:/Users/allem/CLionProjects/hpc/cmake-build-debug/Makefile&quot; VERBOSE=1 clean"/>
<DistClean command="C:/MinGW/bin/mingw32-make.exe -f &quot;C:/Users/allem/CLionProjects/hpc/cmake-build-debug/Makefile&quot; VERBOSE=1 clean"/>
</MakeCommands>
</Target>
</Build>
<Unit filename="C:/Users/allem/CLionProjects/hpc/main.cpp">
<Option target="hpc"/>
</Unit>
<Unit filename="C:/Users/allem/CLionProjects/hpc/CMakeLists.txt">
<Option virtualFolder="CMake Files\"/>
</Unit>
</Project>
</CodeBlocks_project_file>

67
main.cpp Normal file
View File

@@ -0,0 +1,67 @@
#include <iostream>
#include <vector>
using Gens=std::vector<int>;
using Table=std::vector<Gens>;
void pp(const Gens &g) {
for (const auto &e : g) {
std::cout << e << " ";
}
std::cout << std::endl;
}
void pp(const Table &t) {
std::cout << "| table:" << std::endl;
for (const auto &g : t) {
std::cout << "| ";
pp(g);
}
}
void new_coset(const int ngens, const std::vector<Gens> &rels,
Table &cosets, std::vector<Table> &reltables,
Table &starts, Table &ends) {
int C = cosets.size();
cosets.emplace_back(ngens, -1);
for (size_t i = 0; i < rels.size(); ++i) {
auto &table = reltables[i];
unsigned int R = rels[i].size();
table.emplace_back(R + 1, -1);
table[C][0] = C;
table[C][R] = C;
starts[i].push_back(0);
ends[i].push_back(R);
}
}
Table solve_tc(int ngens, const Gens &sub, const std::vector<Gens> &rels) {
Table cosets;
std::vector<Table> reltables(rels.size());
// storing progress for each relation table row
Table starts(rels.size()); // [rel_table][coset]
Table ends(rels.size());
new_coset(ngens, rels, cosets, reltables, starts, ends);
return cosets;
}
int main() {
auto cosets = solve_tc(3, {0, 1}, {
{0, 1, 0, 1, 0, 1, 0, 1},
{1, 2, 1, 2, 1, 2},
{0, 2, 0, 2},
});
pp(cosets);
return 0;
}