diff --git a/fileReader.cpp b/fileReader.cpp index 631eb70..a3b544a 100644 --- a/fileReader.cpp +++ b/fileReader.cpp @@ -8,8 +8,6 @@ #include #include - - fileReader::fileReader(unsigned n, unsigned k, unsigned m, stabilizerCodesType codeType, bool trained) { mycodetype = codeType; N = n; @@ -26,7 +24,6 @@ fileReader::fileReader(unsigned n, unsigned k, unsigned m, stabilizerCodesType c } } - void fileReader::read_H() { std::string codeTypeString = code_type_string(); std::string filename = "./PCMs/" + codeTypeString + "_" + std::to_string(N) + "_" + std::to_string(K) + "/" + @@ -36,7 +33,7 @@ void fileReader::read_H() { // Mck same shape and Nv, but its value k means the i-th CN being the k-th neigbor of j-th VN std::vector> checkValues; std::vector> VariableValues; - + std::string line; std::ifstream matrix_file; matrix_file.open(filename); @@ -172,7 +169,7 @@ void fileReader::load_cn_weights() { unsigned n = std::stoul(line); getline(weights_file, line); unsigned m = std::stoul(line); - + if (n != N) { throw std::runtime_error("load_cn_weights: file-specified N not as expected"); } @@ -290,7 +287,6 @@ std::filesystem::path fileReader::construct_weights_path(std::string_view filena return path; } - std::string fileReader::code_type_string() const { switch (mycodetype) { case stabilizerCodesType::GeneralizedBicycle: @@ -349,6 +345,4 @@ bool fileReader::check_symplectic() { return true; } -inline bool fileReader::trace_inner_product(unsigned int a, unsigned int b) { - return !(a == 0 || b == 0 || a == b); -} \ No newline at end of file +inline bool fileReader::trace_inner_product(unsigned int a, unsigned int b) { return !(a == 0 || b == 0 || a == b); } \ No newline at end of file diff --git a/fileReader.h b/fileReader.h index 5c1ebdb..35cc16a 100644 --- a/fileReader.h +++ b/fileReader.h @@ -11,13 +11,12 @@ #include #include enum class stabilizerCodesType { GeneralizedBicycle = 0, HypergraphProduct = 1, toric = 3 }; -class fileReader{ +class fileReader { public: fileReader(unsigned n, unsigned k, unsigned m, stabilizerCodesType codeType, bool trained = false); std::string code_type_string() const; std::filesystem::path construct_weights_path(std::string_view filename) const; - void load_cn_weights(); void load_vn_weights(); void load_llr_weights(); @@ -51,4 +50,3 @@ class fileReader{ std::vector>> weights_vn; std::vector> weights_llr; }; - diff --git a/simulateFER.cpp b/simulateFER.cpp index 9b1b7a6..1fd6800 100644 --- a/simulateFER.cpp +++ b/simulateFER.cpp @@ -37,9 +37,8 @@ int main() { std::cout << ",trained"; std::cout << std::endl; - std::cout << "% collect " << max_frame_errors << " frame errors or " << max_decoded_words << " decoded error patterns" << std::endl; - - + std::cout << "% collect " << max_frame_errors << " frame errors or " << max_decoded_words + << " decoded error patterns" << std::endl; // omp_set_num_threads(1); for (double epsilon : ep_list) { @@ -63,7 +62,6 @@ int main() { } std::cout << "% FE " << failure << ", total dec. " << total_decoding << "\\\\" << std::endl; std::cout << epsilon << " " << (failure / total_decoding) << "\\\\" << std::endl; - } return 0; } diff --git a/stabilizerCodes.cpp b/stabilizerCodes.cpp index 966d2ad..622a671 100644 --- a/stabilizerCodes.cpp +++ b/stabilizerCodes.cpp @@ -15,8 +15,8 @@ #include #include - -stabilizerCodes::stabilizerCodes(unsigned n, unsigned k, unsigned m, stabilizerCodesType codeType, const fileReader fr, bool trained) { +stabilizerCodes::stabilizerCodes(unsigned n, unsigned k, unsigned m, stabilizerCodesType codeType, const fileReader fr, + bool trained) { mycodetype = codeType; N = n; K = k; @@ -34,13 +34,11 @@ stabilizerCodes::stabilizerCodes(unsigned n, unsigned k, unsigned m, stabilizerC Nvk = fr.Nvk; Mck = fr.Mck; G = fr.G; - if (trained){ + if (trained) { weights_cn = fr.weights_cn; weights_vn = fr.weights_vn; weights_llr = fr.weights_llr; } - - } std::vector stabilizerCodes::decode(unsigned int L, double epsilon) { @@ -52,8 +50,6 @@ std::vector stabilizerCodes::decode(unsigned int L, double epsilon) { return flooding_decode(L, epsilon); } - - void stabilizerCodes::add_error_given_epsilon(double epsilon) { error.clear(); errorString.clear(); @@ -83,7 +79,6 @@ void stabilizerCodes::add_error_given_epsilon(double epsilon) { // void stabilizerCodes::add_error_given_positions(int *pos, int *error, int size) {} - double stabilizerCodes::quantize_belief(double Tau, double Tau1, double Tau2) { double nom = log1p(exp(-1.0 * Tau)); double denom = std::max(-1.0 * Tau1, -1.0 * Tau2) + log1p(exp(-1.0 * fabs((Tau1 - Tau2)))); @@ -355,5 +350,3 @@ std::vector stabilizerCodes::check_success(const double *Taux, const doubl success[1] = true; return success; } - - diff --git a/stabilizerCodes.h b/stabilizerCodes.h index 3f4e34a..098714f 100644 --- a/stabilizerCodes.h +++ b/stabilizerCodes.h @@ -10,17 +10,16 @@ */ #ifndef BPDECODING_STABILIZIERCODES_H #define BPDECODING_STABILIZIERCODES_H +#include "fileReader.h" #include #include #include #include -#include "fileReader.h" - - class stabilizerCodes { public: - stabilizerCodes(unsigned n, unsigned k, unsigned m, stabilizerCodesType codeType, const fileReader fr, bool trained = false); + stabilizerCodes(unsigned n, unsigned k, unsigned m, stabilizerCodesType codeType, const fileReader fr, + bool trained = false); std::vector decode(unsigned int L, double epsilon); @@ -39,8 +38,6 @@ class stabilizerCodes { static double quantize_belief(double Taux, double Tauy, double Tauz); private: - - bool print_msg = false; stabilizerCodesType mycodetype;