author
int64 658
755k
| date
stringlengths 19
19
| timezone
int64 -46,800
43.2k
| hash
stringlengths 40
40
| message
stringlengths 5
490
| mods
list | language
stringclasses 20
values | license
stringclasses 3
values | repo
stringlengths 5
68
| original_message
stringlengths 12
491
|
---|---|---|---|---|---|---|---|---|---|
8,483 |
17.04.2018 08:58:40
| -7,200 |
6940d9e91ce50e96f50aac5c86fdb109398b4cbc
|
Remove the deactivation of cool bash when using sim-pyber argument
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/Simulation.cpp",
"new_path": "src/Factory/Simulation/Simulation.cpp",
"diff": "@@ -186,11 +186,11 @@ void Simulation::parameters\nthis->local_seed = this->global_seed;\n#endif\n-#ifdef ENABLE_COOL_BASH\n- // disable the cool bash mode for PyBER\n- if (!this->pyber.empty())\n- rang::setControlMode(rang::control::Off);\n-#endif\n+//#ifdef ENABLE_COOL_BASH\n+// // disable the cool bash mode for PyBER\n+// if (!this->pyber.empty())\n+// rang::setControlMode(rang::control::Off);\n+//#endif\n#ifdef MULTI_PREC\nif(vals.exist({p+\"-prec\", \"p\"})) this->sim_prec = vals.to_int({p+\"-prec\", \"p\"});\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Remove the deactivation of cool bash when using sim-pyber argument
|
8,483 |
17.04.2018 08:59:08
| -7,200 |
ab7e2e832c798497f1254558a4139bbe5a2cd589
|
Using Terminal::comment_tag in Launcher when displaying the legend
|
[
{
"change_type": "MODIFY",
"old_path": "src/Launcher/Launcher.cpp",
"new_path": "src/Launcher/Launcher.cpp",
"diff": "#include <functional>\n#include <date.h>\n+#include \"Tools/Display/Terminal/Terminal.hpp\"\n+\n#ifdef ENABLE_MPI\n#include <mpi.h>\n#endif\n@@ -76,7 +78,7 @@ int Launcher::read_arguments()\n{\nauto save = tools::exception::no_backtrace;\ntools::exception::no_backtrace = true;\n- cmd_error.push_back(e.what());\n+ cmd_error.emplace_back(e.what());\ntools::exception::no_backtrace = save;\n}\n@@ -87,16 +89,16 @@ int Launcher::read_arguments()\n}\n// print usage\n- if (cmd_error.size() && !params_common.display_help)\n+ if (!cmd_error.empty() && !params_common.display_help)\nah.print_usage(this->args);\n// print the errors\n- if (cmd_error.size()) std::cerr << std::endl;\n+ if (!cmd_error.empty()) std::cerr << std::endl;\nfor (unsigned e = 0; e < cmd_error.size(); e++)\nstd::cerr << rang::format::error << cmd_error[e] << rang::format::reset << std::endl;\n// print the help tags\n- if (cmd_error.size() && !params_common.display_help)\n+ if (!cmd_error.empty() && !params_common.display_help)\n{\ntools::Argument_tag help_tag = {\"help\", \"h\"};\n@@ -106,25 +108,26 @@ int Launcher::read_arguments()\nstd::cerr << std::endl << rang::format::info << message << rang::format::reset << std::endl;\n}\n- return (cmd_error.size() || params_common.display_help) ? EXIT_FAILURE : EXIT_SUCCESS;\n+ return (!cmd_error.empty() || params_common.display_help) ? EXIT_FAILURE : EXIT_SUCCESS;\n}\nvoid Launcher::print_header()\n{\n// display configuration and simulation parameters\n- stream << \"# \" << rang::style::bold << \"----------------------------------------------------\" << std::endl;\n- stream << \"# \" << \"---- A FAST FORWARD ERROR CORRECTION TOOLBOX >> ----\" << std::endl;\n- stream << \"# \" << \"----------------------------------------------------\" << std::endl;\n- stream << \"# \" << rang::style::underline << \"Parameters :\"<< rang::style::reset << std::endl;\n+ stream << rang::style::bold;\n+ stream << tools::Terminal::comment_tag << \"----------------------------------------------------\" << std::endl;\n+ stream << tools::Terminal::comment_tag << \"---- A FAST FORWARD ERROR CORRECTION TOOLBOX >> ----\" << std::endl;\n+ stream << tools::Terminal::comment_tag << \"----------------------------------------------------\" << std::endl;\n+ stream << tools::Terminal::comment_tag << rang::style::underline << \"Parameters :\"<< rang::style::reset << std::endl;\nfactory::Header::print_parameters({¶ms_common}, false, this->stream);\n- this->stream << \"#\" << std::endl;\n+ this->stream << tools::Terminal::comment_tag << std::endl;\n}\nint Launcher::launch()\n{\nint exit_code = EXIT_SUCCESS;\n- std::srand(this->params_common.global_seed);\n+ std::srand((unsigned)this->params_common.global_seed);\n// in case of the user call launch multiple times\nif (simu != nullptr)\n@@ -187,7 +190,7 @@ int Launcher::launch()\n#ifdef ENABLE_MPI\nif (this->params_common.mpi_rank == 0)\n#endif\n- stream << \"# \" << \"The simulation is running...\" << std::endl;\n+ stream << tools::Terminal::comment_tag << \"The simulation is running...\" << std::endl;\ntry\n{\n@@ -206,7 +209,7 @@ int Launcher::launch()\n#ifdef ENABLE_MPI\nif (this->params_common.mpi_rank == 0)\n#endif\n- stream << \"# End of the simulation.\" << std::endl;\n+ stream << tools::Terminal::comment_tag << \"End of the simulation.\" << std::endl;\nif (simu != nullptr)\n{\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Using Terminal::comment_tag in Launcher when displaying the legend
|
8,483 |
17.04.2018 11:18:47
| -7,200 |
e3ac183542a71d74f4c53e20873091e01e27fcf4
|
Add a 'comment' rang format and use it in terminal class, Launcher and Factory::Header class
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Factory.cpp",
"new_path": "src/Factory/Factory.cpp",
"diff": "#include <sstream>\n#include <vector>\n#include <map>\n-#include <rang.hpp>\n+#include \"Tools/Display/rang_format/rang_format.h\"\n#include \"Tools/general_utils.h\"\n#include \"Tools/Exception/exception.hpp\"\n@@ -126,13 +126,13 @@ void aff3ct::factory::Header::print_parameters(std::string grp_key, std::string\nif (key.size() == 1)\n{\n- stream << \"# * \" << rang::style::bold << rang::style::underline << grp_name << rang::style::reset << \" \";\n+ stream << rang::format::comment << \"* \" << rang::style::bold << rang::style::underline << grp_name << rang::style::reset << \" \";\nfor (auto i = 0; i < 46 - (int)grp_name.length(); i++) std::cout << \"-\";\nstream << std::endl;\n}\nelse if (key.size() > 1)\n{\n- stream << \"# \" << rang::style::bold << rang::style::underline << grp_name << rang::style::reset << \" \";\n+ stream << rang::format::comment << \" \" << rang::style::bold << rang::style::underline << grp_name << rang::style::reset << \" \";\nfor (auto i = 0; i < 45 - (int)grp_name.length(); i++) std::cout << \"-\";\nstream << std::endl;\n}\n@@ -142,7 +142,7 @@ void aff3ct::factory::Header::print_parameters(std::string grp_key, std::string\n{\nif (std::find(dup.begin(), dup.end(), header[i].first + header[i].second) == dup.end())\n{\n- stream << \"# ** \" << rang::style::bold << header[i].first << rang::style::reset;\n+ stream << rang::format::comment << \" ** \" << rang::style::bold << header[i].first << rang::style::reset;\nfor (auto j = 0; j < max_n_chars - (int)header[i].first.length(); j++) stream << \" \";\nstream << \" = \" << header[i].second << std::endl;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/Simulation.cpp",
"new_path": "src/Factory/Simulation/Simulation.cpp",
"diff": "@@ -186,12 +186,6 @@ void Simulation::parameters\nthis->local_seed = this->global_seed;\n#endif\n-//#ifdef ENABLE_COOL_BASH\n-// // disable the cool bash mode for PyBER\n-// if (!this->pyber.empty())\n-// rang::setControlMode(rang::control::Off);\n-//#endif\n-\n#ifdef MULTI_PREC\nif(vals.exist({p+\"-prec\", \"p\"})) this->sim_prec = vals.to_int({p+\"-prec\", \"p\"});\n#endif\n@@ -212,7 +206,7 @@ void Simulation::parameters\n{\nstd::stringstream noise_range_str;\nnoise_range_str << this->noise_range.front() << \" -> \" << this->noise_range.back() << \" dB\";\n- headers[p].push_back(std::make_pair(\"NOISE range\", noise_range_str.str()));\n+ headers[p].push_back(std::make_pair(\"Noise range\", noise_range_str.str()));\n}\nheaders[p].push_back(std::make_pair(\"Seed\", std::to_string(this->global_seed)));\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Launcher/Launcher.cpp",
"new_path": "src/Launcher/Launcher.cpp",
"diff": "@@ -114,13 +114,12 @@ int Launcher::read_arguments()\nvoid Launcher::print_header()\n{\n// display configuration and simulation parameters\n- stream << rang::style::bold;\n- stream << tools::Terminal::comment_tag << \"----------------------------------------------------\" << std::endl;\n- stream << tools::Terminal::comment_tag << \"---- A FAST FORWARD ERROR CORRECTION TOOLBOX >> ----\" << std::endl;\n- stream << tools::Terminal::comment_tag << \"----------------------------------------------------\" << std::endl;\n- stream << tools::Terminal::comment_tag << rang::style::underline << \"Parameters :\"<< rang::style::reset << std::endl;\n+ stream << rang::format::comment << rang::style::bold << \"----------------------------------------------------\" << std::endl;\n+ stream << rang::format::comment << rang::style::bold << \"---- A FAST FORWARD ERROR CORRECTION TOOLBOX >> ----\" << std::endl;\n+ stream << rang::format::comment << rang::style::bold << \"----------------------------------------------------\" << std::endl;\n+ stream << rang::format::comment << rang::style::bold << rang::style::underline << \"Parameters :\"<< rang::style::reset << std::endl;\nfactory::Header::print_parameters({¶ms_common}, false, this->stream);\n- this->stream << tools::Terminal::comment_tag << std::endl;\n+ this->stream << rang::format::comment << std::endl;\n}\nint Launcher::launch()\n@@ -190,7 +189,7 @@ int Launcher::launch()\n#ifdef ENABLE_MPI\nif (this->params_common.mpi_rank == 0)\n#endif\n- stream << tools::Terminal::comment_tag << \"The simulation is running...\" << std::endl;\n+ stream << rang::format::comment << \"The simulation is running...\" << std::endl;\ntry\n{\n@@ -209,7 +208,7 @@ int Launcher::launch()\n#ifdef ENABLE_MPI\nif (this->params_common.mpi_rank == 0)\n#endif\n- stream << tools::Terminal::comment_tag << \"End of the simulation.\" << std::endl;\n+ stream << rang::format::comment << \"End of the simulation.\" << std::endl;\nif (simu != nullptr)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/Terminal.cpp",
"new_path": "src/Tools/Display/Terminal/Terminal.cpp",
"diff": "@@ -6,7 +6,6 @@ using namespace aff3ct::tools;\nconst char aff3ct::tools::Terminal::col_separator = '|';\nconst char aff3ct::tools::Terminal::line_separator = '-';\n-const std::string aff3ct::tools::Terminal::comment_tag = \"# \";\nconst std::string aff3ct::tools::Terminal::spaced_scol_separator = \" |\" ;\nconst std::string aff3ct::tools::Terminal::spaced_dcol_separator = \" ||\";\nconst std::string aff3ct::tools::Terminal::data_tag = \" \";\n@@ -60,7 +59,7 @@ void Terminal\n// indice (7.2) is \"cols_groups[1].second[2].second\"\n// print line 1 of the table\n- stream << comment_tag;\n+ stream << rang::format::comment;\nfor (unsigned i = 0; i < cols_groups.size(); i++)\n{\nconst unsigned group_width = cols_groups[i].second.size()*(column_width+1)-1; // add a col separator between each exept for the last\n@@ -74,7 +73,7 @@ void Terminal\n// print line 2 and 3 of the table (group title lines)\nfor (auto l = 0; l < 2; l++)\n{\n- stream << comment_tag;\n+ stream << rang::format::comment;\nfor (unsigned i = 0; i < cols_groups.size(); i++)\n{\nconst auto& text = l == 0 ? cols_groups[i].first.first : cols_groups[i].first.second;\n@@ -94,7 +93,7 @@ void Terminal\n}\n// print line 4 of the table\n- stream << comment_tag;\n+ stream << rang::format::comment;\nfor (unsigned i = 0; i < cols_groups.size(); i++)\n{\nconst unsigned group_width = cols_groups[i].second.size()*(column_width+1)-1; // add a col separator between each exept for the last\n@@ -106,7 +105,7 @@ void Terminal\nstream << std::endl;\n// print line 5 of the table\n- stream << comment_tag;\n+ stream << rang::format::comment;\nfor (unsigned i = 0; i < cols_groups.size(); i++)\n{\nfor (unsigned j = 0; j < cols_groups[i].second.size(); j++)\n@@ -124,7 +123,7 @@ void Terminal\n// print line 6 and 7 of the table (column title lines)\nfor (auto l = 0; l < 2; l++)\n{\n- stream << comment_tag;\n+ stream << rang::format::comment;\nfor (unsigned i = 0; i < cols_groups.size(); i++)\n{\nfor (unsigned j = 0; j < cols_groups[i].second.size(); j++)\n@@ -145,7 +144,7 @@ void Terminal\n}\n// print line 8 of the table\n- stream << comment_tag;\n+ stream << rang::format::comment;\nfor (unsigned i = 0; i < cols_groups.size(); i++)\n{\nfor (unsigned j = 0; j < cols_groups[i].second.size(); j++)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/Terminal.hpp",
"new_path": "src/Tools/Display/Terminal/Terminal.hpp",
"diff": "#include <vector>\n#include <utility>\n#include <string>\n-#include <rang.hpp>\n+\n+#include \"Tools/Display/rang_format/rang_format.h\"\nnamespace aff3ct\n{\n@@ -32,7 +33,6 @@ class Terminal\npublic:\nstatic const char col_separator;\nstatic const char line_separator;\n- static const std::string comment_tag;\nstatic const std::string spaced_scol_separator;\nstatic const std::string spaced_dcol_separator;\nstatic const std::string data_tag;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/rang_format/rang_format.cpp",
"new_path": "src/Tools/Display/rang_format/rang_format.cpp",
"diff": "@@ -27,22 +27,28 @@ std::ostream& format_reset(std::ostream& os)\nreturn os;\n}\n-std::ostream& rang::operator<<(std::ostream& os, const format f)\n+std::ostream& format_comment(std::ostream& os)\n+{\n+ os << rang::style::bold << \"# \" << rang::style::reset;\n+ return os;\n+}\n+\n+std::ostream& rang::operator<<(std::ostream& os, format f)\n{\nswitch (f)\n{\n- case rang::format::error: return format_error (os); break;\n- case rang::format::warning: return format_warning(os); break;\n- case rang::format::info: return format_info (os); break;\n- case rang::format::reset: return format_reset (os); break;\n- default: return os ; break;\n+ case rang::format::error: return format_error (os);\n+ case rang::format::warning: return format_warning(os);\n+ case rang::format::info: return format_info (os);\n+ case rang::format::reset: return format_reset (os);\n+ case rang::format::comment: return format_comment(os);\n}\n}\n-void rang::format_on_each_line(std::ostream& os, const std::string& str, const rang::format f)\n+void rang::format_on_each_line(std::ostream& os, const std::string& str, rang::format f)\n{\nsize_t pos = 0, old_pos = 0;\n- while ((pos = str.find('\\n', old_pos)) != str.npos)\n+ while ((pos = str.find('\\n', old_pos)) != std::string::npos)\n{\nos << f << str.substr(old_pos, pos-old_pos) << format::reset << std::endl;\nold_pos = pos+1;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/rang_format/rang_format.h",
"new_path": "src/Tools/Display/rang_format/rang_format.h",
"diff": "@@ -10,14 +10,15 @@ namespace rang\nenum class format {\nerror = 0,\n- warning = 1,\n- info = 2,\n- reset = 3\n+ warning,\n+ info,\n+ comment,\n+ reset\n};\n-std::ostream& operator<<(std::ostream& os, const format f);\n+std::ostream& operator<<(std::ostream& os, format f);\n-void format_on_each_line(std::ostream& os, const std::string& str, const format f);\n+void format_on_each_line(std::ostream& os, const std::string& str, format f);\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a 'comment' rang format and use it in terminal class, Launcher and Factory::Header class
|
8,483 |
17.04.2018 12:10:45
| -7,200 |
6669bc7713542cf3c139e8ba4539946f4f294ce8
|
Move Noise class in Noise folder; Remove pointless const specifer in arguments
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/Channel.hpp",
"new_path": "src/Module/Channel/Channel.hpp",
"diff": "#include <vector>\n#include \"Module/Module.hpp\"\n-#include \"Tools/Noise.hpp\"\n+#include \"../../Tools/Noise/Noise.hpp\"\nnamespace aff3ct\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/Codec.hpp",
"new_path": "src/Module/Codec/Codec.hpp",
"diff": "#define CODEC_HPP_\n#include \"Tools/Interleaver/Interleaver_core.hpp\"\n-#include \"Tools/Noise.hpp\"\n+#include \"../../Tools/Noise/Noise.hpp\"\n#include \"Factory/Module/Interleaver/Interleaver.hpp\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/Modem.hpp",
"new_path": "src/Module/Modem/Modem.hpp",
"diff": "#include <vector>\n#include \"Module/Module.hpp\"\n-#include \"Tools/Noise.hpp\"\n+#include \"../../Tools/Noise/Noise.hpp\"\nnamespace aff3ct\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.hpp",
"new_path": "src/Simulation/BFER/BFER.hpp",
"diff": "#include \"Tools/Display/Terminal/BFER/Terminal_BFER.hpp\"\n#include \"Tools/Display/Dumper/Dumper.hpp\"\n#include \"Tools/Display/Dumper/Dumper_reduction.hpp\"\n-#include \"Tools/Noise.hpp\"\n+#include \"../../Tools/Noise/Noise.hpp\"\n#include \"Module/Module.hpp\"\n#include \"Module/Monitor/Monitor.hpp\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/EXIT/EXIT.hpp",
"new_path": "src/Simulation/EXIT/EXIT.hpp",
"diff": "#include \"Module/Monitor/EXIT/Monitor_EXIT.hpp\"\n#include \"Tools/Display/Terminal/EXIT/Terminal_EXIT.hpp\"\n-#include \"Tools/Noise.hpp\"\n+#include \"../../Tools/Noise/Noise.hpp\"\n#include \"Factory/Simulation/EXIT/EXIT.hpp\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/BFER/Terminal_BFER.hpp",
"new_path": "src/Tools/Display/Terminal/BFER/Terminal_BFER.hpp",
"diff": "#include <chrono>\n#include \"Module/Monitor/BFER/Monitor_BFER.hpp\"\n-#include \"Tools/Noise.hpp\"\n+#include \"../../../Noise/Noise.hpp\"\n#include \"../Terminal.hpp\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/EXIT/Terminal_EXIT.hpp",
"new_path": "src/Tools/Display/Terminal/EXIT/Terminal_EXIT.hpp",
"diff": "#include <iostream>\n#include \"Module/Monitor/EXIT/Monitor_EXIT.hpp\"\n-#include \"Tools/Noise.hpp\"\n+#include \"../../../Noise/Noise.hpp\"\n#include \"../Terminal.hpp\"\n"
},
{
"change_type": "DELETE",
"old_path": "src/Tools/Noise.hpp",
"new_path": null,
"diff": "-#ifndef NOISE_HPP__\n-#define NOISE_HPP__\n-\n-#include <utility>\n-#include <string>\n-#include <limits>\n-\n-namespace aff3ct\n-{\n-namespace tools\n-{\n-\n-enum class Noise_type : uint8_t{ SIGMA, ROP, EP }; // Sigma (SNR variance), Received optical power, Erasure Probability\n-\n-template <typename R = float>\n-class Noise\n-{\n-public:\n- static const R erased_symbol_val;\n- static const R erased_llr_val;\n-\n-public:\n- Noise();\n- explicit Noise(const R noise, const Noise_type t = Noise_type::SIGMA);\n- Noise(const Noise<R>& other);\n- Noise(Noise<R>&& other);\n- ~Noise();\n-\n- bool is_set () const throw();\n- bool has_type () const throw();\n- bool has_noise() const throw();\n-\n- Noise_type get_type () const; // return the noise type, throw if not set\n- R get_noise() const; // return the stocked noise, throw if not set\n- R get_sigma() const; // return the noise as SIGMA type and has been set, throw if it is not\n- R get_rop () const; // return the noise as ROP type and has been set, throw if it is not\n- R get_ep () const; // return the noise as EP type and has been set, throw if it is not\n-\n- const R get_ebn0() const; // return EB/N0 when the noise is of SIGMA type and has been set, throw if it is not\n- const R get_esn0() const; // return ES/N0 when the noise is of SIGMA type and has been set, throw if it is not\n-\n- void set_noise(const R noise, const Noise_type t = Noise_type::SIGMA);\n- void set_rop (const R rop ); // set the noise and its type as ROP\n- void set_ep (const R ep ); // set the noise and its type as EP\n- void set_sigma(const R sigma); // set the noise and its type as SIGMA\n- void set_sigma(const R sigma, const R ebn0, const R esn0); // set the noise and its type as SIGMA\n- // set also EB/N0 and ES/N0\n-\n- static Noise_type str2type(const std::string& str);\n- static std::string type2str(const Noise_type& t);\n-\n- Noise& operator=(const Noise<R>& other);\n- Noise& operator=(Noise<R>&& other);\n-\n-protected:\n- std::pair<Noise_type, bool> _t;\n- std::pair<R, bool> _n;\n- std::pair<R, bool> _ebn0;\n- std::pair<R, bool> _esn0;\n-\n- void check();\n-\n- void set_n(const R n);\n- void set_t(const Noise_type t);\n-\n- void init();\n-};\n-\n-}\n-}\n-\n-#endif // NOISE_HPP__\n\\ No newline at end of file\n"
},
{
"change_type": "RENAME",
"old_path": "src/Tools/Noise.cpp",
"new_path": "src/Tools/Noise/Noise.cpp",
"diff": "@@ -20,7 +20,7 @@ Noise()\ntemplate <typename R>\nNoise<R>::\n-Noise(const R noise, const Noise_type t)\n+Noise(R noise, Noise_type t)\n{\ninit();\nset_noise(noise, t);\n@@ -77,21 +77,21 @@ Noise<R>::\ntemplate <typename R>\nbool Noise<R>::\n-is_set() const throw()\n+is_set() const noexcept\n{\nreturn has_type() && has_noise();\n}\ntemplate <typename R>\nbool Noise<R>::\n-has_type() const throw()\n+has_type() const noexcept\n{\nreturn _t.second;\n}\ntemplate <typename R>\nbool Noise<R>::\n-has_noise() const throw()\n+has_noise() const noexcept\n{\nreturn _n.second;\n}\n@@ -246,7 +246,7 @@ set_noise(const R noise, const Noise_type t)\ntemplate <typename R>\nvoid Noise<R>::\n-set_rop(const R rop)\n+set_rop(R rop)\n{\nset_n(rop);\nset_t(Noise_type::ROP);\n@@ -255,7 +255,7 @@ set_rop(const R rop)\ntemplate <typename R>\nvoid Noise<R>::\n-set_ep(const R ep)\n+set_ep(R ep)\n{\nset_n(ep);\nset_t(Noise_type::EP);\n@@ -264,7 +264,7 @@ set_ep(const R ep)\ntemplate <typename R>\nvoid Noise<R>::\n-set_sigma(const R sigma)\n+set_sigma(R sigma)\n{\nset_n(sigma);\nset_t(Noise_type::SIGMA);\n@@ -275,7 +275,7 @@ set_sigma(const R sigma)\ntemplate <typename R>\nvoid Noise<R>::\n-set_sigma(const R sigma, const R ebn0, const R esn0)\n+set_sigma(R sigma, R ebn0, R esn0)\n{\nset_n(sigma);\nset_t(Noise_type::SIGMA);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Move Noise class in Noise folder; Remove pointless const specifer in arguments
|
8,483 |
17.04.2018 12:11:04
| -7,200 |
19878ba791f98a631ff419d8161b3254beea908e
|
Add the noise.hpp file
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Noise/Noise.hpp",
"diff": "+#ifndef NOISE_HPP__\n+#define NOISE_HPP__\n+\n+#include \"../../../../../../../../../../usr/include/c++/5/utility\"\n+#include \"../../../../../../../../../../usr/include/c++/5/string\"\n+#include \"../../../../../../../../../../usr/include/c++/5/limits\"\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+\n+enum class Noise_type : uint8_t{ SIGMA, ROP, EP }; // Sigma (SNR variance), Received optical power, Erasure Probability\n+\n+template <typename R = float>\n+class Noise\n+{\n+public:\n+ static const R erased_symbol_val;\n+ static const R erased_llr_val;\n+\n+public:\n+ Noise();\n+ explicit Noise(R noise, Noise_type t = Noise_type::SIGMA);\n+ Noise(const Noise<R>& other);\n+ Noise(Noise<R>&& other);\n+ ~Noise();\n+\n+ bool is_set () const noexcept;\n+ bool has_type () const noexcept;\n+ bool has_noise() const noexcept;\n+\n+ Noise_type get_type () const; // return the noise type, throw if not set\n+ R get_noise() const; // return the stocked noise, throw if not set\n+ R get_sigma() const; // return the noise as SIGMA type and has been set, throw if it is not\n+ R get_rop () const; // return the noise as ROP type and has been set, throw if it is not\n+ R get_ep () const; // return the noise as EP type and has been set, throw if it is not\n+\n+ const R get_ebn0() const; // return EB/N0 when the noise is of SIGMA type and has been set, throw if it is not\n+ const R get_esn0() const; // return ES/N0 when the noise is of SIGMA type and has been set, throw if it is not\n+\n+ void set_noise(R noise, Noise_type t = Noise_type::SIGMA);\n+ void set_rop (R rop ); // set the noise and its type as ROP\n+ void set_ep (R ep ); // set the noise and its type as EP\n+ void set_sigma(R sigma); // set the noise and its type as SIGMA\n+ void set_sigma(R sigma, R ebn0, R esn0); // set the noise and its type as SIGMA\n+ // set also EB/N0 and ES/N0\n+\n+ static Noise_type str2type(const std::string& str);\n+ static std::string type2str(const Noise_type& t);\n+\n+ Noise& operator=(const Noise<R>& other);\n+ Noise& operator=(Noise<R>&& other);\n+\n+protected:\n+ std::pair<Noise_type, bool> _t;\n+ std::pair<R, bool> _n;\n+ std::pair<R, bool> _ebn0;\n+ std::pair<R, bool> _esn0;\n+\n+ void check();\n+\n+ void set_n(R n);\n+ void set_t(Noise_type t);\n+\n+ void init();\n+};\n+\n+}\n+}\n+\n+#endif // NOISE_HPP__\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add the noise.hpp file
|
8,488 |
17.04.2018 17:14:58
| -7,200 |
7a9056e21cc01ef6854e40958e16e2324a54ed41
|
Raise an error if no export type is given.
|
[
{
"change_type": "MODIFY",
"old_path": "scripts/debug_parser/aff3ct_debug_parser.py",
"new_path": "scripts/debug_parser/aff3ct_debug_parser.py",
"diff": "@@ -219,6 +219,10 @@ def adp_parse_args():\nparser.add_argument(\"-o\", \"--output\", type=str, help=\"path to the output folder\", default=\"./\")\nargs = parser.parse_args()\n+\n+ if not (args.txt or args.bin or args.src):\n+ parser.error('At least one of the export types is required (e.g. --txt)')\n+\nreturn args\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Raise an error if no export type is given.
|
8,488 |
17.04.2018 17:34:01
| -7,200 |
249d94daba2036431d72852f09704a3acbb50654
|
Check that given output path is a directory.
|
[
{
"change_type": "MODIFY",
"old_path": "scripts/debug_parser/aff3ct_debug_parser.py",
"new_path": "scripts/debug_parser/aff3ct_debug_parser.py",
"diff": "@@ -206,6 +206,12 @@ def check_positive(value):\nreturn ivalue\n+def check_directory(value):\n+ if not os.path.isdir(value):\n+ raise argparse.ArgumentTypeError(\"%s is not a directory\" % value)\n+ return value\n+\n+\ndef adp_parse_args():\nparser = argparse.ArgumentParser()\n@@ -216,7 +222,7 @@ def adp_parse_args():\nparser.add_argument(\"--bin\", help=\"export as bin\", action='store_true')\nparser.add_argument(\"--src\", help=\"export as c source\", action='store_true')\nparser.add_argument(\"--fra\", type=check_positive, help=\"export a single frame, whose index is specified\")\n- parser.add_argument(\"-o\", \"--output\", type=str, help=\"path to the output folder\", default=\"./\")\n+ parser.add_argument(\"-o\", \"--output\", type=check_directory, help=\"path to the output folder\", default=\"./\")\nargs = parser.parse_args()\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Check that given output path is a directory.
|
8,483 |
18.04.2018 08:37:29
| -7,200 |
87d52b07d076f6a214c648c2b560113a2a669b62
|
Renaming rang::format into rang::tag
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Command_parser.cpp",
"new_path": "src/Factory/Command_parser.cpp",
"diff": "@@ -72,7 +72,7 @@ void Command_parser\nstd::string message = \"For more information please display the help (\\\"\";\nmessage += tools::Argument_handler::print_tag(Command_parser::help_tag) += \"\\\").\";\n- err_stream << rang::format::info << message << rang::format::reset << std::endl << std::endl;\n+ err_stream << rang::tag::info << message << rang::tag::reset << std::endl << std::endl;\n}\n}\n@@ -80,14 +80,14 @@ void Command_parser\n::print_errors()\n{\nfor (size_t e = 0; e < errors.size(); e++)\n- err_stream << rang::format::error << errors[e] << rang::format::reset << std::endl;\n+ err_stream << rang::tag::error << errors[e] << rang::tag::reset << std::endl;\n}\nvoid Command_parser\n::print_warnings()\n{\nfor (size_t w = 0; w < warnings.size(); w++)\n- err_stream << rang::format::warning << warnings[w] << rang::format::reset << std::endl;\n+ err_stream << rang::tag::warning << warnings[w] << rang::tag::reset << std::endl;\n}\nbool Command_parser\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Factory.cpp",
"new_path": "src/Factory/Factory.cpp",
"diff": "@@ -126,13 +126,13 @@ void aff3ct::factory::Header::print_parameters(std::string grp_key, std::string\nif (key.size() == 1)\n{\n- stream << rang::format::comment << \"* \" << rang::style::bold << rang::style::underline << grp_name << rang::style::reset << \" \";\n+ stream << rang::tag::comment << \"* \" << rang::style::bold << rang::style::underline << grp_name << rang::style::reset << \" \";\nfor (auto i = 0; i < 46 - (int)grp_name.length(); i++) std::cout << \"-\";\nstream << std::endl;\n}\nelse if (key.size() > 1)\n{\n- stream << rang::format::comment << \" \" << rang::style::bold << rang::style::underline << grp_name << rang::style::reset << \" \";\n+ stream << rang::tag::comment << \" \" << rang::style::bold << rang::style::underline << grp_name << rang::style::reset << \" \";\nfor (auto i = 0; i < 45 - (int)grp_name.length(); i++) std::cout << \"-\";\nstream << std::endl;\n}\n@@ -142,7 +142,7 @@ void aff3ct::factory::Header::print_parameters(std::string grp_key, std::string\n{\nif (std::find(dup.begin(), dup.end(), header[i].first + header[i].second) == dup.end())\n{\n- stream << rang::format::comment << \" ** \" << rang::style::bold << header[i].first << rang::style::reset;\n+ stream << rang::tag::comment << \" ** \" << rang::style::bold << header[i].first << rang::style::reset;\nfor (auto j = 0; j < max_n_chars - (int)header[i].first.length(); j++) stream << \" \";\nstream << \" = \" << header[i].second << std::endl;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Launcher/Launcher.cpp",
"new_path": "src/Launcher/Launcher.cpp",
"diff": "@@ -95,7 +95,7 @@ int Launcher::read_arguments()\n// print the errors\nif (!cmd_error.empty()) std::cerr << std::endl;\nfor (unsigned e = 0; e < cmd_error.size(); e++)\n- std::cerr << rang::format::error << cmd_error[e] << rang::format::reset << std::endl;\n+ std::cerr << rang::tag::error << cmd_error[e] << rang::tag::reset << std::endl;\n// print the help tags\nif (!cmd_error.empty() && !params_common.display_help)\n@@ -105,7 +105,7 @@ int Launcher::read_arguments()\nstd::string message = \"For more information please display the help (\\\"\";\nmessage += tools::Argument_handler::print_tag(help_tag) += \"\\\").\";\n- std::cerr << std::endl << rang::format::info << message << rang::format::reset << std::endl;\n+ std::cerr << std::endl << rang::tag::info << message << rang::tag::reset << std::endl;\n}\nreturn (!cmd_error.empty() || params_common.display_help) ? EXIT_FAILURE : EXIT_SUCCESS;\n@@ -114,12 +114,12 @@ int Launcher::read_arguments()\nvoid Launcher::print_header()\n{\n// display configuration and simulation parameters\n- stream << rang::format::comment << rang::style::bold << \"----------------------------------------------------\" << std::endl;\n- stream << rang::format::comment << rang::style::bold << \"---- A FAST FORWARD ERROR CORRECTION TOOLBOX >> ----\" << std::endl;\n- stream << rang::format::comment << rang::style::bold << \"----------------------------------------------------\" << std::endl;\n- stream << rang::format::comment << rang::style::bold << rang::style::underline << \"Parameters :\"<< rang::style::reset << std::endl;\n+ stream << rang::tag::comment << rang::style::bold << \"----------------------------------------------------\" << std::endl;\n+ stream << rang::tag::comment << rang::style::bold << \"---- A FAST FORWARD ERROR CORRECTION TOOLBOX >> ----\" << std::endl;\n+ stream << rang::tag::comment << rang::style::bold << \"----------------------------------------------------\" << std::endl;\n+ stream << rang::tag::comment << rang::style::bold << rang::style::underline << \"Parameters :\"<< rang::style::reset << std::endl;\nfactory::Header::print_parameters({¶ms_common}, false, this->stream);\n- this->stream << rang::format::comment << std::endl;\n+ this->stream << rang::tag::comment << std::endl;\n}\nint Launcher::launch()\n@@ -142,7 +142,7 @@ int Launcher::launch()\nif (this->params_common.mpi_rank == 0)\n#endif\nfor (unsigned w = 0; w < this->cmd_warn.size(); w++)\n- std::clog << rang::format::warning << this->cmd_warn[w] << rang::format::reset << std::endl;\n+ std::clog << rang::tag::warning << this->cmd_warn[w] << rang::tag::reset << std::endl;\nreturn EXIT_FAILURE;\n}\n@@ -170,7 +170,7 @@ int Launcher::launch()\nif (this->params_common.mpi_rank == 0)\n#endif\nfor (unsigned w = 0; w < this->cmd_warn.size(); w++)\n- std::clog << rang::format::warning << this->cmd_warn[w] << rang::format::reset << std::endl;\n+ std::clog << rang::tag::warning << this->cmd_warn[w] << rang::tag::reset << std::endl;\ntry\n{\n@@ -178,7 +178,7 @@ int Launcher::launch()\n}\ncatch(const std::exception& e)\n{\n- rang::format_on_each_line(std::cerr, std::string(e.what()) + \"\\n\", rang::format::error);\n+ rang::format_on_each_line(std::cerr, std::string(e.what()) + \"\\n\", rang::tag::error);\nexit_code = EXIT_FAILURE;\n}\n@@ -189,7 +189,7 @@ int Launcher::launch()\n#ifdef ENABLE_MPI\nif (this->params_common.mpi_rank == 0)\n#endif\n- stream << rang::format::comment << \"The simulation is running...\" << std::endl;\n+ stream << rang::tag::comment << \"The simulation is running...\" << std::endl;\ntry\n{\n@@ -199,7 +199,7 @@ int Launcher::launch()\n}\ncatch(const std::exception& e)\n{\n- rang::format_on_each_line(std::cerr, std::string(e.what()) + \"\\n\", rang::format::error);\n+ rang::format_on_each_line(std::cerr, std::string(e.what()) + \"\\n\", rang::tag::error);\nexit_code = EXIT_FAILURE;\n}\n}\n@@ -208,7 +208,7 @@ int Launcher::launch()\n#ifdef ENABLE_MPI\nif (this->params_common.mpi_rank == 0)\n#endif\n- stream << rang::format::comment << \"End of the simulation.\" << std::endl;\n+ stream << rang::tag::comment << \"End of the simulation.\" << std::endl;\nif (simu != nullptr)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/CRC/Polynomial/CRC_polynomial.cpp",
"new_path": "src/Module/CRC/Polynomial/CRC_polynomial.cpp",
"diff": "@@ -32,10 +32,10 @@ CRC_polynomial<B>\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, \"Please specify the CRC 'size'.\");\nif (!crc_name.empty() && CRC_polynomial<B>::get_size(crc_name) != this->size)\n- std::clog << rang::format::warning << \"You specified \\\"\" << this->size\n+ std::clog << rang::tag::warning << \"You specified \\\"\" << this->size\n<< \" bits\\\" for your CRC size but the database advise you to use \\\"\"\n<< std::get<1>(known_polynomials.at(crc_name))\n- << \" bits\\\", are you sure?\" << rang::format::reset << std::endl;\n+ << \" bits\\\", are you sure?\" << rang::tag::reset << std::endl;\npolynomial.push_back(1);\nfor (auto i = 0; i < this->size; i++)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.cpp",
"new_path": "src/Simulation/BFER/BFER.cpp",
"diff": "@@ -241,7 +241,7 @@ void BFER<B,R,Q>\nmodule::Monitor::stop();\nterminal->final_report(std::cout); // display final report to not lost last line overwritten by the error messages\n- rang::format_on_each_line(std::cerr, std::string(e.what()) + \"\\n\", rang::format::error);\n+ rang::format_on_each_line(std::cerr, std::string(e.what()) + \"\\n\", rang::tag::error);\nthis->simu_error = true;\n}\n@@ -347,7 +347,7 @@ void BFER<B,R,Q>\nif (std::find(simu->prev_err_messages.begin(), simu->prev_err_messages.end(), msg) == simu->prev_err_messages.end())\n{\n// with backtrace if debug mode\n- rang::format_on_each_line(std::cerr, std::string(e.what()) + \"\\n\", rang::format::error);\n+ rang::format_on_each_line(std::cerr, std::string(e.what()) + \"\\n\", rang::tag::error);\nsimu->prev_err_messages.push_back(msg); // save only the function signature\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/Iterative/Threads/BFER_ite_threads.cpp",
"new_path": "src/Simulation/BFER/Iterative/Threads/BFER_ite_threads.cpp",
"diff": "@@ -23,9 +23,9 @@ BFER_ite_threads<B,R,Q>\nif (this->params_BFER_ite.err_track_revert)\n{\nif (this->params_BFER_ite.n_threads != 1)\n- std::clog << rang::format::warning << \"Multi-threading detected with error tracking revert feature! \"\n+ std::clog << rang::tag::warning << \"Multi-threading detected with error tracking revert feature! \"\n\"Each thread will play the same frames. Please run with one thread.\"\n- << rang::format::reset << std::endl;\n+ << rang::tag::reset << std::endl;\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/Standard/Threads/BFER_std_threads.cpp",
"new_path": "src/Simulation/BFER/Standard/Threads/BFER_std_threads.cpp",
"diff": "@@ -23,9 +23,9 @@ BFER_std_threads<B,R,Q>\nif (this->params_BFER_std.err_track_revert)\n{\nif (this->params_BFER_std.n_threads != 1)\n- std::clog << rang::format::warning << \"Multi-threading detected with error tracking revert feature! \"\n+ std::clog << rang::tag::warning << \"Multi-threading detected with error tracking revert feature! \"\n\"Each thread will play the same frames. Please run with one thread.\"\n- << rang::format::reset << std::endl;\n+ << rang::tag::reset << std::endl;\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/Polar/nodes_parser.hxx",
"new_path": "src/Tools/Code/Polar/nodes_parser.hxx",
"diff": "@@ -197,8 +197,8 @@ std::vector<aff3ct::tools::Pattern_polar_i*> aff3ct::tools\n}\nelse\n{\n- std::clog << rang::format::warning << \"Unrecognized Polar node type (\" << v_polar[i] << \").\"\n- << rang::format::reset << std::endl;\n+ std::clog << rang::tag::warning << \"Unrecognized Polar node type (\" << v_polar[i] << \").\"\n+ << rang::tag::reset << std::endl;\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Statistics/Statistics.cpp",
"new_path": "src/Tools/Display/Statistics/Statistics.cpp",
"diff": "@@ -290,8 +290,8 @@ void Statistics\nelse\n{\nstream << \"# \"\n- << rang::format::info << \"Statistics are unavailable. Did you enable the statistics in the tasks?\"\n- << rang::format::reset << std::endl;\n+ << rang::tag::info << \"Statistics are unavailable. Did you enable the statistics in the tasks?\"\n+ << rang::tag::reset << std::endl;\n}\n}\n@@ -437,7 +437,7 @@ void Statistics\nelse\n{\nstream << \"# \"\n- << rang::format::info << \"Statistics are unavailable. Did you enable the statistics in the tasks?\"\n- << rang::format::reset << std::endl;\n+ << rang::tag::info << \"Statistics are unavailable. Did you enable the statistics in the tasks?\"\n+ << rang::tag::reset << std::endl;\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/Terminal.cpp",
"new_path": "src/Tools/Display/Terminal/Terminal.cpp",
"diff": "@@ -59,7 +59,7 @@ void Terminal\n// indice (7.2) is \"cols_groups[1].second[2].second\"\n// print line 1 of the table\n- stream << rang::format::comment;\n+ stream << rang::tag::comment;\nfor (unsigned i = 0; i < cols_groups.size(); i++)\n{\nconst unsigned group_width = cols_groups[i].second.size()*(column_width+1)-1; // add a col separator between each exept for the last\n@@ -73,7 +73,7 @@ void Terminal\n// print line 2 and 3 of the table (group title lines)\nfor (auto l = 0; l < 2; l++)\n{\n- stream << rang::format::comment;\n+ stream << rang::tag::comment;\nfor (unsigned i = 0; i < cols_groups.size(); i++)\n{\nconst auto& text = l == 0 ? cols_groups[i].first.first : cols_groups[i].first.second;\n@@ -93,7 +93,7 @@ void Terminal\n}\n// print line 4 of the table\n- stream << rang::format::comment;\n+ stream << rang::tag::comment;\nfor (unsigned i = 0; i < cols_groups.size(); i++)\n{\nconst unsigned group_width = cols_groups[i].second.size()*(column_width+1)-1; // add a col separator between each exept for the last\n@@ -105,7 +105,7 @@ void Terminal\nstream << std::endl;\n// print line 5 of the table\n- stream << rang::format::comment;\n+ stream << rang::tag::comment;\nfor (unsigned i = 0; i < cols_groups.size(); i++)\n{\nfor (unsigned j = 0; j < cols_groups[i].second.size(); j++)\n@@ -123,7 +123,7 @@ void Terminal\n// print line 6 and 7 of the table (column title lines)\nfor (auto l = 0; l < 2; l++)\n{\n- stream << rang::format::comment;\n+ stream << rang::tag::comment;\nfor (unsigned i = 0; i < cols_groups.size(); i++)\n{\nfor (unsigned j = 0; j < cols_groups[i].second.size(); j++)\n@@ -144,7 +144,7 @@ void Terminal\n}\n// print line 8 of the table\n- stream << rang::format::comment;\n+ stream << rang::tag::comment;\nfor (unsigned i = 0; i < cols_groups.size(); i++)\n{\nfor (unsigned j = 0; j < cols_groups[i].second.size(); j++)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/rang_format/rang_format.cpp",
"new_path": "src/Tools/Display/rang_format/rang_format.cpp",
"diff": "@@ -33,26 +33,28 @@ std::ostream& format_comment(std::ostream& os)\nreturn os;\n}\n-std::ostream& rang::operator<<(std::ostream& os, format f)\n+std::ostream& rang::operator<<(std::ostream& os, tag f)\n{\nswitch (f)\n{\n- case rang::format::error: return format_error (os);\n- case rang::format::warning: return format_warning(os);\n- case rang::format::info: return format_info (os);\n- case rang::format::reset: return format_reset (os);\n- case rang::format::comment: return format_comment(os);\n+ case rang::tag::error: return format_error (os);\n+ case rang::tag::warning: return format_warning(os);\n+ case rang::tag::info: return format_info (os);\n+ case rang::tag::reset: return format_reset (os);\n+ case rang::tag::comment: return format_comment(os);\n}\n+\n+ return os;\n}\n-void rang::format_on_each_line(std::ostream& os, const std::string& str, rang::format f)\n+void rang::format_on_each_line(std::ostream& os, const std::string& str, rang::tag f)\n{\nsize_t pos = 0, old_pos = 0;\nwhile ((pos = str.find('\\n', old_pos)) != std::string::npos)\n{\n- os << f << str.substr(old_pos, pos-old_pos) << format::reset << std::endl;\n+ os << f << str.substr(old_pos, pos-old_pos) << tag::reset << std::endl;\nold_pos = pos+1;\n}\nif (!str.substr(old_pos, pos-old_pos).empty())\n- os << f << str.substr(old_pos, pos-old_pos) << format::reset;\n+ os << f << str.substr(old_pos, pos-old_pos) << tag::reset;\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/rang_format/rang_format.h",
"new_path": "src/Tools/Display/rang_format/rang_format.h",
"diff": "namespace rang\n{\n-enum class format {\n+enum class tag {\nerror = 0,\nwarning,\ninfo,\n@@ -16,9 +16,9 @@ enum class format {\nreset\n};\n-std::ostream& operator<<(std::ostream& os, format f);\n+std::ostream& operator<<(std::ostream& os, tag f);\n-void format_on_each_line(std::ostream& os, const std::string& str, format f);\n+void format_on_each_line(std::ostream& os, const std::string& str, tag f);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/main.cpp",
"new_path": "src/main.cpp",
"diff": "@@ -112,11 +112,11 @@ int read_arguments(const int argc, const char** argv, factory::Launcher::paramet\nif (cmd_error.size()) std::cerr << std::endl;\nfor (auto w = 0; w < (int)cmd_error.size(); w++)\n- std::cerr << rang::format::error << cmd_error[w] << rang::format::reset << std::endl;\n+ std::cerr << rang::tag::error << cmd_error[w] << rang::tag::reset << std::endl;\nif (cmd_warn.size()) std::cerr << std::endl;\nfor (auto w = 0; w < (int)cmd_warn.size(); w++)\n- std::cerr << rang::format::warning << cmd_warn[w] << rang::format::reset << std::endl;\n+ std::cerr << rang::tag::warning << cmd_warn[w] << rang::tag::reset << std::endl;\n}\nreturn (cmd_error.size() || display_help) ? EXIT_FAILURE : EXIT_SUCCESS;\n}\n@@ -161,7 +161,7 @@ int sc_main(int argc, char **argv)\n}\ncatch(std::exception const& e)\n{\n- rang::format_on_each_line(std::cerr, std::string(e.what()) + \"\\n\", rang::format::error);\n+ rang::format_on_each_line(std::cerr, std::string(e.what()) + \"\\n\", rang::tag::error);\n}\n#ifdef ENABLE_MPI\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Renaming rang::format into rang::tag
|
8,483 |
18.04.2018 08:48:14
| -7,200 |
853c87dab556fff00fce89aea688c484d2c70de1
|
Fix the CPM noise checker before generating the projection matrix
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/CPM/Modem_CPM.hxx",
"new_path": "src/Module/Modem/CPM/Modem_CPM.hxx",
"diff": "@@ -87,7 +87,7 @@ Modem_CPM<B,R,Q,MAX>\ngenerate_baseband();\n- if (no_sig2 || this->n->is_set())\n+ if (no_sig2 || (this->n != nullptr && this->n->is_set()))\ngenerate_projection();\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/Modem.hxx",
"new_path": "src/Module/Modem/Modem.hxx",
"diff": "@@ -51,7 +51,7 @@ Modem(const int N, const int N_mod, const int N_fil, const tools::Noise<R>& nois\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- if (noise.is_set()) this->set_noise(noise);\n+ if (noise.has_noise()) this->set_noise(noise);\nthis->init_processes();\n}\n@@ -79,7 +79,7 @@ Modem(const int N, const int N_mod, const tools::Noise<R>& noise, const int n_fr\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- if (noise.is_set()) this->set_noise(noise);\n+ if (noise.has_noise()) this->set_noise(noise);\nthis->init_processes();\n}\n@@ -100,7 +100,7 @@ Modem(const int N, const tools::Noise<R>& noise, const int n_frames)\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- if (noise.is_set()) this->set_noise(noise);\n+ if (noise.has_noise()) this->set_noise(noise);\nthis->init_processes();\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix the CPM noise checker before generating the projection matrix
|
8,483 |
18.04.2018 09:37:03
| -7,200 |
a3695c1abfc7b4b88d6cbcd9b8329ad2fea46eb9
|
Fix rang::format to rang::tag in MPI
|
[
{
"change_type": "MODIFY",
"old_path": "src/Simulation/EXIT/EXIT.cpp",
"new_path": "src/Simulation/EXIT/EXIT.cpp",
"diff": "@@ -31,8 +31,8 @@ EXIT<B,R>\nterminal (nullptr)\n{\n#ifdef ENABLE_MPI\n- std::clog << rang::format::warning << \"This simulation is not MPI ready, the same computations will be launched \"\n- \"on each MPI processes.\" << rang::format::reset << std::endl;\n+ std::clog << rang::tag::warning << \"This simulation is not MPI ready, the same computations will be launched \"\n+ \"on each MPI processes.\" << std::endl;\n#endif\nif (params_EXIT.n_threads > 1)\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix rang::format to rang::tag in MPI
|
8,483 |
18.04.2018 14:28:13
| -7,200 |
f309f71092c760562454edaf035fea39296c7434
|
Fix generate range when only one value
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/general_utils.cpp",
"new_path": "src/Tools/general_utils.cpp",
"diff": "@@ -126,6 +126,7 @@ R aff3ct::tools::ebn0_to_esn0(const R ebn0, const R bit_rate, const int bps)\nreturn esn0;\n}\n+#include <iostream>\ntemplate <typename R>\nstd::vector<R> aff3ct::tools::generate_range(const std::vector<std::vector<R>>& range_description, const R default_step)\n{\n@@ -137,7 +138,7 @@ std::vector<R> aff3ct::tools::generate_range(const std::vector<std::vector<R>>&\n{\nif (s.size() == 1)\n{\n- range.push_back(s.front());\n+ range.push_back(s.front() * float_precision);\ncontinue;\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix generate range when only one value
|
8,483 |
18.04.2018 17:30:51
| -7,200 |
abe4e8bc3c628bd0592530c372069cff91fcc7a9
|
Modify test regression to handle several noise types and data to check
|
[
{
"change_type": "MODIFY",
"old_path": "ci/test-regression.py",
"new_path": "ci/test-regression.py",
"diff": "@@ -10,6 +10,7 @@ import time\nimport pathlib\nimport argparse\nimport subprocess\n+import numpy as np\n# ==================================================================== PACKAGES\n# =============================================================================\n@@ -32,12 +33,19 @@ parser.add_argument('--verbose', action='store', dest='verbose', ty\n# supported file extensions (filename suffix)\nextensions = ['.txt', '.perf', '.data', '.dat']\n+NoiseTypeList = [\"Eb/N0\", \"Es/N0\", \"ROP\", \"EP\"]\n+\n# ================================================================== PARAMETERS\n# =============================================================================\n# =============================================================================\n# =================================================================== FUNCTIONS\n+def format_e(n):\n+ a = '%.2e' % n\n+ return a\n+ # return a.split('E')[0].rstrip('0').rstrip('.') + 'E' + a.split('E')[1]\n+\ndef getFileNames(currentPath, fileNames):\nif os.path.isdir(currentPath):\n@@ -68,7 +76,296 @@ def getFileNames(currentPath, fileNames):\nelse:\nprint(\"# (WW) The path '\", currentPath, \"' does not exist.\")\n-# -----\n+def getLegend(line):\n+ line = line.replace(\"#\", \"\")\n+ line = line.replace(\"||\", \"|\")\n+ line = line.split('|')\n+ for i in range(len(line)):\n+ line[i] = line[i].strip()\n+\n+ return line\n+\n+def getVal(line):\n+ line = line.replace(\"#\", \"\")\n+ line = line.replace(\"||\", \"|\")\n+ line = line.split('|')\n+\n+ valLine = []\n+ for i in range(len(line)):\n+ val = float(0.0)\n+\n+ try:\n+ val = float(line[i])\n+\n+ if \"inf\" in str(val):\n+ val = float(0.0)\n+\n+ except ValueError:\n+ pass\n+\n+ valLine.append(val)\n+\n+ return valLine\n+\n+def getLegendIdx(legend, colName):\n+ for i in range(len(legend)):\n+ if legend[i] == colName:\n+ return i\n+ return -1\n+\n+class simuData:\n+ def __init__(self):\n+ self.Legend = []\n+ self.All = []\n+ self.Noise = []\n+ self.BER = []\n+ self.FER = []\n+ self.MI = []\n+ self.RunCommand = \"\"\n+ self.CurveName = \"\"\n+ self.NoiseType = \"\"\n+\n+def dataReader(aff3ctOutput):\n+ data = simuData()\n+\n+ for line in aff3ctOutput:\n+ if line.startswith(\"#\"):\n+ if len(line) > 20 and (line.find(\"FRA |\") != -1 or line.find(\"BER |\") != -1 or line.find(\"FER |\") != -1):\n+ data.Legend = getLegend(line)\n+\n+ else:\n+ if len(data.Legend) != 0:\n+ d = getVal(line)\n+ if len(d) == len(data.Legend):\n+ data.All.append(d)\n+\n+\n+ data.All = np.array(data.All).transpose()\n+\n+ # get the command to to run to reproduce this trace\n+ if len(aff3ctOutput) >= 2 and \"Run command:\" in aff3ctOutput[0]:\n+ data.RunCommand = str(aff3ctOutput[1].strip())\n+ elif len(aff3ctOutput) >= 4 and \"Run command:\" in aff3ctOutput[2]:\n+ data.RunCommand = str(aff3ctOutput[3].strip())\n+ else:\n+ data.RunCommand = \"\"\n+\n+ # get the curve name (if there is one)\n+ if len(lines) >= 2 and \"Curve name:\" in lines[0]:\n+ data.CurveName = str(lines[1].strip())\n+ elif len(lines) >= 4 and \"Curve name:\" in lines[2]:\n+ data.CurveName = str(lines[3].strip())\n+ else:\n+ data.CurveName = \"\"\n+\n+\n+ # find the type of noise used in this simulation\n+ idx = -1\n+ for n in NoiseTypeList:\n+ idx = getLegendIdx(data.Legend, n)\n+ if idx != -1:\n+ data.NoiseType = n\n+ break\n+\n+ if len(data.All) and idx != -1 :\n+ # set noise range\n+ data.Noise = data.All[idx]\n+\n+ # set BER\n+ idx = getLegendIdx(data.Legend, \"BER\")\n+ if idx == -1:\n+ data.BER = [0 for x in range(len(data.Noise))]\n+ else:\n+ data.BER = data.All[idx]\n+\n+ # set FER\n+ idx = getLegendIdx(data.Legend, \"FER\")\n+ if idx == -1:\n+ data.FER = [0 for x in range(len(data.Noise))]\n+ else:\n+ data.FER = data.All[idx]\n+\n+ # set MI\n+ idx = getLegendIdx(data.Legend, \"MI\")\n+ if idx == -1:\n+ data.MI = []\n+ else:\n+ data.MI = data.All[idx]\n+\n+ return data\n+\n+def splitAsCommand(runCommand):\n+ # split the run command\n+ argsList = [\"\"]\n+ idx = 0\n+\n+ new = 0\n+ found_dashes = 0\n+ for s in runCommand:\n+ if found_dashes == 0:\n+ if s == ' ':\n+ if new == 0:\n+ argsList.append(\"\")\n+ idx = idx + 1\n+ new = 1\n+\n+ elif s == '\\\"':\n+ if new == 0:\n+ argsList.append(\"\")\n+ idx = idx + 1\n+ new = 1\n+ found_dashes = 1\n+\n+ else:\n+ argsList[idx] += s\n+ new = 0\n+\n+ else: # between dashes\n+ if s == '\\\"':\n+ argsList.append(\"\")\n+ idx = idx + 1\n+ found_dashes = 0\n+\n+ else:\n+ argsList[idx] += s\n+\n+ del argsList[idx]\n+\n+ return argsList\n+\n+class tableStats:\n+ def __init__(self, tableCur, tableRef, sensibility, name):\n+ if len(tableCur) > len(tableRef) : # can't have less ref than checked points\n+ raise RuntimeError\n+\n+ self.tableCur = tableCur\n+ self.tableRef = tableRef\n+ self.name = name\n+ self.sensibility = sensibility\n+ self.minSensibility = 0\n+ self.maxSensibility = 0\n+ self.sumSensibility = 0\n+ self.valid = 0\n+ self.nData = len(tableCur)\n+ self.errorsList = []\n+ self.errorsPos = []\n+ self.errorsMessage = []\n+\n+ for i in range(self.nData):\n+ diff = tableCur[i] - tableRef[i];\n+ absoluteDiff = math.fabs(diff)\n+\n+ if absoluteDiff > self.sensibility:\n+ self.errorsPos .append(i)\n+ self.errorsList .append([tableCur[i], diff])\n+ self.errorsMessage.append(format_e(tableRef[i]))\n+ else:\n+ self.valid += 1\n+\n+ self.sumSensibility += absoluteDiff\n+ self.minSensibility = min(self.minSensibility, absoluteDiff)\n+ self.maxSensibility = max(self.maxSensibility, absoluteDiff)\n+\n+ if self.nData != 0:\n+ self.avgSensibility = self.sumSensibility / float(self.nData)\n+ else:\n+ self.avgSensibility = 0\n+ self.rateSensibility = (self.avgSensibility / self.sensibility) * 100\n+\n+ def errorMessage(self, idx):\n+ if len(self.errorsMessage) > idx and len(self.errorsMessage[idx]):\n+ return self.name + \"=\" + self.errorsMessage[idx]\n+ else:\n+ return \"\"\n+\n+ def hasError(self):\n+ return self.valid != self.nData\n+\n+ def passRate(self):\n+ if self.nData == 0:\n+ raise RuntimeError\n+\n+ return float(self.valid) / float(self.nData)\n+\n+class compStats:\n+ def __init__(self, dataCur, dataRef, sensibility):\n+ if not isinstance(dataCur, simuData) or not isinstance(dataRef, simuData) :\n+ raise TypeError\n+\n+ self.dataCur = dataCur\n+ self.dataRef = dataRef\n+ self.dataList = []\n+ self.dataList.append(tableStats(dataCur.FER, dataRef.FER, sensibility, \"FER\"))\n+ self.dataList.append(tableStats(dataCur.BER, dataRef.BER, sensibility, \"BER\"))\n+ self.dataList.append(tableStats(dataCur.MI, dataRef.MI, sensibility, \"MI\" ))\n+\n+ def errorMessage(self, idx):\n+ message = \"\"\n+ for d in self.dataList:\n+ dm = d.errorMessage(idx)\n+ if len(dm):\n+ message += dm + \" \"\n+\n+ if len(message):\n+ return \"WRONG! \" + message\n+ else:\n+ return \"\"\n+\n+ def getResumeTable(self):\n+ message = \"\"\n+ if len(self.dataCur.Noise) == 0:\n+ return message\n+\n+ message += \"---- Details: first noise point = \" + format_e(self.dataCur.Noise[0]) + \", last noise point = \" + format_e(self.dataCur.Noise[len(self.dataCur.Noise) -1]) + \"\\n\"\n+ message += \"---- name | valid points | sensibility [avg,min,max,rate%] | [first,last] point \\n\"\n+\n+ for d in self.dataList:\n+ if len(d.tableCur):\n+ message += d.name.rjust(9) + \" | \"\n+ message += (str(d.valid) + \"/\" + str(d.nData)).rjust(12) + \" | \"\n+ message += (\"[\" + format_e(d.avgSensibility) + \", \" + format_e(d.minSensibility) + \", \" + format_e(d.maxSensibility) + \", \" + format_e(d.rateSensibility) + \"]\").rjust(41) + \" | \"\n+ message += (\"[\" + format_e(d.tableCur[0]) + \",\" + format_e(d.tableCur[len(d.tableCur) -1]) + \"]\").rjust(18) + \"\\n\"\n+\n+ if self.hasError():\n+ message += \"---- name | errors list \\n\"\n+ for d in self.dataList:\n+ if d.hasError():\n+ message += d.name.rjust(9) + \" | \"\n+\n+ el = 0\n+ for e in d.errorsList:\n+ message += \"{\" + str(e[0]) + \" -> \"\n+ if e[1] > 0: message += \"+\"\n+ message += format_e(e[1]) + \"}\"\n+\n+ el += 1\n+ if el < len(d.errorsList):\n+ message += \", \"\n+ message += \"\\n\"\n+\n+ return message\n+\n+ def hasError(self):\n+ hasError = False\n+ for d in self.dataList:\n+ hasError = hasError or d.hasError()\n+ return hasError\n+\n+ def passRate(self):\n+ passRate = float(0)\n+\n+ nGoodList = 0\n+ for d in self.dataList:\n+ try:\n+ passRate += d.passRate()\n+ nGoodList += 1\n+ except RuntimeError:\n+ pass\n+\n+ if nGoodList:\n+ return passRate / float(nGoodList)\n+ else:\n+ return passRate\n# =================================================================== FUNCTIONS\n# =============================================================================\n@@ -132,63 +429,18 @@ for fn in fileNames:\n# open the file in read mode (from the fileName \"fn\" and the path)\nf = open(args.refsPath + \"/\" + fn, 'r')\n- # read all the lines from the current file f\n+ # read all the lines from the reference file f\nlines = []\nfor line in f:\nlines.append(line)\n- # get the main infos from the lines\n- runCommand = lines[1].strip()\n-\n- currentSection = \"\"\n- idx = 0\n- simuRef = []\n- for l in lines:\n- # avoid the first lines and the comments\n- if idx > 6 and l.replace(\" \", \"\") != \"\" and \\\n- l.replace(\" \", \"\") != \"\\n\" and \\\n- l[0] != '#':\n- simuRef.append(l.strip().replace(\"||\", \"|\").replace(\" \", \"\").split(\"|\"))\n- idx = idx +1\n-\nf.close()\n- # split the run command\n- argsAFFECT = [\"\"]\n- idx = 0\n-\n- new = 0\n- found_dashes = 0\n- for s in runCommand:\n- if found_dashes == 0:\n- if s == ' ':\n- if new == 0:\n- argsAFFECT.append(\"\")\n- idx = idx + 1\n- new = 1\n-\n- elif s == '\\\"':\n- if new == 0:\n- argsAFFECT.append(\"\")\n- idx = idx + 1\n- new = 1\n- found_dashes = 1\n-\n- else:\n- argsAFFECT[idx] += s\n- new = 0\n-\n- else: # between dashes\n- if s == '\\\"':\n- argsAFFECT.append(\"\")\n- idx = idx + 1\n- found_dashes = 0\n-\n- else:\n- argsAFFECT[idx] += s\n-\n- del argsAFFECT[idx]\n+ # parse the reference file\n+ simuRef = dataReader(lines)\n+ # get the command line to run\n+ argsAFFECT = splitAsCommand(simuRef.RunCommand)\nargsAFFECT.append(\"--ter-freq\")\nargsAFFECT.append(\"0\")\nif args.maxFE:\n@@ -201,6 +453,18 @@ for fn in fileNames:\nargsAFFECT.append(\"--sim-stop-time\")\nargsAFFECT.append(str(args.maxSNRTime))\n+ noiseVals = \"\"\n+ for n in range(len(simuRef.Noise)):\n+ if n != 0:\n+ noiseVals += \",\";\n+\n+ noiseVals += str(simuRef.Noise[n])\n+\n+ argsAFFECT.append(\"-R\")\n+ argsAFFECT.append(noiseVals)\n+\n+\n+ # run the tested simulator\nos.chdir(args.buildPath)\nstartTime = time.time()\nprocessAFFECT = subprocess.Popen(argsAFFECT, stdout=subprocess.PIPE,\n@@ -211,8 +475,17 @@ for fn in fileNames:\nerrAndWarnMessages = stderrAFFECT.decode(encoding='UTF-8')\n+\n+ # compare ref and nex results to check if the simulator is still OK\nos.chdir(PathOrigin)\n+ # get the results\n+ stdOutput = stdoutAFFECT.decode(encoding='UTF-8').split(\"\\n\")\n+ simuCur = dataReader(stdOutput)\n+\n+ # result file\n+ fRes = open(args.resultsPath + \"/\" + fn, 'w+')\n+\nif returnCode:\nprint(\" - ABORTED.\", end=\"\\n\");\nif errAndWarnMessages:\n@@ -220,67 +493,50 @@ for fn in fileNames:\nprint(errAndWarnMessages)\nnErrors = nErrors +1\nfailIds.append(testId +1)\n- else:\n- # begin to write the results into a file\n- fRes = open(args.resultsPath + \"/\" + fn, 'w+')\n- # parse the results\n- stdOutput = stdoutAFFECT.decode(encoding='UTF-8').split(\"\\n\")\n- outputAFFECTLines = []\n- simuCur = []\n- for l in stdOutput:\n- if l != \"\" and l[0] != '#' and l[0] != \"(\": # avoid the first lines and the comments\n- array = l.strip().replace(\"||\", \"|\").replace(\" \", \"\").split(\"|\")\n- if (len(array) == 12 or len(array) == 9):\n- outputAFFECTLines.append(l)\n- simuCur.append(array)\n+ elif not simuCur.NoiseType == simuRef.NoiseType:\n+ failIds.append(testId +1)\n+ nErrors += 1\n+ print(\" - NOISE TYPE MISMATCH: \" + simuRef.NoiseType + \" vs \" + simuCur.NoiseType + \".\", end=\"\\n\");\n+\nelse:\n- fRes.write(l + \"\\n\")\n- elif l != \"\" and l[0] == '#' and \"# End of the simulation.\" not in l:\n+ # parse the results to validate (or not) the BER/FER/MI performance\n+ comp = compStats(simuCur, simuRef, args.sensibility)\n+\n+ # print the header\n+ fRes.write(\"Run command:\\n\" + simuCur.RunCommand + \"\\n\")\n+ fRes.write(\"Curve name:\\n\" + simuCur.CurveName + \"\\n\")\n+\n+ # print the parameters directly and add to the wrong data the ref values\n+ idxNoise = 0\n+ i = 0\n+ while( i < len(stdOutput)):\n+ l = stdOutput[i]\n+ if l.startswith(\"#\"):\n+ if \"# End of the simulation.\" not in l:\nfRes.write(l + \"\\n\")\n- fRes.flush()\n+ elif l == \"Run command:\" or l == \"Curve name:\":\n+ i += 1 # ignore the following line\n- # validate (or not) the BER/FER performance\n- valid = 0\n- idx = 0\n- errorsList = []\n- sensibilityList = []\n- for ref in simuRef:\n- try:\n- cur_fe = int(simuCur[idx][4])\n- except IndexError: # no such line\n- break\n+ else:\n+ em = comp.errorMessage(idxNoise)\n+ fRes.write(l + em + \"\\n\")\n+ idxNoise += 1\n- if cur_fe < args.maxFE / 2:\n- break\n+ i += 1 # to next line\n- numRef = float(ref[6][0:4])\n- powerRef = int(ref[6][6:8])\n- numCur = float(simuCur[idx][6][0:4])\n- powerCur = int(simuCur[idx][6][6:8])\n- if powerRef - powerCur != 0:\n- if powerRef > powerCur:\n- numCur = numCur * 10**(math.fabs(powerCur - powerRef))\n- else:\n- numRef = numRef * 10**(math.fabs(powerCur - powerRef))\n+ fRes.flush()\n- absoluteNumDiff = math.fabs(numCur - numRef)\n- sensibilityList.append(absoluteNumDiff)\n- if absoluteNumDiff > args.sensibility:\n- fRes.write(outputAFFECTLines[idx] + \"WRONG! FER=\" + ref[6][0:8] + \"\\n\")\n- errorsList.append([float(simuCur[idx][1][0:4]), numCur - numRef])\n- else:\n- valid = valid + 1\n- fRes.write(outputAFFECTLines[idx] + \"\\n\")\n+ # validate (or not) the BER/FER/MI performance\n+ print(\" - %.2f\" %elapsedTime, \"sec\", end=\"\")\n- idx = idx + 1\n+ passRate = comp.passRate()\n- print(\" - %.2f\" %elapsedTime, \"sec\", end=\"\")\n- if valid == idx:\n+ if passRate == float(1):\nprint(\" - STRONG PASSED.\", end=\"\\n\");\n- elif idx != 0 and float(valid) / float(idx) >= args.weakRate:\n+ elif passRate >= args.weakRate:\nprint(\" - WEAK PASSED.\", end=\"\\n\");\nelse:\nprint(\" - FAILED.\", end=\"\\n\");\n@@ -288,42 +544,12 @@ for fn in fileNames:\nfailIds.append(testId +1)\nif args.verbose:\n- avgSensibility = 0\n- minSensibility = 0\n- maxSensibility = 0\n- if idx == 0:\n- avgSensibility = 0\n- else:\n- avgSensibility = sum(sensibilityList) / float(idx)\n- minSensibility = min(sensibilityList)\n- maxSensibility = max(sensibilityList)\n- rateSensibility = (avgSensibility / args.sensibility) * 100\n-\n- print(\"---- Details: 'valid SNR points' = \", valid, \"/\", idx,\n- \", 'sensibility [avg,min,max,rate]' = [ %.2f\" %avgSensibility,\n- \", %.2f\" %minSensibility, \", %.2f\" %maxSensibility,\n- \", %.1f\" % rateSensibility, \"% ].\", end=\"\\n\")\n- if idx > 0:\n- print(\"---- Details: 'first SNR point' =\", float(simuCur[0][1][0:4]),\n- \"dB (@\", simuCur[0][6][0:8],\n- \"FER), 'last SNR point' =\", float(simuCur[idx -1][1][0:4]),\n- \"dB (@\", simuCur[idx -1][6][0:8], \"FER).\")\n- if len(errorsList):\n- print(\"---- Details: 'errors list' = [\", end=\"\")\n- el = 0\n- for error in errorsList:\n- if error[1] > 0:\n- print(\"{\", error[0], \"dB -> +%.2f\" %error[1], \"}\", end=\"\")\n- else:\n- print(\"{\", error[0], \"dB -> %.2f\" %error[1], \"}\", end=\"\")\n- if el < len(errorsList) -1:\n- print(\", \", end=\"\")\n- el = el + 1\n- print(\"].\", end=\"\\n\")\n+ print (comp.getResumeTable())\nif errAndWarnMessages:\nprint(\"---- Warning message(s):\", end=\"\\n\");\nprint(errAndWarnMessages)\n+ fRes.write(errAndWarnMessages)\nfRes.write(\"# End of the simulation.\\n\")\nfRes.close();\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Modify test regression to handle several noise types and data to check
|
8,483 |
18.04.2018 17:47:48
| -7,200 |
68d5d78d73c550a7a1bf1c806e2f64fb22f8c5ad
|
Remove rang::tag::reset cause it is useless
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Command_parser.cpp",
"new_path": "src/Factory/Command_parser.cpp",
"diff": "@@ -72,7 +72,7 @@ void Command_parser\nstd::string message = \"For more information please display the help (\\\"\";\nmessage += tools::Argument_handler::print_tag(Command_parser::help_tag) += \"\\\").\";\n- err_stream << rang::tag::info << message << rang::tag::reset << std::endl << std::endl;\n+ err_stream << rang::tag::info << message << std::endl << std::endl;\n}\n}\n@@ -80,14 +80,14 @@ void Command_parser\n::print_errors()\n{\nfor (size_t e = 0; e < errors.size(); e++)\n- err_stream << rang::tag::error << errors[e] << rang::tag::reset << std::endl;\n+ err_stream << rang::tag::error << errors[e] << std::endl;\n}\nvoid Command_parser\n::print_warnings()\n{\nfor (size_t w = 0; w < warnings.size(); w++)\n- err_stream << rang::tag::warning << warnings[w] << rang::tag::reset << std::endl;\n+ err_stream << rang::tag::warning << warnings[w] << std::endl;\n}\nbool Command_parser\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Launcher/Launcher.cpp",
"new_path": "src/Launcher/Launcher.cpp",
"diff": "@@ -95,7 +95,7 @@ int Launcher::read_arguments()\n// print the errors\nif (!cmd_error.empty()) std::cerr << std::endl;\nfor (unsigned e = 0; e < cmd_error.size(); e++)\n- std::cerr << rang::tag::error << cmd_error[e] << rang::tag::reset << std::endl;\n+ std::cerr << rang::tag::error << cmd_error[e] << std::endl;\n// print the help tags\nif (!cmd_error.empty() && !params_common.display_help)\n@@ -105,7 +105,7 @@ int Launcher::read_arguments()\nstd::string message = \"For more information please display the help (\\\"\";\nmessage += tools::Argument_handler::print_tag(help_tag) += \"\\\").\";\n- std::cerr << std::endl << rang::tag::info << message << rang::tag::reset << std::endl;\n+ std::cerr << std::endl << rang::tag::info << message << std::endl;\n}\nreturn (!cmd_error.empty() || params_common.display_help) ? EXIT_FAILURE : EXIT_SUCCESS;\n@@ -142,7 +142,7 @@ int Launcher::launch()\nif (this->params_common.mpi_rank == 0)\n#endif\nfor (unsigned w = 0; w < this->cmd_warn.size(); w++)\n- std::clog << rang::tag::warning << this->cmd_warn[w] << rang::tag::reset << std::endl;\n+ std::clog << rang::tag::warning << this->cmd_warn[w] << std::endl;\nreturn EXIT_FAILURE;\n}\n@@ -170,7 +170,7 @@ int Launcher::launch()\nif (this->params_common.mpi_rank == 0)\n#endif\nfor (unsigned w = 0; w < this->cmd_warn.size(); w++)\n- std::clog << rang::tag::warning << this->cmd_warn[w] << rang::tag::reset << std::endl;\n+ std::clog << rang::tag::warning << this->cmd_warn[w] << std::endl;\ntry\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/CRC/Polynomial/CRC_polynomial.cpp",
"new_path": "src/Module/CRC/Polynomial/CRC_polynomial.cpp",
"diff": "@@ -35,7 +35,7 @@ CRC_polynomial<B>\nstd::clog << rang::tag::warning << \"You specified \\\"\" << this->size\n<< \" bits\\\" for your CRC size but the database advise you to use \\\"\"\n<< std::get<1>(known_polynomials.at(crc_name))\n- << \" bits\\\", are you sure?\" << rang::tag::reset << std::endl;\n+ << \" bits\\\", are you sure?\" << std::endl;\npolynomial.push_back(1);\nfor (auto i = 0; i < this->size; i++)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/Iterative/Threads/BFER_ite_threads.cpp",
"new_path": "src/Simulation/BFER/Iterative/Threads/BFER_ite_threads.cpp",
"diff": "@@ -25,7 +25,7 @@ BFER_ite_threads<B,R,Q>\nif (this->params_BFER_ite.n_threads != 1)\nstd::clog << rang::tag::warning << \"Multi-threading detected with error tracking revert feature! \"\n\"Each thread will play the same frames. Please run with one thread.\"\n- << rang::tag::reset << std::endl;\n+ << std::endl;\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/Standard/Threads/BFER_std_threads.cpp",
"new_path": "src/Simulation/BFER/Standard/Threads/BFER_std_threads.cpp",
"diff": "@@ -25,7 +25,7 @@ BFER_std_threads<B,R,Q>\nif (this->params_BFER_std.n_threads != 1)\nstd::clog << rang::tag::warning << \"Multi-threading detected with error tracking revert feature! \"\n\"Each thread will play the same frames. Please run with one thread.\"\n- << rang::tag::reset << std::endl;\n+ << std::endl;\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator_TV.cpp",
"new_path": "src/Tools/Code/Polar/Frozenbits_generator/Frozenbits_generator_TV.cpp",
"diff": "@@ -101,8 +101,7 @@ void Frozenbits_generator_TV\ncmd += \" --log-length=\" + str_m; // m\ncmd += \" -f=\" + filename; // filename\n- std::clog << rang::format::info << \"Generating best channels positions file (\\\"\" << filename << \"\\\")...\"\n- << rang::format::reset << \"\\r\";\n+ std::clog << rang::tag::info << \"Generating best channels positions file (\\\"\" << filename << \"\\\")...\\r\";\nfflush(stdout); fflush(stderr);\nif (system(cmd.c_str()) == 0)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/Polar/nodes_parser.hxx",
"new_path": "src/Tools/Code/Polar/nodes_parser.hxx",
"diff": "@@ -197,8 +197,7 @@ std::vector<aff3ct::tools::Pattern_polar_i*> aff3ct::tools\n}\nelse\n{\n- std::clog << rang::tag::warning << \"Unrecognized Polar node type (\" << v_polar[i] << \").\"\n- << rang::tag::reset << std::endl;\n+ std::clog << rang::tag::warning << \"Unrecognized Polar node type (\" << v_polar[i] << \").\" << std::endl;\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Statistics/Statistics.cpp",
"new_path": "src/Tools/Display/Statistics/Statistics.cpp",
"diff": "@@ -289,9 +289,8 @@ void Statistics\n}\nelse\n{\n- stream << \"# \"\n- << rang::tag::info << \"Statistics are unavailable. Did you enable the statistics in the tasks?\"\n- << rang::tag::reset << std::endl;\n+ stream << rang::tag::comment << rang::tag::info\n+ << \"Statistics are unavailable. Did you enable the statistics in the tasks?\" << std::endl;\n}\n}\n@@ -436,8 +435,7 @@ void Statistics\n}\nelse\n{\n- stream << \"# \"\n- << rang::tag::info << \"Statistics are unavailable. Did you enable the statistics in the tasks?\"\n- << rang::tag::reset << std::endl;\n+ stream << rang::tag::comment << rang::tag::info\n+ << \"Statistics are unavailable. Did you enable the statistics in the tasks?\" << std::endl;\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/rang_format/rang_format.cpp",
"new_path": "src/Tools/Display/rang_format/rang_format.cpp",
"diff": "@@ -21,12 +21,6 @@ std::ostream& format_info(std::ostream& os)\nreturn os;\n}\n-std::ostream& format_reset(std::ostream& os)\n-{\n- os << rang::style::reset;\n- return os;\n-}\n-\nstd::ostream& format_comment(std::ostream& os)\n{\nos << rang::style::bold << \"# \" << rang::style::reset;\n@@ -40,7 +34,6 @@ std::ostream& rang::operator<<(std::ostream& os, tag f)\ncase rang::tag::error: return format_error (os);\ncase rang::tag::warning: return format_warning(os);\ncase rang::tag::info: return format_info (os);\n- case rang::tag::reset: return format_reset (os);\ncase rang::tag::comment: return format_comment(os);\n}\n@@ -52,9 +45,9 @@ void rang::format_on_each_line(std::ostream& os, const std::string& str, rang::t\nsize_t pos = 0, old_pos = 0;\nwhile ((pos = str.find('\\n', old_pos)) != std::string::npos)\n{\n- os << f << str.substr(old_pos, pos-old_pos) << tag::reset << std::endl;\n+ os << f << str.substr(old_pos, pos-old_pos) << std::endl;\nold_pos = pos+1;\n}\nif (!str.substr(old_pos, pos-old_pos).empty())\n- os << f << str.substr(old_pos, pos-old_pos) << tag::reset;\n+ os << f << str.substr(old_pos, pos-old_pos);\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/rang_format/rang_format.h",
"new_path": "src/Tools/Display/rang_format/rang_format.h",
"diff": "@@ -12,8 +12,7 @@ enum class tag {\nerror = 0,\nwarning,\ninfo,\n- comment,\n- reset\n+ comment\n};\nstd::ostream& operator<<(std::ostream& os, tag f);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/main.cpp",
"new_path": "src/main.cpp",
"diff": "@@ -112,11 +112,11 @@ int read_arguments(const int argc, const char** argv, factory::Launcher::paramet\nif (cmd_error.size()) std::cerr << std::endl;\nfor (auto w = 0; w < (int)cmd_error.size(); w++)\n- std::cerr << rang::tag::error << cmd_error[w] << rang::tag::reset << std::endl;\n+ std::cerr << rang::tag::error << cmd_error[w] << std::endl;\nif (cmd_warn.size()) std::cerr << std::endl;\nfor (auto w = 0; w < (int)cmd_warn.size(); w++)\n- std::cerr << rang::tag::warning << cmd_warn[w] << rang::tag::reset << std::endl;\n+ std::cerr << rang::tag::warning << cmd_warn[w] << std::endl;\n}\nreturn (cmd_error.size() || display_help) ? EXIT_FAILURE : EXIT_SUCCESS;\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Remove rang::tag::reset cause it is useless
|
8,483 |
19.04.2018 11:23:26
| -7,200 |
026e9ccbc159fa704757ac8e4f8bd44c55153565
|
Change the output format for more lisibility; Change the sensibility computation to a ratio between the ref and the new value
|
[
{
"change_type": "MODIFY",
"old_path": "ci/test-regression.py",
"new_path": "ci/test-regression.py",
"diff": "@@ -23,17 +23,18 @@ parser.add_argument('--refs-path', action='store', dest='refsPath', ty\nparser.add_argument('--results-path', action='store', dest='resultsPath', type=str, default=\"test-regression-results\", help='Path to the simulated results.')\nparser.add_argument('--build-path', action='store', dest='buildPath', type=str, default=\"build\", help='Path to the AFF3CT build.')\nparser.add_argument('--start-id', action='store', dest='startId', type=int, default=1, help='Starting id to avoid computing results one again.') # choices=xrange(1, +inf)\n-parser.add_argument('--sensibility', action='store', dest='sensibility', type=float, default=1.0, help='Sensibility to verify a SNR point.') # choices=xrange(0.0, +inf)\n+parser.add_argument('--sensibility', action='store', dest='sensibility', type=float, default=1.5, help='Sensibility on the ratio between new vs ref to verify a noise point.') # choices=xrange(1.0, +inf)\nparser.add_argument('--n-threads', action='store', dest='nThreads', type=int, default=0, help='Number of threads to use in the simulation (0 = all available).') # choices=xrange(0, +ing)\nparser.add_argument('--recursive-scan', action='store', dest='recursiveScan', type=bool, default=True, help='If enabled, scan the path of refs recursively.')\n-parser.add_argument('--max-fe', action='store', dest='maxFE', type=int, default=100, help='Maximum number of frames errors to simulate per SNR point.') # choices=xrange(0, +inf)\n-parser.add_argument('--weak-rate', action='store', dest='weakRate', type=float, default=0.8, help='Rate of valid SNR points to passed a test.') # choices=xrange(0.0, 1.0 )\n-parser.add_argument('--max-snr-time', action='store', dest='maxSNRTime', type=int, default=600, help='The maximum amount of time to spend to compute a SNR point in seconds (0 = illimited)') # choices=xrange(0, +inf)\n+parser.add_argument('--max-fe', action='store', dest='maxFE', type=int, default=100, help='Maximum number of frames errors to simulate per noise point.') # choices=xrange(0, +inf)\n+parser.add_argument('--weak-rate', action='store', dest='weakRate', type=float, default=0.9, help='Rate of valid noise points to passe a test.') # choices=xrange(0.0, 1.0 )\n+parser.add_argument('--max-snr-time', action='store', dest='maxSNRTime', type=int, default=600, help='The maximum amount of time to spend to compute a noise point in seconds (0 = illimited)') # choices=xrange(0, +inf)\nparser.add_argument('--verbose', action='store', dest='verbose', type=bool, default=False, help='Enable the verbose mode.')\n# supported file extensions (filename suffix)\nextensions = ['.txt', '.perf', '.data', '.dat']\nNoiseTypeList = [\"Eb/N0\", \"Es/N0\", \"ROP\", \"EP\"]\n+NoiseUnityList = [\"dB\", \"dB\", \"dB\", \"\" ]\n# ================================================================== PARAMETERS\n@@ -192,6 +193,13 @@ def dataReader(aff3ctOutput):\nelse:\ndata.MI = data.All[idx]\n+ # set ESN0\n+ idx = getLegendIdx(data.Legend, \"Es/N0\")\n+ if idx == -1 or data.NoiseType == \"Es/N0\":\n+ data.ESN0 = []\n+ else:\n+ data.ESN0 = data.All[idx]\n+\nreturn data\ndef splitAsCommand(runCommand):\n@@ -242,35 +250,47 @@ class tableStats:\nself.tableRef = tableRef\nself.name = name\nself.sensibility = sensibility\n- self.minSensibility = 0\n+ self.minSensibility = float('inf')\nself.maxSensibility = 0\nself.sumSensibility = 0\n+ self.avgSensibility = 0\n+ self.rateSensibility = 0\nself.valid = 0\nself.nData = len(tableCur)\nself.errorsList = []\nself.errorsPos = []\nself.errorsMessage = []\n+ self.makeStats()\n+\n+ def makeStats(self):\nfor i in range(self.nData):\n- diff = tableCur[i] - tableRef[i];\n- absoluteDiff = math.fabs(diff)\n+ if self.tableCur[i] > self.tableRef[i]:\n+ ratio = self.tableCur[i] / self.tableRef[i];\n+ else:\n+ ratio = self.tableRef[i] / self.tableCur[i];\n- if absoluteDiff > self.sensibility:\n+ if ratio > self.sensibility:\nself.errorsPos .append(i)\n- self.errorsList .append([tableCur[i], diff])\n- self.errorsMessage.append(format_e(tableRef[i]))\n+ self.errorsList .append([self.tableCur[i], ratio])\n+ self.errorsMessage.append(format_e(self.tableRef[i]))\nelse:\nself.valid += 1\n- self.sumSensibility += absoluteDiff\n- self.minSensibility = min(self.minSensibility, absoluteDiff)\n- self.maxSensibility = max(self.maxSensibility, absoluteDiff)\n+ self.sumSensibility += ratio\n+ self.minSensibility = min(self.minSensibility, ratio)\n+ self.maxSensibility = max(self.maxSensibility, ratio)\nif self.nData != 0:\nself.avgSensibility = self.sumSensibility / float(self.nData)\nelse:\nself.avgSensibility = 0\n+\n+ if self.sensibility != 0:\nself.rateSensibility = (self.avgSensibility / self.sensibility) * 100\n+ else:\n+ self.rateSensibility = float(100)\n+\ndef errorMessage(self, idx):\nif len(self.errorsMessage) > idx and len(self.errorsMessage[idx]):\n@@ -298,6 +318,7 @@ class compStats:\nself.dataList.append(tableStats(dataCur.FER, dataRef.FER, sensibility, \"FER\" ))\nself.dataList.append(tableStats(dataCur.BER, dataRef.BER, sensibility, \"BER\" ))\nself.dataList.append(tableStats(dataCur.MI, dataRef.MI, sensibility, \"MI\" ))\n+ self.dataList.append(tableStats(dataCur.ESN0,dataRef.ESN0, 1.0, \"Es/N0\"))\ndef errorMessage(self, idx):\nmessage = \"\"\n@@ -316,25 +337,43 @@ class compStats:\nif len(self.dataCur.Noise) == 0:\nreturn message\n- message += \"---- Details: first noise point = \" + format_e(self.dataCur.Noise[0]) + \", last noise point = \" + format_e(self.dataCur.Noise[len(self.dataCur.Noise) -1]) + \"\\n\"\n- message += \"---- name | valid points | sensibility [avg,min,max,rate%] | [first,last] point \\n\"\n+ # get noise unity\n+ unity = \"\"\n+ idx = NoiseTypeList.index(self.dataCur.NoiseType)\n+ if idx != -1:\n+ unity = NoiseUnityList[idx]\n+ if len(unity):\n+ unity = \" \" + unity\n+\n+ message += \"---- Details: Noise type = \" + self.dataCur.NoiseType\n+ message += \", first noise point = \" + format_e(self.dataCur.Noise[0]) + unity\n+ message += \", last noise point = \" + format_e(self.dataCur.Noise[len(self.dataCur.Noise) -1]) + unity + \"\\n\"\n+ message += \"---- -------|--------------|--------------------------------|----------------------- \\n\"\n+ message += \"---- name | valid points | sensibility [avg,min,max,rate] | [first,last] points \\n\"\n+ message += \"---- -------|--------------|--------------------------------|----------------------- \\n\"\nfor d in self.dataList:\nif len(d.tableCur):\n- message += d.name.rjust(9) + \" | \"\n+ message += \"----\" + d.name.rjust(7) + \" | \"\nmessage += (str(d.valid) + \"/\" + str(d.nData)).rjust(12) + \" | \"\n- message += (\"[\" + format_e(d.avgSensibility) + \", \" + format_e(d.minSensibility) + \", \" + format_e(d.maxSensibility) + \", \" + format_e(d.rateSensibility) + \"]\").rjust(41) + \" | \"\n- message += (\"[\" + format_e(d.tableCur[0]) + \",\" + format_e(d.tableCur[len(d.tableCur) -1]) + \"]\").rjust(18) + \"\\n\"\n+ message += \"[ \" + (\"%.3f\" % d.avgSensibility + \", %.2f\" % d.minSensibility + \", %.2f\" % d.maxSensibility + \", \" + (\"%.2f\" % d.rateSensibility).rjust(6) + \"%\") + \" ] | \"\n+ message += \"[\" + (format_e(d.tableCur[0]) + \",\" + format_e(d.tableCur[len(d.tableCur) -1])).rjust(19) + \" ]\" + \"\\n\"\nif self.hasError():\n+ message += \"\\n\"\n+ message += \"---- -------|----------------------------------------------------------------------- \\n\"\nmessage += \"---- name | errors list \\n\"\n+ message += \"---- -------|----------------------------------------------------------------------- \\n\"\nfor d in self.dataList:\nif d.hasError():\n- message += d.name.rjust(9) + \" | \"\n-\n+ message += \"----\" + d.name.rjust(7) + \" | \"\nel = 0\nfor e in d.errorsList:\n- message += \"{\" + str(e[0]) + \" -> \"\n+ if el != 0 and (el % 3) == 0 :\n+ message += \"\\n---- | \"\n+\n+\n+ message += \"{ %.3f\" %e[0] + \" -> \"\nif e[1] > 0: message += \"+\"\nmessage += format_e(e[1]) + \"}\"\n@@ -463,6 +502,11 @@ for fn in fileNames:\nargsAFFECT.append(\"-R\")\nargsAFFECT.append(noiseVals)\n+ if simuRef.NoiseType == \"Eb/N0\":\n+ argsAFFECT.append(\"-E\")\n+ argsAFFECT.append(\"EBN0\")\n+\n+\n# run the tested simulator\nos.chdir(args.buildPath)\n@@ -537,9 +581,9 @@ for fn in fileNames:\nif passRate == float(1):\nprint(\" - STRONG PASSED.\", end=\"\\n\");\nelif passRate >= args.weakRate:\n- print(\" - WEAK PASSED.\", end=\"\\n\");\n+ print(\" - WEAK PASSED (rate = %.2f\" %passRate, \").\", end=\"\\n\");\nelse:\n- print(\" - FAILED.\", end=\"\\n\");\n+ print(\" - FAILED (rate = %.2f\" %passRate, \").\", end=\"\\n\");\nnErrors = nErrors +1\nfailIds.append(testId +1)\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Change the output format for more lisibility; Change the sensibility computation to a ratio between the ref and the new value
|
8,483 |
23.04.2018 10:05:57
| -7,200 |
53edd5745e3e4d2d156965b2fc5161d476d1cf1d
|
Change back the way of checking the new simulation curves to the old way by calculating the difference between the new and the ref
|
[
{
"change_type": "MODIFY",
"old_path": "refs",
"new_path": "refs",
"diff": "-Subproject commit 26e1a5f51eb5f8d12cb30b3a42420c5a300536f7\n+Subproject commit a96cf26955547ab3566cc96dbb58531228350515\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Change back the way of checking the new simulation curves to the old way by calculating the difference between the new and the ref
|
8,483 |
23.04.2018 11:25:14
| -7,200 |
afb041837636e2e348e05b1874e88280476ff76b
|
Replace arg -sigma to -noise in channel and modem factories; Change get_noise method to current_noise method in Modem and Channel Modules
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Channel/Channel.cpp",
"new_path": "src/Factory/Module/Channel/Channel.cpp",
"diff": "@@ -85,9 +85,9 @@ void Channel::parameters\n\"block fading policy for the RAYLEIGH channel.\");\nargs.add(\n- {p+\"-sigma\"},\n+ {p+\"-noise\"},\ntools::Real(tools::Positive(), tools::Non_zero()),\n- \"noise variance value.\");\n+ \"noise value (for SIGMA, ROP or EP noise type).\");\nargs.add(\n{p+\"-seed\", \"S\"},\n@@ -125,7 +125,7 @@ void Channel::parameters\nif(vals.exist({p+\"-blk-fad\" })) this->block_fading = vals.at ({p+\"-blk-fad\" });\nif(vals.exist({p+\"-add-users\" })) this->add_users = true;\nif(vals.exist({p+\"-complex\" })) this->complex = true;\n- if(vals.exist({p+\"-sigma\" })) this->sigma = vals.to_float({p+\"-sigma\" });\n+ if(vals.exist({p+\"-noise\" })) this->noise = vals.to_float({p+\"-noise\" });\n}\nvoid Channel::parameters\n@@ -139,8 +139,8 @@ void Channel::parameters\nif (full) headers[p].push_back(std::make_pair(\"Frame size (N)\", std::to_string(this->N)));\nif (full) headers[p].push_back(std::make_pair(\"Inter frame level\", std::to_string(this->n_frames)));\n- if (this->sigma != -1.f)\n- headers[p].push_back(std::make_pair(\"Sigma value\", std::to_string(this->sigma)));\n+ if (this->noise != -1.f)\n+ headers[p].push_back(std::make_pair(\"Sigma value\", std::to_string(this->noise)));\nif (this->type == \"USER\" || this->type == \"RAYLEIGH_USER\")\nheaders[p].push_back(std::make_pair(\"Path\", this->path));\n@@ -174,15 +174,15 @@ module::Channel<R>* Channel::parameters\nelse\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n- if (type == \"AWGN\" ) return new module::Channel_AWGN_LLR <R>(N, n, add_users, tools::Sigma<R>((R)this->sigma), n_frames);\n- else if (type == \"RAYLEIGH\" ) return new module::Channel_Rayleigh_LLR <R>(N, complex, n, add_users, tools::Sigma<R>((R)this->sigma), n_frames);\n- else if (type == \"RAYLEIGH_USER\") return new module::Channel_Rayleigh_LLR_user<R>(N, complex, path, gain_occur, n, add_users, tools::Sigma<R>((R)this->sigma), n_frames);\n+ if (type == \"AWGN\" ) return new module::Channel_AWGN_LLR <R>(N, n, add_users, tools::Sigma<R>((R)this->noise), n_frames);\n+ else if (type == \"RAYLEIGH\" ) return new module::Channel_Rayleigh_LLR <R>(N, complex, n, add_users, tools::Sigma<R>((R)this->noise), n_frames);\n+ else if (type == \"RAYLEIGH_USER\") return new module::Channel_Rayleigh_LLR_user<R>(N, complex, path, gain_occur, n, add_users, tools::Sigma<R>((R)this->noise), n_frames);\nelse\n{\nmodule::Channel<R>* c = nullptr;\nif (type == \"USER\") c = new module::Channel_user<R>(N, path, add_users, n_frames);\nelse if (type == \"NO\" ) c = new module::Channel_NO <R>(N, add_users, n_frames);\n- else if (type == \"BEC\" ) c = new module::Channel_BEC <R>(N, seed, tools::Erased_probability<R>((R)this->sigma), n_frames);\n+ else if (type == \"BEC\" ) c = new module::Channel_BEC <R>(N, seed, tools::Erased_probability<R>((R)this->noise), n_frames);\ndelete n;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Channel/Channel.hpp",
"new_path": "src/Factory/Module/Channel/Channel.hpp",
"diff": "@@ -32,7 +32,7 @@ struct Channel : public Factory\nint n_frames = 1;\nint seed = 0;\nint gain_occur = 1;\n- float sigma = -1.f;\n+ float noise = -1.f;\n// ---------------------------------------------------------------------------------------------------- METHODS\nexplicit parameters(const std::string &p = Channel_prefix);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Modem/Modem.cpp",
"new_path": "src/Factory/Module/Modem/Modem.cpp",
"diff": "@@ -112,7 +112,7 @@ void Modem::parameters\n\"select the type of the max operation to use in the demodulator.\");\nargs.add(\n- {p+\"-sigma\"},\n+ {p+\"-noise\"},\ntools::Real(tools::Positive(), tools::Non_zero()),\n\"noise variance value for the demodulator.\");\n@@ -199,7 +199,7 @@ void Modem::parameters\n// --------------------------------------------------------------------------------------------------- demodulator\nif(vals.exist({p+\"-no-sig2\"})) this->no_sig2 = true;\n- if(vals.exist({p+\"-sigma\" })) this->sigma = vals.to_float({p+\"-sigma\"});\n+ if(vals.exist({p+\"-noise\" })) this->noise = vals.to_float({p+\"-noise\"});\nif(vals.exist({p+\"-ite\" })) this->n_ite = vals.to_int ({p+\"-ite\" });\nif(vals.exist({p+\"-max\" })) this->max = vals.at ({p+\"-max\" });\nif(vals.exist({p+\"-psi\" })) this->psi = vals.at ({p+\"-psi\" });\n@@ -239,8 +239,8 @@ void Modem::parameters\nstd::string demod_ite = std::to_string(this->n_ite);\nstd::string demod_psi = this->psi;\n- if (this->sigma != -1.f && full)\n- headers[p].push_back(std::make_pair(\"Sigma value\", std::to_string(this->sigma)));\n+ if (this->noise != -1.f && full)\n+ headers[p].push_back(std::make_pair(\"Sigma value\", std::to_string(this->noise)));\nheaders[p].push_back(std::make_pair(\"Sigma square\", demod_sig2));\nif (demod_max != \"unused\")\nheaders[p].push_back(std::make_pair(\"Max type\", demod_max));\n@@ -255,14 +255,14 @@ template <typename B, typename R, typename Q, tools::proto_max<Q> MAX>\nmodule::Modem<B,R,Q>* Modem::parameters\n::_build() const\n{\n- if (this->type == \"BPSK\" ) return new module::Modem_BPSK <B,R,Q >(this->N, tools::Sigma<R>((R)this->sigma), this->no_sig2, this->n_frames);\n- else if (this->type == \"BPSK_FAST\") return new module::Modem_BPSK_fast<B,R,Q >(this->N, tools::Sigma<R>((R)this->sigma), this->no_sig2, this->n_frames);\n- else if (this->type == \"OOK\" ) return new module::Modem_OOK <B,R,Q >(this->N, tools::Sigma<R>((R)this->sigma), this->no_sig2, this->n_frames);\n- else if (this->type == \"PAM\" ) return new module::Modem_PAM <B,R,Q,MAX>(this->N, tools::Sigma<R>((R)this->sigma), this->bps, this->no_sig2, this->n_frames);\n- else if (this->type == \"QAM\" ) return new module::Modem_QAM <B,R,Q,MAX>(this->N, tools::Sigma<R>((R)this->sigma), this->bps, this->no_sig2, this->n_frames);\n- else if (this->type == \"PSK\" ) return new module::Modem_PSK <B,R,Q,MAX>(this->N, tools::Sigma<R>((R)this->sigma), this->bps, this->no_sig2, this->n_frames);\n- else if (this->type == \"USER\" ) return new module::Modem_user <B,R,Q,MAX>(this->N, this->const_path, tools::Sigma<R>((R)this->sigma), this->bps, this->no_sig2, this->n_frames);\n- else if (this->type == \"CPM\" ) return new module::Modem_CPM <B,R,Q,MAX>(this->N, tools::Sigma<R>((R)this->sigma), this->bps, this->upf, this->cpm_L, this->cpm_k, this->cpm_p, this->mapping, this->wave_shape, this->no_sig2, this->n_frames);\n+ if (this->type == \"BPSK\" ) return new module::Modem_BPSK <B,R,Q >(this->N, tools::Sigma<R>((R)this->noise), this->no_sig2, this->n_frames);\n+ else if (this->type == \"BPSK_FAST\") return new module::Modem_BPSK_fast<B,R,Q >(this->N, tools::Sigma<R>((R)this->noise), this->no_sig2, this->n_frames);\n+ else if (this->type == \"OOK\" ) return new module::Modem_OOK <B,R,Q >(this->N, tools::Sigma<R>((R)this->noise), this->no_sig2, this->n_frames);\n+ else if (this->type == \"PAM\" ) return new module::Modem_PAM <B,R,Q,MAX>(this->N, tools::Sigma<R>((R)this->noise), this->bps, this->no_sig2, this->n_frames);\n+ else if (this->type == \"QAM\" ) return new module::Modem_QAM <B,R,Q,MAX>(this->N, tools::Sigma<R>((R)this->noise), this->bps, this->no_sig2, this->n_frames);\n+ else if (this->type == \"PSK\" ) return new module::Modem_PSK <B,R,Q,MAX>(this->N, tools::Sigma<R>((R)this->noise), this->bps, this->no_sig2, this->n_frames);\n+ else if (this->type == \"USER\" ) return new module::Modem_user <B,R,Q,MAX>(this->N, this->const_path, tools::Sigma<R>((R)this->noise), this->bps, this->no_sig2, this->n_frames);\n+ else if (this->type == \"CPM\" ) return new module::Modem_CPM <B,R,Q,MAX>(this->N, tools::Sigma<R>((R)this->noise), this->bps, this->upf, this->cpm_L, this->cpm_k, this->cpm_p, this->mapping, this->wave_shape, this->no_sig2, this->n_frames);\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n@@ -271,10 +271,10 @@ template <typename B, typename R, typename Q>\nmodule::Modem<B,R,Q>* Modem::parameters\n::_build_scma() const\n{\n- if (this->psi == \"PSI0\") return new module::Modem_SCMA <B,R,Q,tools::psi_0<Q>>(this->N, tools::Sigma<R>((R)this->sigma), this->bps, this->no_sig2, this->n_ite, this->n_frames);\n- else if (this->psi == \"PSI1\") return new module::Modem_SCMA <B,R,Q,tools::psi_1<Q>>(this->N, tools::Sigma<R>((R)this->sigma), this->bps, this->no_sig2, this->n_ite, this->n_frames);\n- else if (this->psi == \"PSI2\") return new module::Modem_SCMA <B,R,Q,tools::psi_2<Q>>(this->N, tools::Sigma<R>((R)this->sigma), this->bps, this->no_sig2, this->n_ite, this->n_frames);\n- else if (this->psi == \"PSI3\") return new module::Modem_SCMA <B,R,Q,tools::psi_3<Q>>(this->N, tools::Sigma<R>((R)this->sigma), this->bps, this->no_sig2, this->n_ite, this->n_frames);\n+ if (this->psi == \"PSI0\") return new module::Modem_SCMA <B,R,Q,tools::psi_0<Q>>(this->N, tools::Sigma<R>((R)this->noise), this->bps, this->no_sig2, this->n_ite, this->n_frames);\n+ else if (this->psi == \"PSI1\") return new module::Modem_SCMA <B,R,Q,tools::psi_1<Q>>(this->N, tools::Sigma<R>((R)this->noise), this->bps, this->no_sig2, this->n_ite, this->n_frames);\n+ else if (this->psi == \"PSI2\") return new module::Modem_SCMA <B,R,Q,tools::psi_2<Q>>(this->N, tools::Sigma<R>((R)this->noise), this->bps, this->no_sig2, this->n_ite, this->n_frames);\n+ else if (this->psi == \"PSI3\") return new module::Modem_SCMA <B,R,Q,tools::psi_3<Q>>(this->N, tools::Sigma<R>((R)this->noise), this->bps, this->no_sig2, this->n_ite, this->n_frames);\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Modem/Modem.hpp",
"new_path": "src/Factory/Module/Modem/Modem.hpp",
"diff": "@@ -46,7 +46,7 @@ struct Modem : public Factory\nbool no_sig2 = false; // do not divide by (sig^2) / 2 in the demodulation\nint n_ite = 1; // number of demodulations/decoding sessions to perform in the BFERI simulations\nint N_fil = 0; // frame size at the output of the filter\n- float sigma = -1.f; // noise variance sigma\n+ float noise = -1.f; // noise value\n// ------- common parameters\nint n_frames = 1;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Launcher/Simulation/BFER_ite.cpp",
"new_path": "src/Launcher/Simulation/BFER_ite.cpp",
"diff": "@@ -71,16 +71,15 @@ void BFER_ite<B,R,Q>\nthis->args.erase({pitl+\"-seed\", \"S\"});\nthis->args.erase({pmdm+\"-fra-size\", \"N\"});\nthis->args.erase({pmdm+\"-fra\", \"F\"});\n- this->args.erase({pmdm+\"-sigma\" });\n+ this->args.erase({pmdm+\"-noise\" });\nthis->args.erase({pchn+\"-fra-size\", \"N\"});\nthis->args.erase({pchn+\"-fra\", \"F\"});\n- this->args.erase({pchn+\"-sigma\" });\n+ this->args.erase({pchn+\"-noise\" });\nthis->args.erase({pchn+\"-seed\", \"S\"});\nthis->args.erase({pchn+\"-add-users\" });\nthis->args.erase({pchn+\"-complex\" });\nthis->args.erase({pqnt+\"-size\", \"N\"});\nthis->args.erase({pqnt+\"-fra\", \"F\"});\n- this->args.erase({pqnt+\"-sigma\" });\nthis->args.erase({pmnt+\"-size\", \"K\"});\nthis->args.erase({pmnt+\"-fra\", \"F\"});\nthis->args.erase({pter+\"-info-bits\", \"K\"});\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Launcher/Simulation/BFER_std.cpp",
"new_path": "src/Launcher/Simulation/BFER_std.cpp",
"diff": "@@ -65,16 +65,15 @@ void BFER_std<B,R,Q>\nthis->args.erase({pcrc+\"-fra\", \"F\"});\nthis->args.erase({pmdm+\"-fra-size\", \"N\"});\nthis->args.erase({pmdm+\"-fra\", \"F\"});\n- this->args.erase({pmdm+\"-sigma\" });\n+ this->args.erase({pmdm+\"-noise\" });\nthis->args.erase({pchn+\"-fra-size\", \"N\"});\nthis->args.erase({pchn+\"-fra\", \"F\"});\n- this->args.erase({pchn+\"-sigma\" });\n+ this->args.erase({pchn+\"-noise\" });\nthis->args.erase({pchn+\"-seed\", \"S\"});\nthis->args.erase({pchn+\"-add-users\" });\nthis->args.erase({pchn+\"-complex\" });\nthis->args.erase({pqnt+\"-size\", \"N\"});\nthis->args.erase({pqnt+\"-fra\", \"F\"});\n- this->args.erase({pqnt+\"-sigma\" });\nthis->args.erase({pmnt+\"-size\", \"K\"});\nthis->args.erase({pmnt+\"-fra\", \"F\"});\nthis->args.erase({pter+\"-info-bits\", \"K\"});\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Launcher/Simulation/EXIT.cpp",
"new_path": "src/Launcher/Simulation/EXIT.cpp",
"diff": "@@ -58,10 +58,10 @@ void EXIT<B,R>\nthis->args.erase({psrc+\"-seed\", \"S\"});\nthis->args.erase({pmdm+\"-fra-size\", \"N\"});\nthis->args.erase({pmdm+\"-fra\", \"F\"});\n- this->args.erase({pmdm+\"-sigma\" });\n+ this->args.erase({pmdm+\"-noise\" });\nthis->args.erase({pchn+\"-fra-size\", \"N\"});\nthis->args.erase({pchn+\"-fra\", \"F\"});\n- this->args.erase({pchn+\"-sigma\" });\n+ this->args.erase({pchn+\"-noise\" });\nthis->args.erase({pchn+\"-seed\", \"S\"});\nthis->args.erase({pchn+\"-add-users\" });\nthis->args.erase({pchn+\"-complex\" });\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/Channel.hpp",
"new_path": "src/Module/Channel/Channel.hpp",
"diff": "@@ -78,6 +78,8 @@ public:\nconst std::vector<R>& get_noise() const;\n+ const tools::Noise<R>* current_noise() const;\n+\nvirtual void set_noise(const tools::Noise<R>& noise);\n/*!\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/Channel.hxx",
"new_path": "src/Module/Channel/Channel.hxx",
"diff": "@@ -100,6 +100,13 @@ set_noise(const tools::Noise<R>& noise)\nthis->check_noise();\n}\n+template<typename R>\n+const tools::Noise <R> *Channel<R>::\n+current_noise() const\n+{\n+ return this->n;\n+}\n+\ntemplate <typename R>\ntemplate <class A>\nvoid Channel<R>::\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/Codec.hpp",
"new_path": "src/Module/Codec/Codec.hpp",
"diff": "@@ -65,7 +65,7 @@ public:\nvirtual Puncturer<B,Q>* get_puncturer();\n- const tools::Noise<float>& get_noise();\n+ const tools::Noise<float>* current_noise() const;\nvirtual void set_noise(const tools::Noise<float>& noise);\nvoid set_noise(const tools::Noise<double>& noise);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/Codec.hxx",
"new_path": "src/Module/Codec/Codec.hxx",
"diff": "@@ -166,8 +166,8 @@ get_puncturer()\n}\ntemplate <typename B, typename Q>\n-const tools::Noise<float>& Codec<B,Q>::\n-get_noise()\n+const tools::Noise<float>* Codec<B,Q>::\n+current_noise() const\n{\nreturn this->n;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/Modem.hpp",
"new_path": "src/Module/Modem/Modem.hpp",
"diff": "@@ -112,7 +112,7 @@ public:\nint get_N_fil() const;\n- const tools::Noise<R>& get_noise();\n+ const tools::Noise<R>* current_noise() const;\nbool is_filter() const;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/Modem.hxx",
"new_path": "src/Module/Modem/Modem.hxx",
"diff": "@@ -225,8 +225,8 @@ get_N_fil() const\n}\ntemplate <typename B, typename R, typename Q>\n-const tools::Noise<R>& Modem<B,R,Q>::\n-get_noise()\n+const tools::Noise<R>* Modem<B,R,Q>::\n+current_noise() const\n{\nreturn this->n;\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Replace arg -sigma to -noise in channel and modem factories; Change get_noise method to current_noise method in Modem and Channel Modules
|
8,483 |
23.04.2018 11:27:15
| -7,200 |
d5af526da040dd1786542d4d3eed7ff3072f4c9b
|
Renaming erased probability to erasure probability
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Channel/Channel.cpp",
"new_path": "src/Factory/Module/Channel/Channel.cpp",
"diff": "@@ -182,7 +182,7 @@ module::Channel<R>* Channel::parameters\nmodule::Channel<R>* c = nullptr;\nif (type == \"USER\") c = new module::Channel_user<R>(N, path, add_users, n_frames);\nelse if (type == \"NO\" ) c = new module::Channel_NO <R>(N, add_users, n_frames);\n- else if (type == \"BEC\" ) c = new module::Channel_BEC <R>(N, seed, tools::Erased_probability<R>((R)this->noise), n_frames);\n+ else if (type == \"BEC\" ) c = new module::Channel_BEC <R>(N, seed, tools::Erasure_probability<R>((R)this->noise), n_frames);\ndelete n;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/BEC/Channel_BEC.cpp",
"new_path": "src/Module/Channel/BEC/Channel_BEC.cpp",
"diff": "@@ -6,7 +6,7 @@ using namespace aff3ct::module;\ntemplate <typename R>\nChannel_BEC<R>\n-::Channel_BEC(const int N, const int seed, const tools::Erased_probability<R>& noise, const int n_frames)\n+::Channel_BEC(const int N, const int seed, const tools::Erasure_probability<R>& noise, const int n_frames)\n: Channel<R>(N, noise, n_frames), uni_dist((R)0, (R)1)\n{\nconst std::string name = \"Channel_BEC\";\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/BEC/Channel_BEC.hpp",
"new_path": "src/Module/Channel/BEC/Channel_BEC.hpp",
"diff": "@@ -29,7 +29,7 @@ protected:\npublic:\nChannel_BEC(const int N, const int seed = 0,\n- const tools::Erased_probability<R>& noise = tools::Erased_probability<R>(),\n+ const tools::Erasure_probability<R>& noise = tools::Erasure_probability<R>(),\nconst int n_frames = 1);\nvirtual ~Channel_BEC() = default;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.cpp",
"new_path": "src/Simulation/BFER/BFER.cpp",
"diff": "@@ -164,7 +164,7 @@ void BFER<B,R,Q>\n{\nn = params_BFER.noise_range[params_BFER.noise_range.size() - noise_idx -1];\n- this->noise = new tools::Erased_probability<R>(n);\n+ this->noise = new tools::Erasure_probability<R>(n);\n}\nelse\n{\n"
},
{
"change_type": "DELETE",
"old_path": "src/Tools/Noise/Erased_probability.hpp",
"new_path": null,
"diff": "-#ifndef ERASED_PROBABILITY_HPP_\n-#define ERASED_PROBABILITY_HPP_\n-\n-#include \"Noise.hpp\"\n-\n-namespace aff3ct\n-{\n-namespace tools\n-{\n-\n-template <typename R = float>\n-class Erased_probability : public Noise<R>\n-{\n-public:\n- Erased_probability() = default;\n- explicit Erased_probability(R noise);\n- virtual ~Erased_probability() = default;\n-\n- virtual Noise_type get_type() const;\n-\n- virtual Erased_probability<R>* clone() const;\n-\n- template <typename T>\n- Erased_probability<T>* cast() const\n- {\n- Erased_probability<T>* ep;\n-\n- if (this->is_set())\n- ep = new Erased_probability<T>((T)this->_n.first);\n- else\n- ep = new Erased_probability<T>();\n-\n- return ep;\n- }\n-\n-protected:\n- virtual void check();\n-};\n-\n-template <typename R = float>\n-using EP = Erased_probability<R>;\n-\n-}\n-}\n-\n-#endif //ERASED_PROBABILITY_HPP_\n"
},
{
"change_type": "RENAME",
"old_path": "src/Tools/Noise/Erased_probability.cpp",
"new_path": "src/Tools/Noise/Erasure_probability.cpp",
"diff": "#include <sstream>\n#include \"Tools/Exception/exception.hpp\"\n-#include \"Erased_probability.hpp\"\n+#include \"Erasure_probability.hpp\"\nusing namespace aff3ct;\nusing namespace aff3ct::tools;\ntemplate<typename R>\n-Erased_probability<R>::Erased_probability(R noise)\n+Erasure_probability<R>::Erased_probability(R noise)\n: Noise<R>(noise)\n{\n}\n//template <typename R>\n-//Erased_probability<R>::\n-//Erased_probability(const Erased_probability<R>& other)\n+//Erasure_probability<R>::\n+//Erasure_probability(const Erasure_probability<R>& other)\n//: Noise<R>(other)\n//{\n//}\n//\n//template <typename R>\n-//Erased_probability<R>::\n-//Erased_probability(Erased_probability<R>&& other)\n+//Erasure_probability<R>::\n+//Erasure_probability(Erasure_probability<R>&& other)\n//: Noise<R>(std::move(other))\n//{\n//}\ntemplate <typename R>\n-void Erased_probability<R>::\n+void Erasure_probability<R>::\ncheck()\n{\nauto n = this->get_noise();\n@@ -41,18 +41,18 @@ check()\n}\ntemplate<typename R>\n-Noise_type Erased_probability<R>::get_type() const\n+Noise_type Erasure_probability<R>::get_type() const\n{\nreturn Noise_type::EP;\n}\ntemplate<typename R>\n-Erased_probability<R>* Erased_probability<R>::clone() const\n+Erasure_probability<R>* Erasure_probability<R>::clone() const\n{\n- return new Erased_probability(*this);\n+ return new Erasure_probability(*this);\n}\n// ==================================================================================== explicit template instantiation\n-template class aff3ct::tools::Erased_probability<float>;\n-template class aff3ct::tools::Erased_probability<double>;\n+template class aff3ct::tools::Erasure_probability<float>;\n+template class aff3ct::tools::Erasure_probability<double>;\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Noise/Erasure_probability.hpp",
"diff": "+#ifndef ERASED_PROBABILITY_HPP_\n+#define ERASED_PROBABILITY_HPP_\n+\n+#include \"Noise.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+\n+template <typename R = float>\n+class Erasure_probability : public Noise<R>\n+{\n+public:\n+ Erasure_probability() = default;\n+ explicit Erasure_probability(R noise);\n+ virtual ~Erasure_probability() = default;\n+\n+ virtual Noise_type get_type() const;\n+\n+ virtual Erasure_probability<R>* clone() const;\n+\n+ template <typename T>\n+ Erasure_probability<T>* cast() const\n+ {\n+ Erasure_probability<T>* ep;\n+\n+ if (this->is_set())\n+ ep = new Erasure_probability<T>((T)this->_n.first);\n+ else\n+ ep = new Erasure_probability<T>();\n+\n+ return ep;\n+ }\n+\n+protected:\n+ virtual void check();\n+};\n+\n+template <typename R = float>\n+using EP = Erasure_probability<R>;\n+\n+}\n+}\n+\n+#endif //ERASED_PROBABILITY_HPP_\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Noise/Noise.hpp",
"new_path": "src/Tools/Noise/Noise.hpp",
"diff": "@@ -59,7 +59,7 @@ protected:\n#include \"Sigma.hpp\"\n#include \"Received_optical_power.hpp\"\n-#include \"Erased_probability.hpp\"\n+#include \"Erasure_probability.hpp\"\nnamespace aff3ct\n{\n@@ -73,7 +73,7 @@ Noise<T>* cast(const Noise<R>& n)\n// switch(n.get_type())\n// {\n// case Noise<R>::Noise_type::SIGMA: cast_n = dynamic_cast<const Sigma <R>&>(n).cast<T>(); break;\n-// case Noise<R>::Noise_type::EP: cast_n = dynamic_cast<const Erased_probability <R>&>(n).cast<T>(); break;\n+// case Noise<R>::Noise_type::EP: cast_n = dynamic_cast<const Erasure_probability <R>&>(n).cast<T>(); break;\n// case Noise<R>::Noise_type::ROP: cast_n = dynamic_cast<const Received_optical_power<R>&>(n).cast<T>(); break;\n// }\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Renaming erased probability to erasure probability
|
8,483 |
23.04.2018 11:31:42
| -7,200 |
ce2ba7cc2961a26f3c4bc63bf6d9f1608ac40297
|
Change default noise to sigma in modem instead of 'Noise' that is virtual so couldn't be default value
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/BPSK/Modem_BPSK.hpp",
"new_path": "src/Module/Modem/BPSK/Modem_BPSK.hpp",
"diff": "@@ -15,7 +15,7 @@ private:\nR two_on_square_sigma;\npublic:\n- Modem_BPSK(const int N, const tools::Noise<R>& noise = tools::Noise<R>(), const bool disable_sig2 = false, const int n_frames = 1);\n+ Modem_BPSK(const int N, const tools::Noise<R>& noise = tools::Sigma<R>(), const bool disable_sig2 = false, const int n_frames = 1);\nvirtual ~Modem_BPSK();\nvirtual void set_noise(const tools::Noise<R>& noise);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/BPSK/Modem_BPSK_fast.hpp",
"new_path": "src/Module/Modem/BPSK/Modem_BPSK_fast.hpp",
"diff": "@@ -15,7 +15,7 @@ private:\nR two_on_square_sigma;\npublic:\n- Modem_BPSK_fast(const int N, const tools::Noise<R>& noise = tools::Noise<R>(), const bool disable_sig2 = false,\n+ Modem_BPSK_fast(const int N, const tools::Noise<R>& noise = tools::Sigma<R>(), const bool disable_sig2 = false,\nconst int n_frames = 1);\nvirtual ~Modem_BPSK_fast();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/CPM/Modem_CPM.hpp",
"new_path": "src/Module/Modem/CPM/Modem_CPM.hpp",
"diff": "@@ -47,7 +47,7 @@ protected:\npublic:\nModem_CPM(const int N,\n- const tools::Noise<R>& noise = tools::Noise<R>(),\n+ const tools::Noise<R>& noise = tools::Sigma<R>(),\nconst int bits_per_symbol = 1,\nconst int sampling_factor = 5,\nconst int cpm_L = 3,\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/Modem.hpp",
"new_path": "src/Module/Modem/Modem.hpp",
"diff": "@@ -78,7 +78,7 @@ public:\n* \\param n_frames: number of frames to process in the Modem.\n* \\param name: Modem's name.\n*/\n- Modem(const int N, const int N_mod, const int N_fil, const tools::Noise<R>& noise = tools::Noise<R>(), const int n_frames = 1);\n+ Modem(const int N, const int N_mod, const int N_fil, const tools::Noise<R>& noise = tools::Sigma<R>(), const int n_frames = 1);\n/*!\n* \\brief Constructor (assumes that nothing is done in the filtering process).\n@@ -88,7 +88,7 @@ public:\n* \\param n_frames: number of frames to process in the Modem.\n* \\param name: Modem's name.\n*/\n- Modem(const int N, const int N_mod, const tools::Noise<R>& noise = tools::Noise<R>(), const int n_frames = 1);\n+ Modem(const int N, const int N_mod, const tools::Noise<R>& noise = tools::Sigma<R>(), const int n_frames = 1);\n/*!\n* \\brief Constructor (assumes that nothing is done in the filtering process).\n@@ -97,7 +97,7 @@ public:\n* \\param n_frames: number of frames to process in the Modem.\n* \\param name: Modem's name.\n*/\n- Modem(const int N, const tools::Noise<R>& noise = tools::Noise<R>(), const int n_frames = 1);\n+ Modem(const int N, const tools::Noise<R>& noise = tools::Sigma<R>(), const int n_frames = 1);\nvoid init_processes();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/OOK/Modem_OOK.hpp",
"new_path": "src/Module/Modem/OOK/Modem_OOK.hpp",
"diff": "@@ -15,7 +15,7 @@ protected:\nR sigma_factor;\npublic:\n- Modem_OOK(const int N, const tools::Noise<R>& noise = tools::Noise<R>(), const bool disable_sig2 = false, const int n_frames = 1);\n+ Modem_OOK(const int N, const tools::Noise<R>& noise = tools::Sigma<R>(), const bool disable_sig2 = false, const int n_frames = 1);\nvirtual ~Modem_OOK();\nvirtual void set_noise(const tools::Noise<R>& noise);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/PAM/Modem_PAM.hpp",
"new_path": "src/Module/Modem/PAM/Modem_PAM.hpp",
"diff": "@@ -23,7 +23,7 @@ private:\nR inv_sigma2;\npublic:\n- Modem_PAM(const int N, const tools::Noise<R>& noise = tools::Noise<R>(),\n+ Modem_PAM(const int N, const tools::Noise<R>& noise = tools::Sigma<R>(),\nconst int bits_per_symbol = 1, const bool disable_sig2 = false,\nconst int n_frames = 1);\nvirtual ~Modem_PAM();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/PSK/Modem_PSK.hpp",
"new_path": "src/Module/Modem/PSK/Modem_PSK.hpp",
"diff": "@@ -23,7 +23,7 @@ private:\nR inv_sigma2;\npublic:\n- Modem_PSK(const int N, const tools::Noise<R>& noise = tools::Noise<R>(), const int bits_per_symbol = 2, const bool disable_sig2 = false,\n+ Modem_PSK(const int N, const tools::Noise<R>& noise = tools::Sigma<R>(), const int bits_per_symbol = 2, const bool disable_sig2 = false,\nconst int n_frames = 1);\nvirtual ~Modem_PSK();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/QAM/Modem_QAM.hpp",
"new_path": "src/Module/Modem/QAM/Modem_QAM.hpp",
"diff": "@@ -24,7 +24,7 @@ private:\nR inv_sigma2;\npublic:\n- Modem_QAM(const int N, const tools::Noise<R>& noise = tools::Noise<R>(), const int bits_per_symbol = 2, const bool disable_sig2 = false,\n+ Modem_QAM(const int N, const tools::Noise<R>& noise = tools::Sigma<R>(), const int bits_per_symbol = 2, const bool disable_sig2 = false,\nconst int n_frames = 1);\nvirtual ~Modem_QAM();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/SCMA/Modem_SCMA.hpp",
"new_path": "src/Module/Modem/SCMA/Modem_SCMA.hpp",
"diff": "@@ -24,7 +24,7 @@ private:\nconst int n_ite;\npublic:\n- Modem_SCMA(const int N, const tools::Noise<R>& noise = tools::Noise<R>(), const int bps = 3, const bool disable_sig2 = false,\n+ Modem_SCMA(const int N, const tools::Noise<R>& noise = tools::Sigma<R>(), const int bps = 3, const bool disable_sig2 = false,\nconst int n_ite = 1, const int n_frames = 6);\nvirtual ~Modem_SCMA();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/User/Modem_user.hpp",
"new_path": "src/Module/Modem/User/Modem_user.hpp",
"diff": "@@ -25,7 +25,7 @@ private:\npublic:\n- Modem_user(const int N, const std::string &const_path, const tools::Noise<R>& noise = tools::Noise<R>(),\n+ Modem_user(const int N, const std::string &const_path, const tools::Noise<R>& noise = tools::Sigma<R>(),\nconst int bits_per_symbol = 2, const bool disable_sig2 = false, const int n_frames = 1);\nvirtual ~Modem_user();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Noise/Erasure_probability.cpp",
"new_path": "src/Tools/Noise/Erasure_probability.cpp",
"diff": "@@ -7,7 +7,7 @@ using namespace aff3ct;\nusing namespace aff3ct::tools;\ntemplate<typename R>\n-Erasure_probability<R>::Erased_probability(R noise)\n+Erasure_probability<R>::Erasure_probability(R noise)\n: Noise<R>(noise)\n{\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Change default noise to sigma in modem instead of 'Noise' that is virtual so couldn't be default value
|
8,483 |
23.04.2018 11:33:50
| -7,200 |
e89945d2e4b608b033a8d6fb7f51d35ce73322ee
|
Remove task idx when creating the task
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"diff": "@@ -19,7 +19,7 @@ Monitor_BFER<B>\nconst std::string name = \"Monitor_BFER\";\nthis->set_name(name);\n- auto &p = this->create_task(\"check_errors\", (int)mnt::tsk::check_errors);\n+ auto &p = this->create_task(\"check_errors\");\nauto &ps_U = this->template create_socket_in<B>(p, \"U\", this->size * this->n_frames);\nauto &ps_V = this->template create_socket_in<B>(p, \"V\", this->size * this->n_frames);\nthis->create_codelet(p, [this, &ps_U, &ps_V]() -> int\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Remove task idx when creating the task
|
8,483 |
23.04.2018 11:42:01
| -7,200 |
eec911785edeb4727051fce336b6d942f19cbbda
|
Change back weak-rate to 0.8 instead of 0.9
|
[
{
"change_type": "MODIFY",
"old_path": "ci/test-regression.py",
"new_path": "ci/test-regression.py",
"diff": "@@ -27,7 +27,7 @@ parser.add_argument('--sensibility', action='store', dest='sensibility', ty\nparser.add_argument('--n-threads', action='store', dest='nThreads', type=int, default=0, help='Number of threads to use in the simulation (0 = all available).') # choices=xrange(0, +ing)\nparser.add_argument('--recursive-scan', action='store', dest='recursiveScan', type=bool, default=True, help='If enabled, scan the path of refs recursively.')\nparser.add_argument('--max-fe', action='store', dest='maxFE', type=int, default=100, help='Maximum number of frames errors to simulate per noise point.') # choices=xrange(0, +inf)\n-parser.add_argument('--weak-rate', action='store', dest='weakRate', type=float, default=0.9, help='Rate of valid noise points to passe a test.') # choices=xrange(0.0, 1.0 )\n+parser.add_argument('--weak-rate', action='store', dest='weakRate', type=float, default=0.8, help='Rate of valid noise points to passe a test.') # choices=xrange(0.0, 1.0 )\nparser.add_argument('--max-snr-time', action='store', dest='maxSNRTime', type=int, default=600, help='The maximum amount of time to spend to compute a noise point in seconds (0 = illimited)') # choices=xrange(0, +inf)\nparser.add_argument('--verbose', action='store', dest='verbose', type=bool, default=False, help='Enable the verbose mode.')\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Change back weak-rate to 0.8 instead of 0.9
|
8,483 |
23.04.2018 11:45:22
| -7,200 |
49749c246b103b5a6f9e561f92a624da3964f255
|
Init n to nullptr in constructor
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/BFER/Terminal_BFER.cpp",
"new_path": "src/Tools/Display/Terminal/BFER/Terminal_BFER.cpp",
"diff": "@@ -18,7 +18,8 @@ Terminal_BFER<B,R>\nmonitor (monitor ),\nt_snr (std::chrono::steady_clock::now()),\nreal_time_state(0 ),\n- display_mutinfo(display_mutinfo )\n+ display_mutinfo(display_mutinfo ),\n+ n (nullptr )\n{\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Init n to nullptr in constructor
|
8,483 |
23.04.2018 12:04:58
| -7,200 |
e0e445ba2c86cea981dc8591609355d190252990
|
Fix monitor BFER
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"diff": "@@ -19,7 +19,7 @@ Monitor_BFER<B>\nconst std::string name = \"Monitor_BFER\";\nthis->set_name(name);\n- auto &p = this->create_task(\"check_errors\");\n+ auto &p = this->create_task(\"check_errors\", (int)mnt::tsk::check_errors);\nauto &ps_U = this->template create_socket_in<B>(p, \"U\", this->size * this->n_frames);\nauto &ps_V = this->template create_socket_in<B>(p, \"V\", this->size * this->n_frames);\nthis->create_codelet(p, [this, &ps_U, &ps_V]() -> int\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix monitor BFER
|
8,483 |
23.04.2018 17:00:06
| -7,200 |
5ea72f9b3ddc4a08d7e3738a2bbe985b19fcd17f
|
Modify Distributions to read a distribution only when simulating it
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/Simulation.cpp",
"new_path": "src/Factory/Simulation/Simulation.cpp",
"diff": "@@ -140,9 +140,7 @@ void Simulation::parameters\nif (vals.exist({p+\"-pdf-path\"}))\n{\nthis->pdf_path = vals.at({p+\"-pdf-path\"});\n- std::ifstream file(this->pdf_path);\n-\n- this->noise_range = std::move(tools::Distributions<>::get_noise_range(file));\n+ this->noise_range = tools::Distributions<>(this->pdf_path).get_noise_range();\nif(vals.exist({p+\"-noise-range\", \"R\"}))\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.cpp",
"new_path": "src/Simulation/BFER/BFER.cpp",
"diff": "@@ -82,11 +82,7 @@ BFER<B,R,Q>\n#endif\nif (!params_BFER.pdf_path.empty())\n- {\n- std::ifstream file(params_BFER.pdf_path);\n- distributions = new tools::Distributions<R>(file);\n- }\n-\n+ distributions = new tools::Distributions<R>(params_BFER.pdf_path);\n}\ntemplate <typename B, typename R, typename Q>\n@@ -186,6 +182,11 @@ void BFER<B,R,Q>\nthis->terminal->set_noise(*this->noise);\n+ // manage noise distributions to be sure it exists\n+ if (this->distributions != nullptr)\n+ this->distributions->read_distribution(this->noise->get_noise());\n+\n+\nif (this->params_BFER.err_track_revert)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/Distribution/Distributions.cpp",
"new_path": "src/Tools/Math/Distribution/Distributions.cpp",
"diff": "#include \"Distributions.hpp\"\nusing namespace aff3ct;\n-using namespace tools;\n+using namespace aff3ct::tools;\n+template<typename R>\n+const int aff3ct::tools::Distributions<R>::saved_noise_precision = 1e6;\ntemplate<typename R>\nDistributions<R>::\n-Distributions()\n+Distributions(const std::string& filename, bool read_all_at_init)\n+: f_distributions(filename)\n+{\n+ if (f_distributions.fail())\n{\n+ std::stringstream message;\n+ message << \"'filename' file name is not valid: f_distributions failbit is set.\";\n+ throw runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ read_noise_range();\n+ if (read_all_at_init)\n+ for(unsigned i = 0; i < this->noise_file_index.size(); i++)\n+ read_distribution_from_file(i);\n}\ntemplate<typename R>\nDistributions<R>::\n-Distributions(std::ifstream& f_distributions)\n+~Distributions()\n{\n- if (f_distributions.fail())\n+ for (auto& d : distributions)\n+ if (d.second != nullptr)\n+ delete d.second;\n+}\n+\n+template<typename R>\n+std::vector<R> Distributions<R>::\n+get_noise_range() const\n{\n- std::stringstream message;\n- message << \"'f_distributions' file descriptor is not valid: failbit is set.\";\n- throw runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ auto nr = this->noise_range;\n+ std::sort(nr.begin(), nr.end());\n+\n+ return nr;\n}\n+template<typename R>\n+void Distributions<R>::\n+read_noise_range()\n+{\n+ file_go_to_pos(); // set the stream at the beginning of the file\nstd::string line;\nstd::getline(f_distributions, line);\n- auto desc = tools::Splitter::split(line, \"\", \"\", \" \");\n- auto ROP_pos = std::find(desc.begin(), desc.end(), \"ROP\");\n- auto x_pos = std::find(desc.begin(), desc.end(), \"x\" );\n- auto y0_pos = std::find(desc.begin(), desc.end(), \"y0\" );\n- auto y1_pos = std::find(desc.begin(), desc.end(), \"y1\" );\n+ this->desc = tools::Splitter::split(line, \"\", \"\", \" \");\n+\n+ // get the data order\n+ this->ROP_pos = std::distance(this->desc.begin(), std::find(this->desc.begin(), this->desc.end(), \"ROP\"));\n+ this->x_pos = std::distance(this->desc.begin(), std::find(this->desc.begin(), this->desc.end(), \"x\" ));\n+ this->y0_pos = std::distance(this->desc.begin(), std::find(this->desc.begin(), this->desc.end(), \"y0\" ));\n+ this->y1_pos = std::distance(this->desc.begin(), std::find(this->desc.begin(), this->desc.end(), \"y1\" ));\n- if (ROP_pos == desc.end())\n+ if (this->ROP_pos == desc.size())\nthrow runtime_error(__FILE__, __LINE__, __func__, \"No ROP in the description of the distribution\");\n- if (x_pos == desc.end())\n+ if (this->x_pos == desc.size())\nthrow runtime_error(__FILE__, __LINE__, __func__, \"No x in the description of the distribution\");\n- if (y0_pos == desc.end())\n+ if (this->y0_pos == desc.size())\nthrow runtime_error(__FILE__, __LINE__, __func__, \"No y0 in the description of the distribution\");\n- if (y1_pos == desc.end())\n+ if (this->y1_pos == desc.size())\nthrow runtime_error(__FILE__, __LINE__, __func__, \"No y1 in the description of the distribution\");\n- std::string ROP;\n- std::vector<std::string> v_x ;\n- std::vector<std::string> v_y0;\n- std::vector<std::string> v_y1;\n-\nwhile (!f_distributions.eof())\n{\n- for (auto it = desc.begin(); it != desc.end(); it++)\n+ auto pos = f_distributions.tellg();\n+ this->noise_file_index.push_back(pos);\n+\n+ for (unsigned i = 0; i < this->desc.size(); i++)\n{\nif (f_distributions.eof())\nbreak;\nstd::getline(f_distributions, line);\n-\nif (line.empty())\n{\n- it--;\n+ i--;\ncontinue;\n}\n- if (it == ROP_pos)\n- ROP = std::move(line);\n- else if (it == x_pos)\n- v_x = std::move(tools::Splitter::split(line, \"\", \"\", \" \"));\n- else if (it == y0_pos)\n- v_y0 = std::move(tools::Splitter::split(line, \"\", \"\", \" \"));\n- else if (it == y1_pos)\n- v_y1 = std::move(tools::Splitter::split(line, \"\", \"\", \" \"));\n- else\n- tools::runtime_error(__FILE__, __LINE__, __func__);\n+ if (i == ROP_pos)\n+ this->noise_range.push_back((R) stof(line));\n+ }\n}\n- if (f_distributions.eof())\n- break;\n+ this->noise_file_index.resize(this->noise_range.size()); // delete the extra noise positions if any\n+}\n- if (v_x.size() != v_y0.size() || v_x.size() != v_y1.size() )\n+template<typename R>\n+bool Distributions<R>::\n+has_distribution(R noise) const\n{\n- std::stringstream message;\n- message << \"'v_x' does not have the same size than 'v_y0' or 'v_y1' \"\n- << \"('v_x.size()' = \" << v_x.size() << \", 'v_y0.size()' = \" << v_y0.size()\n- << \", 'v_y1.size()' = \" << v_y1.size() << \" and 'ROP' = \" << ROP << \").\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ return this->distributions.find(calibrated_noise(noise)) != this->distributions.end();\n}\n-\n- try\n+template<typename R>\n+const Distribution<R>* const Distributions<R>::\n+get_distribution(R noise) const\n{\n- auto ROP_R = (R)stof(ROP);\n-\n- std::vector<R> v_x_R(v_x.size()) ;\n- std::vector<std::vector<R>> v_y_R(2);\n- for(auto& v : v_y_R)\n- v.resize(v_x.size());\n+ auto it = this->distributions.find(calibrated_noise(noise));\n+ if (it == this->distributions.end())\n+ return nullptr;\n- // convert string vector to 'R' vector\n- for(unsigned j = 0; j < v_x_R.size(); j++)\n- {\n- v_x_R [j] = (R)stof(v_x [j]);\n- v_y_R[0][j] = (R)stof(v_y0[j]);\n- v_y_R[1][j] = (R)stof(v_y1[j]);\n+ return it->second;\n}\n- add_distribution(ROP_R, new Distribution<R>(std::move(v_x_R), std::move(v_y_R)));\n- }\n- catch(...)\n+template<typename R>\n+void Distributions<R>::\n+add_distribution(R noise, Distribution<R>* new_distribution)\n+{\n+ if (get_distribution(noise))\n{\nstd::stringstream message;\n- message << \"A value does not represent a float\";\n- throw runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ message << \"A distribution already exist for the given noise power 'noise_power' ('noise' = \" << noise << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n+ this->distributions[calibrated_noise(noise)] = new_distribution;\n}\n+\n+template<typename R>\n+void Distributions<R>::\n+file_go_to_pos(unsigned index)\n+{\n+ f_distributions.clear();\n+\n+ if (index == (unsigned)-1)\n+ f_distributions.seekg(f_distributions.beg); // set the stream cursor at the beginning of the file\n+ else\n+ f_distributions.seekg(this->noise_file_index.at(index)); // set the stream cursor at the right position to read the\n}\ntemplate<typename R>\n-Distributions<R>::\n-~Distributions()\n+void Distributions<R>::\n+read_distribution(R noise)\n{\n- for (auto& d : distributions)\n- if (d.second)\n- delete d.second;\n+ if (has_distribution(noise))\n+ return;\n+\n+ // else has not been read yet\n+\n+ // check if the distribution exists in the file\n+ auto idx = std::find(this->noise_range.begin(),this->noise_range.end(), noise);\n+\n+ if (idx != this->noise_range.end())\n+ read_distribution_from_file(std::distance(this->noise_range.begin(), idx)); // then read it\n}\ntemplate<typename R>\n-std::vector<R> Distributions<R>::\n-get_noise_range(std::ifstream& f_distributions)\n+void Distributions<R>::\n+read_distribution_from_file(unsigned index)\n{\n+ if (has_distribution(this->noise_range.at(index)))\n+ return; // distribution already read\n+\n+ file_go_to_pos(index); // set the stream cursor at the right position to read the asked distribution\n+\nif (f_distributions.fail())\n{\nstd::stringstream message;\n- message << \"'f_distributions' file descriptor is not valid: failbit is set.\";\n+ message << \"Failed to go to the asked position in the file stream 'f_distribution' (this->noise_file_index[\"\n+ << index << \"] = \" << this->noise_file_index[index] << \").\";\nthrow runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- std::string line;\n- std::getline(f_distributions, line);\n- auto desc = tools::Splitter::split(line, \"\", \"\", \" \");\n-\n- auto ROP_pos = std::find(desc.begin(), desc.end(), \"ROP\");\n-\n- std::vector<R> v_noise;\n+ std::string ROP, line;\n+ std::vector<std::string> v_x, v_y0, v_y1;\n- while (!f_distributions.eof())\n- {\n- for (auto it = desc.begin(); it != desc.end(); it++)\n+ for (unsigned i = 0; i < this->desc.size(); i++)\n{\nif (f_distributions.eof())\n- break;\n+ throw runtime_error(__FILE__, __LINE__, __func__, \"The file stream is at the end while reading it.\");\nstd::getline(f_distributions, line);\n+\nif (line.empty())\n{\n- it--;\n+ i--;\ncontinue;\n}\n- if (it == ROP_pos)\n- v_noise.push_back((R)stof(line));\n- }\n+ if (i == ROP_pos)\n+ ROP = std::move(line);\n+ else if (i == x_pos)\n+ v_x = tools::Splitter::split(line, \"\", \"\", \" \");\n+ else if (i == y0_pos)\n+ v_y0 = tools::Splitter::split(line, \"\", \"\", \" \");\n+ else if (i == y1_pos)\n+ v_y1 = tools::Splitter::split(line, \"\", \"\", \" \");\n+ else\n+ tools::runtime_error(__FILE__, __LINE__, __func__);\n}\n- std::sort(v_noise.begin(), v_noise.end());\n- return v_noise;\n+ if (v_x.size() != v_y0.size() || v_x.size() != v_y1.size() )\n+ {\n+ std::stringstream message;\n+ message << \"'v_x' does not have the same size than 'v_y0' or 'v_y1' \"\n+ << \"('v_x.size()' = \" << v_x.size() << \", 'v_y0.size()' = \" << v_y0.size()\n+ << \", 'v_y1.size()' = \" << v_y1.size() << \" and 'ROP' = \" << ROP << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n-template<typename R>\n-const Distribution<R>* const Distributions<R>::\n-get_distribution(const R noise_power) const\n+ try\n{\n- int np = (int)(noise_power*(R)saved_noise_precision);\n+ auto ROP_R = (R)stof(ROP);\n- auto it_dis = this->distributions.find(np);\n+ if (ROP_R != this->noise_range[index])\n+ {\n+ std::stringstream message;\n+ message << \"'ROP_R' does not match with the asked distribution 'this->noise_range[index]'\"\n+ << \"('ROP_R' = \" << ROP_R << \" and 'this->noise_range[\" << index << \"]' = \" << this->noise_range[index] << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n- if (it_dis == this->distributions.end())\n- return nullptr;\n+ std::vector<R> v_x_R(v_x.size()) ;\n+ std::vector<std::vector<R>> v_y_R(2);\n+ for(auto& v : v_y_R)\n+ v.resize(v_x.size());\n- return it_dis->second;\n+ // convert string vector to 'R' vector\n+ for(unsigned j = 0; j < v_x_R.size(); j++)\n+ {\n+ v_x_R [j] = (R)stof(v_x [j]);\n+ v_y_R[0][j] = (R)stof(v_y0[j]);\n+ v_y_R[1][j] = (R)stof(v_y1[j]);\n}\n-template<typename R>\n-void Distributions<R>::\n-add_distribution(R noise_power, Distribution<R>* new_distribution)\n-{\n- if (get_distribution(noise_power))\n+ add_distribution(ROP_R, new Distribution<R>(std::move(v_x_R), std::move(v_y_R)));\n+ }\n+ catch(...)\n{\nstd::stringstream message;\n- message << \"A distribution already exist for the given noise power 'noise_power' ('noise_power' = \" << noise_power << \").\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ message << \"A value does not represent a float\";\n+ throw runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n-\n- int np = (int)(noise_power*(R)saved_noise_precision);\n-\n- this->distributions[np] = new_distribution;\n}\n+template<typename R>\n+int Distributions<R>::\n+calibrated_noise(R noise)\n+{\n+ return (int)(noise*(R)saved_noise_precision);\n+}\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/Distribution/Distributions.hpp",
"new_path": "src/Tools/Math/Distribution/Distributions.hpp",
"diff": "#include <fstream>\n#include <string>\n#include <map>\n+#include <vector>\n#include \"Distribution.hpp\"\n@@ -17,25 +18,44 @@ namespace tools\ntemplate <typename R = float>\nclass Distributions\n{\n+public:\n+ static const int saved_noise_precision;\n+\nprotected:\nstd::map<int, Distribution<R>*> distributions; // distributions in function of the noise power\n- const int saved_noise_precision = 1e6;\n+ std::ifstream f_distributions;\n-public:\n- Distributions();\n+ std::vector<R> noise_range;\n+ std::vector<std::streampos> noise_file_index;\n- Distributions(std::ifstream& f_distributions);\n+ // the data description\n+ std::vector<std::string> desc;\n+ size_t ROP_pos;\n+ size_t x_pos ;\n+ size_t y0_pos ;\n+ size_t y1_pos ;\n+\n+public:\n+ explicit Distributions(const std::string& filename, bool read_all_at_init = false);\nvirtual ~Distributions();\n- const Distribution<R>* const get_distribution(const R noise_power) const;\n+ bool has_distribution(R noise) const;\n+ const Distribution<R>* const get_distribution(R noise) const;\n+ void read_distribution(R noise);\n- static std::vector<R> get_noise_range(std::ifstream& f_distributions);\n+ std::vector<R> get_noise_range() const;\n+protected:\n/*\n* Add a distribution 'new_distribution' associated with the noise power 'noise_power'.\n*/\n- void add_distribution(R noise_power, Distribution<R>* new_distribution);\n+ void add_distribution(R noise, Distribution<R>* new_distribution);\n+ void read_noise_range();\n+ void read_distribution_from_file(unsigned index);\n+\n+ static int calibrated_noise(R noise);\n+ void file_go_to_pos(unsigned index = -1);\n};\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Modify Distributions to read a distribution only when simulating it
|
8,483 |
23.04.2018 17:16:07
| -7,200 |
731086e7aa9621c3e3ba27b1de6e1873a486a994
|
Add the noise value in the error list
|
[
{
"change_type": "MODIFY",
"old_path": "ci/test-regression.py",
"new_path": "ci/test-regression.py",
"diff": "@@ -300,7 +300,7 @@ class tableStats:\nif self.sensibility != 0:\nself.rateSensibility = (self.avgSensibility / self.sensibility) * 100\nelse:\n- self.rateSensibility = float(100)\n+ self.rateSensibility = float(0)\ndef errorMessage(self, idx):\n@@ -374,7 +374,7 @@ class compStats:\nif self.hasError():\nmessage += \"---- -------|----------------------------------------------------------------------- \\n\"\n- message += \"---- name | errors list {new -> ref} \\n\"\n+ message += \"---- name | errors list {noise: new -> ref} \\n\"\nmessage += \"---- -------|----------------------------------------------------------------------- \\n\"\nfor d in self.dataList:\nif d.hasError():\n@@ -385,7 +385,7 @@ class compStats:\nmessage += \"\\n---- | \"\n- message += \"{\" + format_e(e[0]) + \" -> \" + format_e(e[1]) + \"}\"\n+ message += \"{\" + format_e(self.dataCur.Noise[d.errorsPos[el]]) + \": \" + format_e(e[0]) + \" -> \" + format_e(e[1]) + \"}\"\nel += 1\nif el < len(d.errorsList):\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add the noise value in the error list
|
8,483 |
24.04.2018 12:35:13
| -7,200 |
b931d4b7f1a7b52cb0e9bb29aadc95043d8f55c5
|
Add arguments sim-max-frame and sim-crit-nostop
sim-max-frame stops the current noise point to the given number of played frames.
when sim-crit-nostop does not stop completely the simulation but goes to the next point when sim-max-frame or sim-stop-time have been checked
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/Simulation.cpp",
"new_path": "src/Factory/Simulation/Simulation.cpp",
"diff": "@@ -71,7 +71,21 @@ void Simulation::parameters\nargs.add(\n{p+\"-stop-time\"},\ntools::Integer(tools::Positive()),\n- \"time in sec after what the current simulatated noise should stop (0 is infinite).\");\n+ \"time in sec after what the current simulatated noise stops (0 is infinite).\",\n+ tools::arg_rank::ADV);\n+\n+ args.add(\n+ {p+\"-max-frame\"},\n+ tools::Integer(tools::Positive()),\n+ \"maximum number of frames to play after what the current simulatated noise stops (0 is infinite).\",\n+ tools::arg_rank::ADV);\n+\n+ args.add(\n+ {p+\"-crit-nostop\"},\n+ tools::None(),\n+ \"The stop criteria arguments -stop-time or -max-frame kill the current simulatated noise point\"\n+ \" but not the simulation.\",\n+ tools::arg_rank::ADV);\nargs.add(\n{p+\"-debug\"},\n@@ -139,9 +153,11 @@ void Simulation::parameters\nif(vals.exist({p+\"-pyber\" })) this->pyber = vals.at ({p+\"-pyber\" });\nif(vals.exist({p+\"-stop-time\" })) this->stop_time = seconds(vals.to_int ({p+\"-stop-time\"}));\n+ if(vals.exist({p+\"-max-frame\" })) this->max_frame = vals.to_int ({p+\"-max-frame\"});\nif(vals.exist({p+\"-seed\", \"S\"})) this->global_seed = vals.to_int ({p+\"-seed\", \"S\"});\nif(vals.exist({p+\"-stats\" })) this->statistics = true;\nif(vals.exist({p+\"-debug\" })) this->debug = true;\n+ if(vals.exist({p+\"-crit-nostop\" })) this->crit_nostop = true;\nif(vals.exist({p+\"-debug-limit\", \"d\"}))\n{\nthis->debug = true;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/Simulation.hpp",
"new_path": "src/Factory/Simulation/Simulation.hpp",
"diff": "@@ -34,9 +34,11 @@ struct Simulation : Launcher\n#endif\nstd::chrono::seconds stop_time = std::chrono::seconds(0);\nstd::string pyber = \"\";\n+ unsigned max_frame = 0;\nbool debug = false;\nbool debug_hex = false;\nbool statistics = false;\n+ bool crit_nostop = false;\nint n_threads = 1;\nint local_seed = 0;\nint global_seed = 0;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.cpp",
"new_path": "src/Simulation/BFER/BFER.cpp",
"diff": "@@ -35,8 +35,6 @@ BFER<B,R,Q>\nbit_rate((float)params_BFER.src->K / (float)params_BFER.cdc->N),\nnoise(nullptr),\n- max_fra(0),\n-\nmonitor (params_BFER.n_threads, nullptr),\nmonitor_red( nullptr),\ndumper (params_BFER.n_threads, nullptr),\n@@ -194,8 +192,11 @@ void BFER<B,R,Q>\nstd::ifstream file(params_BFER.chn->path, std::ios::binary);\nif (file.is_open())\n{\n+ unsigned max_fra;\nfile.read((char*)&max_fra, sizeof(max_fra));\nfile.close();\n+\n+ *const_cast<unsigned*>(¶ms_BFER.max_frame) = max_fra;\n}\nelse\n{\n@@ -282,9 +283,9 @@ void BFER<B,R,Q>\nthis->dumper_red->clear();\n}\n- if (!params_BFER.err_track_revert && !module::Monitor::is_interrupt() &&\n+ if (!params_BFER.crit_nostop && !params_BFER.err_track_revert && !module::Monitor::is_interrupt() &&\nthis->monitor_red->get_n_fe() < this->monitor_red->get_fe_limit() &&\n- (max_fra == 0 || this->monitor_red->get_n_fe() < max_fra))\n+ (params_BFER.max_frame == 0 || this->monitor_red->get_n_fe() < params_BFER.max_frame))\nmodule::Monitor::stop();\nthis->monitor_red->reset();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.hpp",
"new_path": "src/Simulation/BFER/BFER.hpp",
"diff": "@@ -43,8 +43,6 @@ protected:\ntools::Noise<R>* noise; // current noise simulated\n- unsigned max_fra;\n-\n// the monitors of the the BFER simulation\nstd::vector<module::Monitor_BFER <B>*> monitor;\nmodule::Monitor_BFER_reduction<B>* monitor_red;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/Iterative/Threads/BFER_ite_threads.cpp",
"new_path": "src/Simulation/BFER/Iterative/Threads/BFER_ite_threads.cpp",
"diff": "@@ -338,7 +338,7 @@ void BFER_ite_threads<B,R,Q>\nwhile ((!this->monitor_red->fe_limit_achieved()) && // while max frame error count has not been reached\n(this->params_BFER_ite.stop_time == seconds(0) ||\n(steady_clock::now() - t_snr) < this->params_BFER_ite.stop_time) &&\n- (this->monitor_red->get_n_analyzed_fra() < this->max_fra || this->max_fra == 0))\n+ (this->params_BFER_ite.max_frame == 0 || this->monitor_red->get_n_analyzed_fra() < this->params_BFER_ite.max_frame))\n{\nif (this->params_BFER_ite.debug)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/Standard/Threads/BFER_std_threads.cpp",
"new_path": "src/Simulation/BFER/Standard/Threads/BFER_std_threads.cpp",
"diff": "@@ -267,7 +267,7 @@ void BFER_std_threads<B,R,Q>\nwhile (!this->monitor_red->fe_limit_achieved() && // while max frame error count has not been reached\n(this->params_BFER_std.stop_time == seconds(0) ||\n(steady_clock::now() - t_snr) < this->params_BFER_std.stop_time) &&\n- (this->monitor_red->get_n_analyzed_fra() < this->max_fra || this->max_fra == 0))\n+ (this->params_BFER_std.max_frame == 0 || this->monitor_red->get_n_analyzed_fra() < this->params_BFER_std.max_frame))\n{\nif (this->params_BFER_std.debug)\n{\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add arguments sim-max-frame and sim-crit-nostop
sim-max-frame stops the current noise point to the given number of played frames.
when sim-crit-nostop does not stop completely the simulation but goes to the next point when sim-max-frame or sim-stop-time have been checked
|
8,483 |
24.04.2018 16:37:54
| -7,200 |
82eb5462a0f8bdc05aefea051cbba252022363e9
|
Develop Histogram as a class; Use it to dump the Noise pdf of the different missions
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"diff": "#include \"Tools/Perf/common/hamming_distance.h\"\n#include \"Tools/Math/utils.h\"\n+using namespace aff3ct;\nusing namespace aff3ct::module;\ntemplate <typename B, typename R>\n@@ -66,13 +67,18 @@ R Monitor_BFER<B,R>\nR MI_sum = 0;\nfor (auto f = f_start; f < f_stop; f++)\n- MI_sum += this->_get_mutual_info(X + f * this->K,\n- Y + f * this->K,\n+ MI_sum += this->_get_mutual_info(X + f * this->N,\n+ Y + f * this->N,\nf);\n- return MI_sum / (R)this->n_frames * 10000;\n-}\n+ for(auto i = 0; i < this->n_frames*this->N ; i++)\n+ if (X[i])\n+ this->llrs1.add_value(Y[i]);\n+ else\n+ this->llrs0.add_value(Y[i]);\n+ return MI_sum / (R)this->n_frames * 10000; // return the mut info %10000 instead of %100\n+}\ntemplate <typename B, typename R>\nint Monitor_BFER<B,R>\n@@ -250,6 +256,8 @@ void Monitor_BFER<B,R>\nthis->n_frame_errors = 0;\nthis->n_analyzed_frames = 0;\nthis->MI_sum = 0;\n+ this->llrs0.reset();\n+ this->llrs1.reset();\n}\ntemplate <typename B, typename R>\n@@ -261,6 +269,18 @@ void Monitor_BFER<B,R>\nthis->callbacks_fe_limit_achieved.clear();\n}\n+template<typename B, typename R>\n+const tools::Histogram<R>& Monitor_BFER<B, R>::get_llrs1()\n+{\n+ return llrs1;\n+}\n+\n+template<typename B, typename R>\n+const tools::Histogram<R>& Monitor_BFER<B, R>::get_llrs0()\n+{\n+ return llrs0;\n+}\n+\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER.hpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER.hpp",
"diff": "#include <functional>\n#include \"../Monitor.hpp\"\n+#include \"Tools/Algo/Histogram.hpp\"\nnamespace aff3ct\n{\n@@ -31,10 +32,11 @@ protected:\nstd::vector<std::function<void(unsigned, int )>> callbacks_fe;\nstd::vector<std::function<void( void)>> callbacks_check;\nstd::vector<std::function<void( void)>> callbacks_fe_limit_achieved;\n+ tools::Histogram<R> llrs0, llrs1;\npublic:\nMonitor_BFER(const int K, const int N, const unsigned max_fe, const int n_frames = 1);\n- virtual ~Monitor_BFER(){};\n+ virtual ~Monitor_BFER() = default;\n/*!\n* \\brief Compares two messages and counts the number of frame errors and bit errors.\n@@ -115,6 +117,8 @@ public:\nvirtual unsigned long long get_n_be () const;\nvirtual R get_MI () const;\nvirtual R get_MI_sum () const;\n+ virtual const tools::Histogram<R>& get_llrs0();\n+ virtual const tools::Histogram<R>& get_llrs1();\nfloat get_fer () const;\nfloat get_ber () const;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER_reduction.cpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER_reduction.cpp",
"diff": "#include <sstream>\n#include <fstream>\n#include <sstream>\n+#include <vector>\n#include \"Tools/Exception/exception.hpp\"\n@@ -78,12 +79,6 @@ Monitor_BFER_reduction<B,R>\n}\n}\n-template <typename B, typename R>\n-Monitor_BFER_reduction<B,R>\n-::~Monitor_BFER_reduction()\n-{\n-}\n-\ntemplate <typename B, typename R>\nunsigned long long Monitor_BFER_reduction<B,R>\n::get_n_analyzed_fra() const\n@@ -142,6 +137,24 @@ R Monitor_BFER_reduction<B,R>\nreturn cur_mi;\n}\n+template<typename B, typename R>\n+const tools::Histogram<R> & Monitor_BFER_reduction<B, R>::get_llrs0()\n+{\n+ for (unsigned i = 0; i < monitors.size(); i++)\n+ this->llrs0.add_values(monitors[i]->get_llrs0());\n+\n+ return this->llrs0;\n+}\n+\n+template<typename B, typename R>\n+const tools::Histogram<R>& Monitor_BFER_reduction<B, R>::get_llrs1()\n+{\n+ for (unsigned i = 0; i < monitors.size(); i++)\n+ this->llrs1.add_values(monitors[i]->get_llrs1());\n+\n+ return this->llrs1;\n+}\n+\ntemplate <typename B, typename R>\nvoid Monitor_BFER_reduction<B,R>\n::reset()\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER_reduction.hpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER_reduction.hpp",
"diff": "@@ -19,12 +19,14 @@ private:\npublic:\nexplicit Monitor_BFER_reduction(const std::vector<Monitor_BFER<B,R>*> &monitors);\n- virtual ~Monitor_BFER_reduction();\n+ virtual ~Monitor_BFER_reduction() = default;\nunsigned long long get_n_analyzed_fra_historic() const;\nunsigned long long get_n_analyzed_fra () const;\nunsigned long long get_n_fe () const;\nunsigned long long get_n_be () const;\n+ const tools::Histogram<R>& get_llrs0();\n+ const tools::Histogram<R>& get_llrs1();\nR get_MI () const;\nR get_MI_sum() const;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.cpp",
"new_path": "src/Simulation/BFER/BFER.cpp",
"diff": "#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/Display/Statistics/Statistics.hpp\"\n#include \"Tools/Display/Terminal/BFER/Terminal_BFER.hpp\"\n+#include \"Tools/Algo/Histogram.hpp\"\n#ifdef ENABLE_MPI\n#include \"Module/Monitor/BFER/Monitor_BFER_reduction_mpi.hpp\"\n@@ -286,6 +287,23 @@ void BFER<B,R,Q>\n}\n}\n+ auto slash_pos = params_BFER.pdf_path.rfind('/')+1;\n+ auto dot_pos = params_BFER.pdf_path.find('.', slash_pos);\n+ std::string mission = params_BFER.pdf_path.substr(slash_pos, dot_pos - slash_pos);\n+\n+ auto llrs0 = monitor_red->get_llrs0();\n+ std::string filename0 = mission + \"/\" + mission + \"_pdf_\" + std::to_string(this->noise->get_noise()) + \"_0.txt\";\n+ std::ofstream pdf0(filename0);\n+ pdf0 << \"x; \\\"PDF of \" << mission << \" bit 0 (\" << this->noise->get_noise() << \"dB, on \" << llrs0.get_n_values() << \" values)\\\"\" << std::endl;\n+ llrs0.dump(pdf0, llrs0.get_hist_min(), llrs0.get_hist_max(), 100, true);\n+\n+ auto llrs1 = monitor_red->get_llrs1();\n+ std::string filename1 = mission + \"/\" + mission + \"_pdf_\" + std::to_string(this->noise->get_noise()) + \"_1.txt\";\n+ std::ofstream pdf1(filename1);\n+ pdf1 << \"x; \\\"PDF of \" << mission << \" bit 1 (\" << this->noise->get_noise() << \"dB, on \" << llrs1.get_n_values() << \" values)\\\"\" << std::endl;\n+ llrs1.dump(pdf1, llrs1.get_hist_min(), llrs1.get_hist_max(), 100, true);\n+\n+\nif (this->dumper_red != nullptr && !this->simu_error)\n{\nstd::stringstream s_noise;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.hpp",
"new_path": "src/Simulation/BFER/BFER.hpp",
"diff": "#include \"Tools/Display/Dumper/Dumper.hpp\"\n#include \"Tools/Display/Dumper/Dumper_reduction.hpp\"\n#include \"Tools/Math/Distribution/Distributions.hpp\"\n-#include \"../../Tools/Noise/Noise.hpp\"\n+#include \"Tools/Noise/Noise.hpp\"\n#include \"Module/Module.hpp\"\n#include \"Module/Monitor/Monitor.hpp\"\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Algo/Histogram.hpp",
"diff": "+#ifndef HISTOGRAM_H__\n+#define HISTOGRAM_H__\n+\n+#include <cmath>\n+#include <fstream>\n+#include <vector>\n+#include <map>\n+#include <numeric>\n+\n+#include \"Tools/Exception/exception.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+\n+/*\n+ * @precision the number of decimal took into account in the given values\n+ */\n+template <typename R, unsigned precision = 3>\n+class Histogram\n+{\n+protected:\n+ const R stock_norm = (R)std::pow((unsigned)10,precision);\n+ const R _stock_norm = (R)1/stock_norm;\n+ size_t n_values = 0;\n+ std::map<int, size_t> hist;\n+\n+public:\n+ inline void add_values(const Histogram<R, precision>& other)\n+ {\n+ for (auto& o : other.hist)\n+ {\n+ auto it = hist.find(o.first);\n+ if (it == hist.end())\n+ hist[o.first] = o.second;\n+ else\n+ it->second += o.second;\n+ }\n+\n+ n_values += other.n_values;\n+ }\n+\n+ inline void add_values(const std::vector<R>& draw)\n+ {\n+ add_values(draw.data(), draw.size());\n+ }\n+\n+ inline void add_value(const R& d)\n+ {\n+ add_values(&d, 1);\n+ }\n+\n+ inline void add_values(const R* draw, size_t size)\n+ {\n+ for (size_t i = 0; i < size; i++)\n+ {\n+ auto x = calibrate_val(draw[i]);\n+\n+ auto it = hist.find(x);\n+ if (it == hist.end())\n+ hist[x] = 1;\n+ else\n+ it->second++;\n+ }\n+\n+ n_values += size;\n+ }\n+\n+\n+ /*\n+ * @hist_file is the output stream where will be dump the histogram with one (x,y) couple per line\n+ * @hist_min is the left border of the dump\n+ * @hist_max is the right border of the dump\n+ * @n_intervals the number of intervals needed to dump the asked range (if -1 then dump directly the values)\n+ * @norm_sum_to_1 is to normalize the values to a cumulative integration to 1.\n+ * @cumul_borders is to accumulate the values over the given range [hist_min, hist_max] on those border values\n+ * @data_separator is the tag used to separate x from y when dumping them\n+ * @return 1 when given limits are over ranges\n+ */\n+ int dump(std::ofstream& hist_file, R hist_min = get_hist_min(), R hist_max = get_hist_max(), int n_intervals = 100, bool norm_sum_to_1 = false,\n+ bool cumul_borders = false, const std::string& data_separator = \"; \") const\n+ {\n+ if (hist_min >= hist_max)\n+ return 1;\n+\n+ // find the min max positions in the saved values\n+ auto it_min = hist.lower_bound(calibrate_val(hist_min));\n+ auto it_max = hist.upper_bound(calibrate_val(hist_max));\n+\n+ if (it_min == hist.end() || it_max == hist.begin()) // above limits bounds\n+ return 1;\n+\n+ hist_min = uncalibrate_val(it_min->first);\n+\n+ it_max --;\n+ hist_max = uncalibrate_val(it_max->first);\n+ it_max ++;\n+\n+ R dump_step = (R)n_intervals / (hist_max - hist_min);\n+ R _dump_step = (R)1/dump_step;\n+\n+ std::vector<size_t> dump_hist(n_intervals + 1, 0);\n+\n+ for (auto it = it_min; it != it_max; it++)\n+ {\n+ auto x = (unsigned)round((uncalibrate_val(it->first) - hist_min) * dump_step);\n+ dump_hist[x] += it->second;\n+ }\n+\n+ if (cumul_borders)\n+ {\n+ auto sum = dump_hist.front();\n+ for (auto it = hist.begin(); it != it_min; it++)\n+ sum += it->second;\n+ dump_hist.front() = sum;\n+\n+ sum = dump_hist.back();\n+ for (auto it = it_max; it != hist.end(); it++)\n+ sum += it->second;\n+ dump_hist.back() = sum;\n+ }\n+\n+ R factor = 1;\n+ if (norm_sum_to_1)\n+ factor = (R)1 /(R)n_values;\n+\n+ for (unsigned i = 0; i < dump_hist.size(); ++i)\n+ hist_file << ((R)i * _dump_step + hist_min) << data_separator << std::scientific << dump_hist[i] * factor\n+ << std::endl;\n+\n+ return 0;\n+ }\n+\n+ inline void reset()\n+ {\n+ n_values = 0;\n+ hist.clear();\n+ }\n+\n+ inline int calibrate_val(R val) const\n+ {\n+ return (int)round(val * stock_norm);\n+ }\n+\n+ inline R uncalibrate_val(int val) const\n+ {\n+ return (R)val * _stock_norm;\n+ }\n+\n+ inline R get_hist_min() const\n+ {\n+ return uncalibrate_val(hist.begin()->first);\n+ }\n+\n+ inline R get_hist_max() const\n+ {\n+ return uncalibrate_val(hist.rbegin()->first);\n+ }\n+\n+ inline size_t get_n_values() const\n+ {\n+ return n_values;\n+ }\n+};\n+\n+}\n+}\n+\n+\n+#endif // HISTOGRAM_H__\n\\ No newline at end of file\n"
},
{
"change_type": "DELETE",
"old_path": "src/Tools/Algo/histogram.h",
"new_path": null,
"diff": "-#ifndef HISTOGRAM_H__\n-#define HISTOGRAM_H__\n-\n-#include <cmath>\n-#include <fstream>\n-#include <vector>\n-\n-template <typename R>\n-void histogram(std::ofstream& hist_file, const std::vector<R>& draw, const R hist_min, const R hist_max, const R n_intervals = 100, const bool include_borders = false)\n-{\n- std::vector<R> hist(n_intervals+1, 0);\n-\n- unsigned n_over_range = 0;\n-\n- R norm = (R)n_intervals / (hist_max - hist_min);\n- R _norm = (R)1/norm;\n-\n-\n- for (auto d : draw)\n- {\n- if (d < hist_min || d > hist_max)\n- {\n- n_over_range++;\n-\n- if (include_borders)\n- d = (d < hist_min) ? hist_min : hist_max;\n- else\n- continue;\n- }\n-\n- auto x = round((d - hist_min) * norm);\n- hist[x]++;\n- }\n-\n-\n- for (unsigned i = 0; i < hist.size(); ++i)\n- hist_file << ((R)i * _norm + hist_min) << \"; \" << hist[i]/(R)draw.size() << std::endl;\n-}\n-\n-\n-#endif // HISTOGRAM_H__\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/aff3ct.hpp",
"new_path": "src/aff3ct.hpp",
"diff": "#ifndef AFF3CT_HPP\n#define AFF3CT_HPP\n-#include <Tools/Algo/histogram.h>\n+#include \"Tools/Algo/Histogram.hpp\"\n#include <Tools/Code/Polar/API/functions_polar_inter.h>\n#include <Tools/Code/Polar/API/functions_polar_inter_8bit_bitpacking.h>\n#include <Tools/Code/Polar/API/functions_polar_inter_intra.h>\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Develop Histogram as a class; Use it to dump the Noise pdf of the different missions
|
8,483 |
24.04.2018 16:40:33
| -7,200 |
83a84cdb2d1689cb53248aebf8210cdfcef8d029
|
Comment the dump of the histograms
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"diff": "@@ -71,11 +71,11 @@ R Monitor_BFER<B,R>\nY + f * this->N,\nf);\n- for(auto i = 0; i < this->n_frames*this->N ; i++)\n- if (X[i])\n- this->llrs1.add_value(Y[i]);\n- else\n- this->llrs0.add_value(Y[i]);\n+// for(auto i = 0; i < this->n_frames*this->N ; i++)\n+// if (X[i])\n+// this->llrs1.add_value(Y[i]);\n+// else\n+// this->llrs0.add_value(Y[i]);\nreturn MI_sum / (R)this->n_frames * 10000; // return the mut info %10000 instead of %100\n}\n@@ -256,8 +256,8 @@ void Monitor_BFER<B,R>\nthis->n_frame_errors = 0;\nthis->n_analyzed_frames = 0;\nthis->MI_sum = 0;\n- this->llrs0.reset();\n- this->llrs1.reset();\n+// this->llrs0.reset();\n+// this->llrs1.reset();\n}\ntemplate <typename B, typename R>\n@@ -269,17 +269,17 @@ void Monitor_BFER<B,R>\nthis->callbacks_fe_limit_achieved.clear();\n}\n-template<typename B, typename R>\n-const tools::Histogram<R>& Monitor_BFER<B, R>::get_llrs1()\n-{\n- return llrs1;\n-}\n-\n-template<typename B, typename R>\n-const tools::Histogram<R>& Monitor_BFER<B, R>::get_llrs0()\n-{\n- return llrs0;\n-}\n+//template<typename B, typename R>\n+//const tools::Histogram<R>& Monitor_BFER<B, R>::get_llrs1()\n+//{\n+// return llrs1;\n+//}\n+//\n+//template<typename B, typename R>\n+//const tools::Histogram<R>& Monitor_BFER<B, R>::get_llrs0()\n+//{\n+// return llrs0;\n+//}\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER.hpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER.hpp",
"diff": "#include <functional>\n#include \"../Monitor.hpp\"\n-#include \"Tools/Algo/Histogram.hpp\"\n+//#include \"Tools/Algo/Histogram.hpp\"\nnamespace aff3ct\n{\n@@ -32,7 +32,7 @@ protected:\nstd::vector<std::function<void(unsigned, int )>> callbacks_fe;\nstd::vector<std::function<void( void)>> callbacks_check;\nstd::vector<std::function<void( void)>> callbacks_fe_limit_achieved;\n- tools::Histogram<R> llrs0, llrs1;\n+// tools::Histogram<R> llrs0, llrs1;\npublic:\nMonitor_BFER(const int K, const int N, const unsigned max_fe, const int n_frames = 1);\n@@ -117,8 +117,8 @@ public:\nvirtual unsigned long long get_n_be () const;\nvirtual R get_MI () const;\nvirtual R get_MI_sum () const;\n- virtual const tools::Histogram<R>& get_llrs0();\n- virtual const tools::Histogram<R>& get_llrs1();\n+// virtual const tools::Histogram<R>& get_llrs0();\n+// virtual const tools::Histogram<R>& get_llrs1();\nfloat get_fer () const;\nfloat get_ber () const;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER_reduction.cpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER_reduction.cpp",
"diff": "@@ -137,23 +137,23 @@ R Monitor_BFER_reduction<B,R>\nreturn cur_mi;\n}\n-template<typename B, typename R>\n-const tools::Histogram<R> & Monitor_BFER_reduction<B, R>::get_llrs0()\n-{\n- for (unsigned i = 0; i < monitors.size(); i++)\n- this->llrs0.add_values(monitors[i]->get_llrs0());\n-\n- return this->llrs0;\n-}\n-\n-template<typename B, typename R>\n-const tools::Histogram<R>& Monitor_BFER_reduction<B, R>::get_llrs1()\n-{\n- for (unsigned i = 0; i < monitors.size(); i++)\n- this->llrs1.add_values(monitors[i]->get_llrs1());\n-\n- return this->llrs1;\n-}\n+//template<typename B, typename R>\n+//const tools::Histogram<R> & Monitor_BFER_reduction<B, R>::get_llrs0()\n+//{\n+// for (unsigned i = 0; i < monitors.size(); i++)\n+// this->llrs0.add_values(monitors[i]->get_llrs0());\n+//\n+// return this->llrs0;\n+//}\n+//\n+//template<typename B, typename R>\n+//const tools::Histogram<R>& Monitor_BFER_reduction<B, R>::get_llrs1()\n+//{\n+// for (unsigned i = 0; i < monitors.size(); i++)\n+// this->llrs1.add_values(monitors[i]->get_llrs1());\n+//\n+// return this->llrs1;\n+//}\ntemplate <typename B, typename R>\nvoid Monitor_BFER_reduction<B,R>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER_reduction.hpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER_reduction.hpp",
"diff": "@@ -25,8 +25,8 @@ public:\nunsigned long long get_n_analyzed_fra () const;\nunsigned long long get_n_fe () const;\nunsigned long long get_n_be () const;\n- const tools::Histogram<R>& get_llrs0();\n- const tools::Histogram<R>& get_llrs1();\n+// const tools::Histogram<R>& get_llrs0();\n+// const tools::Histogram<R>& get_llrs1();\nR get_MI () const;\nR get_MI_sum() const;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.cpp",
"new_path": "src/Simulation/BFER/BFER.cpp",
"diff": "#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/Display/Statistics/Statistics.hpp\"\n#include \"Tools/Display/Terminal/BFER/Terminal_BFER.hpp\"\n-#include \"Tools/Algo/Histogram.hpp\"\n+//#include \"Tools/Algo/Histogram.hpp\"\n#ifdef ENABLE_MPI\n#include \"Module/Monitor/BFER/Monitor_BFER_reduction_mpi.hpp\"\n@@ -287,21 +287,21 @@ void BFER<B,R,Q>\n}\n}\n- auto slash_pos = params_BFER.pdf_path.rfind('/')+1;\n- auto dot_pos = params_BFER.pdf_path.find('.', slash_pos);\n- std::string mission = params_BFER.pdf_path.substr(slash_pos, dot_pos - slash_pos);\n+// auto slash_pos = params_BFER.pdf_path.rfind('/')+1;\n+// auto dot_pos = params_BFER.pdf_path.find('.', slash_pos);\n+// std::string mission = params_BFER.pdf_path.substr(slash_pos, dot_pos - slash_pos);\n- auto llrs0 = monitor_red->get_llrs0();\n- std::string filename0 = mission + \"/\" + mission + \"_pdf_\" + std::to_string(this->noise->get_noise()) + \"_0.txt\";\n- std::ofstream pdf0(filename0);\n- pdf0 << \"x; \\\"PDF of \" << mission << \" bit 0 (\" << this->noise->get_noise() << \"dB, on \" << llrs0.get_n_values() << \" values)\\\"\" << std::endl;\n- llrs0.dump(pdf0, llrs0.get_hist_min(), llrs0.get_hist_max(), 100, true);\n-\n- auto llrs1 = monitor_red->get_llrs1();\n- std::string filename1 = mission + \"/\" + mission + \"_pdf_\" + std::to_string(this->noise->get_noise()) + \"_1.txt\";\n- std::ofstream pdf1(filename1);\n- pdf1 << \"x; \\\"PDF of \" << mission << \" bit 1 (\" << this->noise->get_noise() << \"dB, on \" << llrs1.get_n_values() << \" values)\\\"\" << std::endl;\n- llrs1.dump(pdf1, llrs1.get_hist_min(), llrs1.get_hist_max(), 100, true);\n+// auto llrs0 = monitor_red->get_llrs0();\n+// std::string filename0 = mission + \"/\" + mission + \"_pdf_\" + std::to_string(this->noise->get_noise()) + \"_0.txt\";\n+// std::ofstream pdf0(filename0);\n+// pdf0 << \"x; \\\"PDF of \" << mission << \" bit 0 (\" << this->noise->get_noise() << \"dB, on \" << llrs0.get_n_values() << \" values)\\\"\" << std::endl;\n+// llrs0.dump(pdf0, llrs0.get_hist_min(), llrs0.get_hist_max(), 100, true);\n+//\n+// auto llrs1 = monitor_red->get_llrs1();\n+// std::string filename1 = mission + \"/\" + mission + \"_pdf_\" + std::to_string(this->noise->get_noise()) + \"_1.txt\";\n+// std::ofstream pdf1(filename1);\n+// pdf1 << \"x; \\\"PDF of \" << mission << \" bit 1 (\" << this->noise->get_noise() << \"dB, on \" << llrs1.get_n_values() << \" values)\\\"\" << std::endl;\n+// llrs1.dump(pdf1, llrs1.get_hist_min(), llrs1.get_hist_max(), 100, true);\nif (this->dumper_red != nullptr && !this->simu_error)\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Comment the dump of the histograms
|
8,483 |
25.04.2018 11:47:01
| -7,200 |
01e42cf0621d7348b705917796b7b95bc3cdd68d
|
Move the LDMC matrix reader from Codec_LDPC to the LDPC_matrix_handler object
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/LDPC/Codec_LDPC.cpp",
"new_path": "src/Module/Codec/LDPC/Codec_LDPC.cpp",
"diff": "#include <algorithm>\n#include \"Tools/Exception/exception.hpp\"\n-#include \"Tools/Code/LDPC/AList/AList.hpp\"\n-#include \"Tools/Code/LDPC/QC/QC.hpp\"\n#include \"Tools/general_utils.h\"\n#include \"Factory/Module/Puncturer/Puncturer.hpp\"\nusing namespace aff3ct;\nusing namespace aff3ct::module;\n-template <typename B, typename Q>\n-std::string Codec_LDPC<B,Q>\n-::get_matrix_format(const std::string& filename)\n-{\n- std::ifstream file(filename, std::ifstream::in);\n-\n- if (file.is_open())\n- {\n- std::string line;\n- tools::getline(file, line);\n- file.close();\n-\n- auto values = tools::split(line);\n-\n- if (values.size() == 3)\n- return \"QC\";\n- else\n- return \"ALIST\";\n- }\n- else\n- {\n- return \"BAD_FILE\";\n- }\n-}\n-\ntemplate <typename B, typename Q>\nCodec_LDPC<B,Q>\n::Codec_LDPC(const factory::Encoder_LDPC ::parameters &enc_params,\n@@ -52,7 +25,7 @@ Codec_LDPC<B,Q>\nfactory::Puncturer_LDPC::parameters *pct_params)\n: Codec <B,Q>(enc_params.K, enc_params.N_cw, pct_params ? pct_params->N : enc_params.N_cw, enc_params.tail_length, enc_params.n_frames),\nCodec_SISO_SIHO<B,Q>(enc_params.K, enc_params.N_cw, pct_params ? pct_params->N : enc_params.N_cw, enc_params.tail_length, enc_params.n_frames),\n- info_bits_pos(enc_params.K), dvbs2(nullptr)\n+ dvbs2(nullptr)\n{\nconst std::string name = \"Codec_LDPC\";\nthis->set_name(name);\n@@ -83,91 +56,32 @@ Codec_LDPC<B,Q>\n}\n// ---------------------------------------------------------------------------------------------------------- tools\n- bool is_info_bits_pos = false;\nif (enc_params.type == \"LDPC\")\n{\n- auto G_format = get_matrix_format(enc_params.G_path);\n-\n- std::ifstream file_G(enc_params.G_path, std::ifstream::in);\n-\n- if (!file_G.is_open() || G_format == \"BAD_FILE\")\n- {\n- std::stringstream message;\n- message << \"'enc_params.G_path' can't be opened ('enc_params.G_path' = \\\"\" + enc_params.G_path + \"\\\").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n- else if (G_format == \"QC\")\n- {\n- G = tools::QC::read(file_G);\n+ G = tools::LDPC_matrix_handler::read(enc_params.G_path, &info_bits_pos);\n}\n- else if (G_format == \"ALIST\")\n- {\n- G = tools::AList::read(file_G);\n-\n- try\n- {\n- info_bits_pos = tools::AList::read_info_bits_pos(file_G, this->K, this->N_cw);\n- is_info_bits_pos = true;\n- }\n- catch (std::exception const&)\n- {\n- // information bits positions are not in the G matrix file\n- }\n- }\n- }\n-\n-\n- if (enc_params.type == \"LDPC_DVBS2\")\n+ else if (enc_params.type == \"LDPC_DVBS2\")\n{\ndvbs2 = tools::build_dvbs2(this->K, this->N);\nH = tools::build_H(*dvbs2);\n}\n- else\n- {\n- if (dec_params.H_path.empty())\n- {\n- std::stringstream message;\n- message << \"'dec_params.H_path' shall not be empty.\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- auto H_format = get_matrix_format(dec_params.H_path);\n-\n- std::ifstream file_H(dec_params.H_path, std::ifstream::in);\n- if (!file_H.is_open() || H_format == \"BAD_FILE\")\n+ if (H.get_n_connections() == 0)\n{\n- std::stringstream message;\n- message << \"'dec_params.H_path' can't be opened ('dec_params.H_path' = \\\"\" + dec_params.H_path + \"\\\").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n- else if (H_format == \"QC\")\n- {\n- H = tools::QC::read(file_H);\n- if (pct_params && pct_params->pattern.empty())\n- pct_params->pattern = tools::QC::read_pct_pattern(file_H);\n- }\n- else if (H_format == \"ALIST\")\n- {\n- H = tools::AList::read(file_H);\n+ tools::LDPC_matrix_handler::Positions_vector* ibp = nullptr;\n+ std::vector<bool>* pct = nullptr;\n- try\n- {\n- info_bits_pos = tools::AList::read_info_bits_pos(file_H, enc_params.K, enc_params.N_cw);\n- is_info_bits_pos = true;\n- }\n- catch (std::exception const&) { }\n- }\n- }\n+ if (info_bits_pos.empty())\n+ ibp = &info_bits_pos;\n- if (dec_params.H_reorder != \"NONE\")\n- {\n- // reorder the H matrix following the check node degrees\n- H.sort_cols_per_density(dec_params.H_reorder);\n+ if (pct_params != nullptr && pct_params->pattern.empty())\n+ pct = &pct_params->pattern;\n+\n+ H = tools::LDPC_matrix_handler::read(dec_params.H_path, ibp, pct);\n}\n- if (!is_info_bits_pos)\n+ if (info_bits_pos.empty())\n{\nif (enc_params.type == \"LDPC_H\")\n{\n@@ -177,12 +91,23 @@ Codec_LDPC<B,Q>\n}\nelse\n{\n+ // generate a default vector [0, 1, 2, 3, ..., K-1]\n+ info_bits_pos.resize(enc_params.K);\nstd::iota(info_bits_pos.begin(), info_bits_pos.end(), 0);\n}\n}\n+ else\n+ {\n+ tools::LDPC_matrix_handler::check_info_pos(info_bits_pos, enc_params.K, enc_params.N_cw);\n+ }\n+\n+ if (dec_params.H_reorder != \"NONE\")\n+ { // reorder the H matrix following the check node degrees\n+ H.sort_cols_per_density(dec_params.H_reorder);\n+ }\n// ---------------------------------------------------------------------------------------------------- allocations\n- if (!pct_params)\n+ if (pct_params == nullptr)\n{\nfactory::Puncturer::parameters pctno_params;\npctno_params.type = \"NO\";\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/LDPC/Codec_LDPC.hpp",
"new_path": "src/Module/Codec/LDPC/Codec_LDPC.hpp",
"diff": "#include \"Tools/Algo/Sparse_matrix/Sparse_matrix.hpp\"\n#include \"Tools/Code/LDPC/Standard/DVBS2/DVBS2_constants.hpp\"\n+#include \"Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp\"\n#include \"../Codec_SISO_SIHO.hpp\"\n@@ -22,7 +23,7 @@ class Codec_LDPC : public Codec_SISO_SIHO<B,Q>\nprotected:\ntools::Sparse_matrix H;\ntools::Sparse_matrix G;\n- std::vector<uint32_t> info_bits_pos;\n+ tools::LDPC_matrix_handler::Positions_vector info_bits_pos;\nstd::vector<bool> pctPattern;\nconst tools::dvbs2_values* dvbs2;\n@@ -36,9 +37,6 @@ protected:\nvoid _extract_sys_par(const Q *Y_N, Q *sys, Q *par, const int frame_id);\nvoid _extract_sys_llr(const Q *Y_N, Q *Y_K, const int frame_id);\nvoid _extract_sys_bit(const Q *Y_N, B *V_K, const int frame_id);\n-\n-private:\n- static std::string get_matrix_format(const std::string& filename);\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.cpp",
"new_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.cpp",
"diff": "#include <functional>\n#include <sstream>\n+#include <fstream>\n+\n+#include \"Tools/Code/LDPC/AList/AList.hpp\"\n+#include \"Tools/Code/LDPC/QC/QC.hpp\"\n+#include \"Tools/general_utils.h\"\n#include \"Tools/Exception/exception.hpp\"\nusing namespace aff3ct::tools;\n+LDPC_matrix_handler::Matrix_format LDPC_matrix_handler\n+::get_matrix_format(std::istream& file)\n+{\n+ std::string line;\n+ tools::getline(file, line);\n+\n+ auto values = tools::split(line);\n+\n+ if (values.size() == 3)\n+ return Matrix_format::QC;\n+\n+ if (values.size() == 2)\n+ return Matrix_format::ALIST;\n+\n+ std::stringstream message;\n+ message << \"The given LDPC matrix file does not represent a known matrix type (ALIST, QC).\";\n+ throw runtime_error(__FILE__, __LINE__, __func__, message.str());\n+}\n+\n+\n+Sparse_matrix LDPC_matrix_handler\n+::read(const std::string& filename, Positions_vector* info_bits_pos, std::vector<bool>* pct_pattern)\n+{\n+ std::ifstream file(filename);\n+ if (!file.is_open())\n+ {\n+ std::stringstream message;\n+ message << \"'filename' couldn't be opened ('filename' = \" << filename << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ auto format = get_matrix_format(file);\n+\n+ file.seekg(0);\n+\n+ Sparse_matrix S;\n+\n+ switch (format)\n+ {\n+ case Matrix_format::QC:\n+ {\n+ S = tools::QC::read(file);\n+\n+ if (pct_pattern != nullptr)\n+ *pct_pattern = tools::QC::read_pct_pattern(file);\n+\n+ break;\n+ }\n+ case Matrix_format::ALIST:\n+ {\n+ S = tools::AList::read(file);\n+\n+ if (info_bits_pos != nullptr)\n+ try\n+ {\n+ *info_bits_pos = tools::AList::read_info_bits_pos(file);\n+ }\n+ catch (std::exception const&)\n+ {\n+ info_bits_pos->clear();\n+ // information bits positions are not in the matrix file\n+ }\n+\n+ break;\n+ }\n+ }\n+\n+ return S;\n+}\n+\n+bool LDPC_matrix_handler\n+::check_info_pos(const Positions_vector& info_bits_pos, int K, int N, bool throw_when_wrong)\n+{\n+ if (info_bits_pos.size() != (unsigned)K)\n+ {\n+ if (!throw_when_wrong)\n+ return false;\n+\n+ std::stringstream message;\n+ message << \"'info_bits_pos.size()' has to be equal to 'K' ('info_bits_pos.size()' = \" << info_bits_pos.size()\n+ << \", 'K' = \" << K << \").\";\n+ throw runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ for (auto pos : info_bits_pos)\n+ if (pos >= (unsigned)N)\n+ {\n+ if (!throw_when_wrong)\n+ return false;\n+\n+ std::stringstream message;\n+ message << \"'pos' has to be smaller than 'N' ('pos' = \" << pos << \", 'N' = \" << N << \").\";\n+ throw runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ return true;\n+}\n+\nvoid LDPC_matrix_handler\n::sparse_to_full(const Sparse_matrix& sparse, Full_matrix& full)\n{\n@@ -32,7 +135,7 @@ Sparse_matrix LDPC_matrix_handler\n}\nSparse_matrix LDPC_matrix_handler\n-::transform_H_to_G(const Sparse_matrix& H, std::vector<unsigned>& info_bits_pos)\n+::transform_H_to_G(const Sparse_matrix& H, Positions_vector& info_bits_pos)\n{\nLDPC_matrix_handler::Full_matrix mat;\n@@ -47,7 +150,7 @@ Sparse_matrix LDPC_matrix_handler\n}\nvoid LDPC_matrix_handler\n-::transform_H_to_G(Full_matrix& mat, std::vector<unsigned>& info_bits_pos)\n+::transform_H_to_G(Full_matrix& mat, Positions_vector& info_bits_pos)\n{\nunsigned n_row = (unsigned)mat.size();\nunsigned n_col = (unsigned)mat.front().size();\n@@ -60,7 +163,7 @@ void LDPC_matrix_handler\nthrow length_error(__FILE__, __LINE__, __func__, message.str());\n}\n- std::vector<unsigned> swapped_cols;\n+ Positions_vector swapped_cols;\nLDPC_matrix_handler::create_diagonal(mat, swapped_cols);\nLDPC_matrix_handler::create_identity(mat);\n@@ -79,7 +182,7 @@ void LDPC_matrix_handler\n// return info bits positions\ninfo_bits_pos.resize(n_col - n_row);\n- std::vector<unsigned> bits_pos(n_col);\n+ Positions_vector bits_pos(n_col);\nstd::iota(bits_pos.begin(), bits_pos.end(), 0);\nfor (unsigned l = 1; l <= (swapped_cols.size() / 2); l++)\n@@ -89,7 +192,7 @@ void LDPC_matrix_handler\n}\nvoid LDPC_matrix_handler\n-::create_diagonal(Full_matrix& mat, std::vector<unsigned>& swapped_cols)\n+::create_diagonal(Full_matrix& mat, Positions_vector& swapped_cols)\n{\nunsigned n_row = (unsigned)mat.size();\nunsigned n_col = (unsigned)mat.front().size();\n@@ -191,7 +294,7 @@ float LDPC_matrix_handler\n}\nSparse_matrix LDPC_matrix_handler\n-::interleave_matrix(const Sparse_matrix& mat, std::vector<unsigned>& old_cols_pos)\n+::interleave_matrix(const Sparse_matrix& mat, Positions_vector& old_cols_pos)\n{\nif (mat.get_n_cols() != old_cols_pos.size())\n{\n@@ -213,8 +316,8 @@ Sparse_matrix LDPC_matrix_handler\nreturn itl_mat;\n}\n-std::vector<unsigned> LDPC_matrix_handler\n-::interleave_info_bits_pos(const std::vector<unsigned>& info_bits_pos, std::vector<unsigned>& old_cols_pos)\n+LDPC_matrix_handler::Positions_vector LDPC_matrix_handler\n+::interleave_info_bits_pos(const Positions_vector& info_bits_pos, Positions_vector& old_cols_pos)\n{\nif (info_bits_pos.size() > old_cols_pos.size())\n{\n@@ -225,7 +328,7 @@ std::vector<unsigned> LDPC_matrix_handler\nthrow length_error(__FILE__, __LINE__, __func__, message.str());\n}\n- std::vector<unsigned> itl_vec(info_bits_pos.size());\n+ Positions_vector itl_vec(info_bits_pos.size());\nunsigned cnt = 0;\nfor (unsigned i = 0; i < info_bits_pos.size(); i++)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp",
"new_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp",
"diff": "#include <vector>\n#include <algorithm>\n#include <numeric>\n+#include <string>\n#include <mipp.h>\n#include \"Tools/Algo/Sparse_matrix/Sparse_matrix.hpp\"\n@@ -17,6 +18,27 @@ struct LDPC_matrix_handler\npublic:\nusing Full_matrix = std::vector<std::vector<bool>>;\nusing QCFull_matrix = std::vector<mipp::vector<int8_t>>;\n+ using Positions_vector = std::vector<uint32_t>;\n+\n+ enum class Matrix_format : int8_t {ALIST, QC};\n+\n+ /*\n+ * read the matrix from the given file\n+ */\n+ static Sparse_matrix read(const std::string& filename, Positions_vector* info_bits_pos = nullptr,\n+ std::vector<bool>* pct_pattern = nullptr);\n+\n+ /*\n+ * try to guess the matrix format from the given input stream\n+ */\n+ static Matrix_format get_matrix_format(std::istream& file);\n+\n+ /*\n+ * Check if the input info bits position are in the matrix dimensions (K*N)\n+ * when @throw_when_wrong is true and the check is wrong, then throw a runtim_error, else return false.\n+ */\n+ static bool check_info_pos(const Positions_vector& info_bits_pos, int K, int N, bool throw_when_wrong = true);\n+\n/*\n* convert a binary sparse matrix to a binary full matrix\n@@ -35,7 +57,7 @@ public:\n* swapped_cols is completed each time with couple of positions of the two swapped columns.\n* A column might be swapped several times.\n*/\n- static void create_diagonal(Full_matrix& mat, std::vector<unsigned>& swapped_cols);\n+ static void create_diagonal(Full_matrix& mat, Positions_vector& swapped_cols);\n/*\n* Reorder rows and columns to create an identity of binary ones on the left part of the matrix.\n@@ -53,14 +75,14 @@ public:\n* Warning G is transposed !\n* Return also the information bits positions in the returned G matrix.\n*/\n- static Sparse_matrix transform_H_to_G(const Sparse_matrix& H, std::vector<unsigned>& info_bits_pos);\n+ static Sparse_matrix transform_H_to_G(const Sparse_matrix& H, Positions_vector& info_bits_pos);\n/*\n* integrate an interleaver inside the matrix to avoid this step.\n* old_cols_pos gives the old position of the matching column.\n* For ex. the column old_cols_pos[i] of mat will be set at position i\n*/\n- static Sparse_matrix interleave_matrix(const Sparse_matrix& mat, std::vector<unsigned>& old_cols_pos);\n+ static Sparse_matrix interleave_matrix(const Sparse_matrix& mat, Positions_vector& old_cols_pos);\n/*\n* return the vector of the position of the info bits after interleaving.\n@@ -68,8 +90,8 @@ public:\n* For ex. the bit position info_bits_pos[i] will be set at position j where\n* old_cols_pos[j] == info_bits_pos[i]\n*/\n- static std::vector<unsigned> interleave_info_bits_pos(const std::vector<unsigned>& info_bits_pos,\n- std::vector<unsigned>& old_cols_pos);\n+ static Positions_vector interleave_info_bits_pos(const Positions_vector& info_bits_pos,\n+ Positions_vector& old_cols_pos);\n/*\n* inverse H2 (H = [H1 H2] with size(H2) = M x M) to allow encoding with p = H1 x inv(H2) x u\n@@ -77,7 +99,7 @@ public:\nstatic QCFull_matrix invert_H2(const Sparse_matrix& H);\nprotected :\n- static void transform_H_to_G(Full_matrix& mat, std::vector<unsigned>& info_bits_pos);\n+ static void transform_H_to_G(Full_matrix& mat, Positions_vector& info_bits_pos);\n};\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Move the LDMC matrix reader from Codec_LDPC to the LDPC_matrix_handler object
|
8,483 |
25.04.2018 11:54:40
| -7,200 |
bab04cbfab04daf49f1dc821fa3a1fe8a2af0044
|
Do not build G twice when using en encoder LDPC_H
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/LDPC/Codec_LDPC.cpp",
"new_path": "src/Module/Codec/LDPC/Codec_LDPC.cpp",
"diff": "@@ -81,13 +81,19 @@ Codec_LDPC<B,Q>\nH = tools::LDPC_matrix_handler::read(dec_params.H_path, ibp, pct);\n}\n+ if (dec_params.H_reorder != \"NONE\")\n+ { // reorder the H matrix following the check node degrees\n+ H.sort_cols_per_density(dec_params.H_reorder);\n+ }\n+\n+\n+\nif (info_bits_pos.empty())\n{\nif (enc_params.type == \"LDPC_H\")\n{\n- auto encoder_LDPC = factory::Encoder_LDPC::build<B>(enc_params, G, H);\n- info_bits_pos = encoder_LDPC->get_info_bits_pos();\n- delete encoder_LDPC;\n+ this->set_encoder(factory::Encoder_LDPC::build<B>(enc_params, G, H));\n+ info_bits_pos = this->get_encoder()->get_info_bits_pos();\n}\nelse\n{\n@@ -101,11 +107,6 @@ Codec_LDPC<B,Q>\ntools::LDPC_matrix_handler::check_info_pos(info_bits_pos, enc_params.K, enc_params.N_cw);\n}\n- if (dec_params.H_reorder != \"NONE\")\n- { // reorder the H matrix following the check node degrees\n- H.sort_cols_per_density(dec_params.H_reorder);\n- }\n-\n// ---------------------------------------------------------------------------------------------------- allocations\nif (pct_params == nullptr)\n{\n@@ -130,8 +131,10 @@ Codec_LDPC<B,Q>\n}\n}\n+\ntry\n{\n+ if (this->get_encoder() == nullptr) // not set when building encoder LDPC_H\nthis->set_encoder(factory::Encoder_LDPC::build<B>(enc_params, G, H, dvbs2));\n}\ncatch (tools::cannot_allocate const&)\n@@ -139,6 +142,7 @@ Codec_LDPC<B,Q>\nthis->set_encoder(factory::Encoder::build<B>(enc_params));\n}\n+\ntry\n{\nauto decoder_siso_siho = factory::Decoder_LDPC::build_siso<B,Q>(dec_params, H, info_bits_pos, this->get_encoder());\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Do not build G twice when using en encoder LDPC_H
|
8,483 |
25.04.2018 14:21:03
| -7,200 |
097ec538c44581754ccc60a8a41a3ef32f2d1590
|
Fix matrix dimensions reader in LDPC_matrix_handler, Alist, QC
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/AList/AList.cpp",
"new_path": "src/Tools/Code/LDPC/AList/AList.cpp",
"diff": "@@ -82,6 +82,13 @@ void AList\n}\n}\n+void AList\n+::read_matrix_size(std::istream &stream, int& H, int& N)\n+{\n+ stream >> N;\n+ stream >> H;\n+}\n+\nstd::vector<unsigned> AList\n::read_info_bits_pos(std::istream &stream)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/AList/AList.hpp",
"new_path": "src/Tools/Code/LDPC/AList/AList.hpp",
"diff": "@@ -15,6 +15,13 @@ public:\nstatic Sparse_matrix read ( std::istream &stream);\nstatic void write(const Sparse_matrix &matrix, std::ostream &stream);\n+ /*\n+ * get the matrix dimensions H and N from the input stream\n+ * @H is the height of the matrix\n+ * @N is the width of the matrix\n+ */\n+ static void read_matrix_size (std::istream &stream, int& H, int& N);\n+\nstatic std::vector<unsigned> read_info_bits_pos (std::istream &stream);\nstatic std::vector<unsigned> read_info_bits_pos (std::istream &stream, const int K, const int N);\nstatic void write_info_bits_pos(const std::vector<unsigned> &info_bits_pos, std::ostream &stream);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.cpp",
"new_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.cpp",
"diff": "using namespace aff3ct::tools;\n+\n+\n+LDPC_matrix_handler::Matrix_format LDPC_matrix_handler\n+::get_matrix_format(const std::string& filename)\n+{\n+ std::ifstream file(filename);\n+ if (!file.is_open())\n+ {\n+ std::stringstream message;\n+ message << \"'filename' couldn't be opened ('filename' = \" << filename << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ return get_matrix_format(file);\n+}\n+\nLDPC_matrix_handler::Matrix_format LDPC_matrix_handler\n-::get_matrix_format(std::istream& file)\n+::get_matrix_format(std::ifstream& file)\n{\n+ file.seekg(0);\n+\nstd::string line;\ntools::getline(file, line);\n@@ -43,6 +61,12 @@ Sparse_matrix LDPC_matrix_handler\nthrow invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n+ return read(file, info_bits_pos, pct_pattern);\n+}\n+\n+Sparse_matrix LDPC_matrix_handler\n+::read(std::ifstream& file, Positions_vector* info_bits_pos, std::vector<bool>* pct_pattern)\n+{\nauto format = get_matrix_format(file);\nfile.seekg(0);\n@@ -82,6 +106,44 @@ Sparse_matrix LDPC_matrix_handler\nreturn S;\n}\n+void LDPC_matrix_handler\n+::read_matrix_size(const std::string& filename, int& H, int& N)\n+{\n+ std::ifstream file(filename);\n+ if (!file.is_open())\n+ {\n+ std::stringstream message;\n+ message << \"'filename' couldn't be opened ('filename' = \" << filename << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ return read_matrix_size(file, H, N);\n+}\n+\n+void LDPC_matrix_handler\n+::read_matrix_size(std::ifstream &file, int& H, int& N)\n+{\n+ auto format = get_matrix_format(file);\n+\n+ file.seekg(0);\n+\n+ switch (format)\n+ {\n+ case Matrix_format::QC:\n+ {\n+ tools::QC::read_matrix_size(file, H, N);\n+ break;\n+ }\n+ case Matrix_format::ALIST:\n+ {\n+ tools::AList::read_matrix_size(file, H, N);\n+ break;\n+ }\n+ }\n+}\n+\n+\n+\nbool LDPC_matrix_handler\n::check_info_pos(const Positions_vector& info_bits_pos, int K, int N, bool throw_when_wrong)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp",
"new_path": "src/Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp",
"diff": "@@ -28,10 +28,23 @@ public:\nstatic Sparse_matrix read(const std::string& filename, Positions_vector* info_bits_pos = nullptr,\nstd::vector<bool>* pct_pattern = nullptr);\n+ static Sparse_matrix read(std::ifstream &file, Positions_vector* info_bits_pos = nullptr,\n+ std::vector<bool>* pct_pattern = nullptr);\n+\n/*\n* try to guess the matrix format from the given input stream\n*/\n- static Matrix_format get_matrix_format(std::istream& file);\n+ static Matrix_format get_matrix_format(const std::string& filename);\n+ static Matrix_format get_matrix_format(std::ifstream& file);\n+\n+ /*\n+ * get the matrix dimensions H and N from the input stream\n+ * @H is the height of the matrix\n+ * @N is the width of the matrix\n+ */\n+ static void read_matrix_size(const std::string& filename, int& H, int& N);\n+ static void read_matrix_size(std::ifstream &file, int& H, int& N);\n+\n/*\n* Check if the input info bits position are in the matrix dimensions (K*N)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/QC/QC.cpp",
"new_path": "src/Tools/Code/LDPC/QC/QC.cpp",
"diff": "@@ -153,3 +153,35 @@ void QC\n{\nAList::write(matrix, stream);\n}\n+\n+void QC\n+::read_matrix_size(std::istream &stream, int& H, int& N)\n+{\n+ std::string line;\n+\n+ getline(stream, line);\n+ auto values = split(line);\n+ if (values.size() < 3)\n+ {\n+ std::stringstream message;\n+ message << \"'values.size()' has to be greater than 2 ('values.size()' = \" << values.size() << \").\";\n+ throw runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ unsigned N_red = 0, M_red = 0, Z = 0;\n+\n+ N_red = std::stoi(values[0]);\n+ M_red = std::stoi(values[1]);\n+ Z = std::stoi(values[2]);\n+\n+ if (N_red == 0 || M_red == 0 || Z == 0)\n+ {\n+ std::stringstream message;\n+ message << \"'N_red', 'M_red' and 'Z' have to be greater than 0 ('N_red' = \" << N_red\n+ << \", 'M_red' = \" << M_red << \", 'Z' = \" << Z << \").\";\n+ throw runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ N = N_red * Z;\n+ H = M_red * Z;\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/QC/QC.hpp",
"new_path": "src/Tools/Code/LDPC/QC/QC.hpp",
"diff": "@@ -19,6 +19,13 @@ public:\nstatic std::vector<bool> read_pct_pattern( std::istream &stream, int N_red = -1);\nstatic void write (const Sparse_matrix &matrix, std::ostream &stream );\n+ /*\n+ * get the matrix dimensions H and N from the input stream\n+ * @H is the height of the matrix\n+ * @N is the width of the matrix\n+ */\n+ static void read_matrix_size(std::istream &stream, int& H, int& N);\n+\nprivate:\nstatic Sparse_matrix _read(std::istream &stream);\n};\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix matrix dimensions reader in LDPC_matrix_handler, Alist, QC
|
8,483 |
25.04.2018 14:22:49
| -7,200 |
23e9c7712685d40286d9135edf13d1b5b802e272
|
make sure that LDPC H matrix gives the K and N_cw to simulate, automatically
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Codec/LDPC/Codec_LDPC.cpp",
"new_path": "src/Factory/Module/Codec/LDPC/Codec_LDPC.cpp",
"diff": "@@ -68,6 +68,9 @@ void Codec_LDPC::parameters\nargs.erase({pdec+\"-info-bits\", \"K\" });\nargs.erase({pdec+\"-fra\", \"F\" });\n+ args.add_link({pdec+\"-h-path\"}, {penc+\"-info-bits\", \"K\"});\n+ args.add_link({pdec+\"-h-path\"}, {penc+\"-cw-size\", \"N\"});\n+\nif (this->pct)\n{\npct->get_description(args);\n@@ -77,6 +80,8 @@ void Codec_LDPC::parameters\nargs.erase({ppct+\"-info-bits\", \"K\" });\nargs.erase({ppct+\"-fra\", \"F\" });\nargs.erase({ppct+\"-cw-size\", \"N_cw\"});\n+\n+ args.add_link({pdec+\"-h-path\"}, {ppct+\"-fra-size\", \"N\"});\n}\n}\n@@ -86,25 +91,29 @@ void Codec_LDPC::parameters\nCodec_SISO_SIHO::parameters::store(vals);\nenc->store(vals);\n+ dec->store(vals);\n+\n+ this->enc->N_cw = this->dec->N_cw;\n+ if (this->enc->K != 0)\n+ this->dec->K = this->enc->K;\n+ else\n+ this->enc->K = this->dec->K;\n+\n+ this->dec->n_frames = this->enc->n_frames;\n+\n+ this->enc->R = (float)this->enc->K / (float)this->enc->N_cw;\n+ this->dec->R = (float)this->dec->K / (float)this->dec->N_cw;\nif (this->pct)\n{\nthis->pct->K = this->enc->K;\n+ this->pct->N = this->enc->N_cw;\nthis->pct->N_cw = this->enc->N_cw;\nthis->pct->n_frames = this->enc->n_frames;\npct->store(vals);\n}\n- this->dec->K = this->enc->K;\n- this->dec->N_cw = this->enc->N_cw;\n- this->dec->n_frames = this->enc->n_frames;\n-\n- dec->store(vals);\n-\n- this->enc->H_path = this->dec->H_path;\n- this->enc->H_reorder = this->dec->H_reorder;\n-\nthis->K = this->enc->K;\nthis->N_cw = this->enc->N_cw;\nthis->N = this->pct ? this->pct->N : this->N_cw;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.cpp",
"new_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.cpp",
"diff": "#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/Math/max.h\"\n+#include \"Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp\"\n#include \"Module/Decoder/LDPC/BP/Flooding/SPA/Decoder_LDPC_BP_flooding_sum_product.hpp\"\n#include \"Module/Decoder/LDPC/BP/Flooding/LSPA/Decoder_LDPC_BP_flooding_log_sum_product.hpp\"\n@@ -52,6 +53,11 @@ void Decoder_LDPC::parameters\n\"path to the H matrix (AList or QC formated file).\",\ntools::arg_rank::REQ);\n+ args.add_link({p+\"-h-path\"}, {p+\"-cw-size\", \"N\"}); // N_cw is H width\n+ args.add_link({p+\"-h-path\"}, {p+\"-info-bits\", \"K\"}); // if there is no K, then H is considered regular,\n+ // so K is the N - H's height\n+\n+\ntools::add_options(args.at({p+\"-type\", \"D\"}), 0, \"BP\", \"BP_FLOODING\", \"BP_LAYERED\");\ntools::add_options(args.at({p+\"-implem\" }), 0, \"ONMS\", \"SPA\", \"LSPA\", \"GALA\", \"AMS\");\n@@ -95,14 +101,11 @@ void Decoder_LDPC::parameters\ntools::Text(tools::Including_set(\"NONE\", \"ASC\", \"DSC\")),\n\"specify if the check nodes (CNs) from H have to be reordered, 'NONE': do nothing (default), 'ASC': from the \"\n\"smallest to the biggest CNs, 'DSC': from the biggest to the smallest CNs.\");\n-\n}\nvoid Decoder_LDPC::parameters\n::store(const tools::Argument_map_value &vals)\n{\n- Decoder::parameters::store(vals);\n-\nauto p = this->get_prefix();\nif(vals.exist({p+\"-h-path\" })) this->H_path = vals.at ({p+\"-h-path\" });\n@@ -114,6 +117,12 @@ void Decoder_LDPC::parameters\nif(vals.exist({p+\"-off\" })) this->offset = vals.to_float({p+\"-off\" });\nif(vals.exist({p+\"-norm\" })) this->norm_factor = vals.to_float({p+\"-norm\" });\nif(vals.exist({p+\"-no-synd\" })) this->enable_syndrome = false;\n+\n+ int H;\n+ tools::LDPC_matrix_handler::read_matrix_size(this->H_path, H, this->N_cw);\n+ this->K = this->N_cw - H; // considered as regular so H = N - K\n+\n+ Decoder::parameters::store(vals);\n}\nvoid Decoder_LDPC::parameters\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Encoder/LDPC/Encoder_LDPC.cpp",
"new_path": "src/Factory/Module/Encoder/LDPC/Encoder_LDPC.cpp",
"diff": "#include \"Tools/Exception/exception.hpp\"\n+#include \"Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp\"\n#include \"Module/Encoder/LDPC/Encoder_LDPC.hpp\"\n#include \"Module/Encoder/LDPC/From_H/Encoder_LDPC_from_H.hpp\"\n@@ -45,11 +46,19 @@ void Encoder_LDPC::parameters\ntools::File(tools::openmode::read),\n\"path to the H matrix (AList formated file, required by the \\\"LDPC_H\\\" encoder).\");\n+ args.add_link({p+\"-h-path\"}, {p+\"-cw-size\", \"N\"}); // N_cw is H width\n+ args.add_link({p+\"-h-path\"}, {p+\"-info-bits\", \"K\"}); // if there is no K, then H is considered regular,\n+ // so K is the N - H's height\n+\n+\nargs.add(\n{p+\"-g-path\"},\ntools::File(tools::openmode::read),\n\"path to the G matrix (AList formated file, required by the \\\"LDPC\\\" encoder).\");\n+ args.add_link({p+\"-g-path\"}, {p+\"-info-bits\", \"K\"});\n+ args.add_link({p+\"-g-path\"}, {p+\"-cw-size\", \"N\"});\n+\nargs.add(\n{p+\"-h-reorder\"},\ntools::Text(tools::Including_set(\"NONE\", \"ASC\", \"DSC\")),\n@@ -60,13 +69,23 @@ void Encoder_LDPC::parameters\nvoid Encoder_LDPC::parameters\n::store(const tools::Argument_map_value &vals)\n{\n- Encoder::parameters::store(vals);\n-\nauto p = this->get_prefix();\nif(vals.exist({p+\"-h-path\" })) this->H_path = vals.at({p+\"-h-path\" });\nif(vals.exist({p+\"-g-path\" })) this->G_path = vals.at({p+\"-g-path\" });\nif(vals.exist({p+\"-h-reorder\"})) this->H_reorder = vals.at({p+\"-h-reorder\"});\n+\n+ if (!this->G_path.empty())\n+ tools::LDPC_matrix_handler::read_matrix_size(this->G_path, this->K, this->N_cw);\n+\n+ else if (!this->H_path.empty())\n+ {\n+ int H;\n+ tools::LDPC_matrix_handler::read_matrix_size(this->H_path, H, this->N_cw);\n+ this->K = this->N_cw - H; // considered as regular so H = N - K\n+ }\n+\n+ Encoder::parameters::store(vals);\n}\nvoid Encoder_LDPC::parameters\n@@ -78,6 +97,7 @@ void Encoder_LDPC::parameters\nif (this->type == \"LDPC\")\nheaders[p].push_back(std::make_pair(\"G matrix path\", this->G_path));\n+\nif (this->type == \"LDPC_H\" || this->type == \"LDPC_QC\")\n{\nheaders[p].push_back(std::make_pair(\"H matrix path\", this->H_path));\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/LDPC/Codec_LDPC.cpp",
"new_path": "src/Module/Codec/LDPC/Codec_LDPC.cpp",
"diff": "@@ -134,13 +134,19 @@ Codec_LDPC<B,Q>\ntry\n{\n- if (this->get_encoder() == nullptr) // not set when building encoder LDPC_H\n+ this->get_encoder();\n+ }\n+ catch (tools::runtime_error const&)\n+ { // encoder not set when building encoder LDPC_H\n+ try\n+ {\nthis->set_encoder(factory::Encoder_LDPC::build<B>(enc_params, G, H, dvbs2));\n}\ncatch(tools::cannot_allocate const&)\n{\nthis->set_encoder(factory::Encoder::build<B>(enc_params));\n}\n+ }\ntry\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
make sure that LDPC H matrix gives the K and N_cw to simulate, automatically
|
8,483 |
25.04.2018 14:36:51
| -7,200 |
08e055c3d086927a84772e2754f73683dbf20b43
|
Fix the K and N storing
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Codec/LDPC/Codec_LDPC.cpp",
"new_path": "src/Factory/Module/Codec/LDPC/Codec_LDPC.cpp",
"diff": "@@ -93,11 +93,15 @@ void Codec_LDPC::parameters\nenc->store(vals);\ndec->store(vals);\n- this->enc->N_cw = this->dec->N_cw;\n+ if (this->enc->type == \"LDPC_DVBS2\" || this->enc->type == \"LDPC\")\n+ this->dec->N_cw = this->enc->N_cw; // then the encoder knows the N_cw\n+ else\n+ this->enc->N_cw = this->dec->N_cw; // then the decoder knows the N_cw\n+\nif (this->enc->K != 0)\n- this->dec->K = this->enc->K;\n+ this->dec->K = this->enc->K; // then the encoder knows the K\nelse\n- this->enc->K = this->dec->K;\n+ this->enc->K = this->dec->K; // then the encoder knows the K\nthis->dec->n_frames = this->enc->n_frames;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.cpp",
"new_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.cpp",
"diff": "@@ -118,9 +118,12 @@ void Decoder_LDPC::parameters\nif(vals.exist({p+\"-norm\" })) this->norm_factor = vals.to_float({p+\"-norm\" });\nif(vals.exist({p+\"-no-synd\" })) this->enable_syndrome = false;\n+ if (!this->H_path.empty())\n+ {\nint H;\ntools::LDPC_matrix_handler::read_matrix_size(this->H_path, H, this->N_cw);\nthis->K = this->N_cw - H; // considered as regular so H = N - K\n+ }\nDecoder::parameters::store(vals);\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix the K and N storing
|
8,483 |
25.04.2018 17:58:19
| -7,200 |
9c20b57ebcf8d62542b2ebd4d9b117553efa1a60
|
Fix the read of K and N by using tools::getline
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/AList/AList.cpp",
"new_path": "src/Tools/Code/LDPC/AList/AList.cpp",
"diff": "@@ -85,8 +85,19 @@ void AList\nvoid AList\n::read_matrix_size(std::istream &stream, int& H, int& N)\n{\n- stream >> N;\n- stream >> H;\n+ std::string line;\n+\n+ tools::getline(stream, line);\n+ auto values = split(line);\n+ if (values.size() < 2)\n+ {\n+ std::stringstream message;\n+ message << \"'values.size()' has to be greater than 1 ('values.size()' = \" << values.size() << \").\";\n+ throw runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ N = stoi(values[0]);\n+ H = stoi(values[1]);\n}\nstd::vector<unsigned> AList\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/QC/QC.cpp",
"new_path": "src/Tools/Code/LDPC/QC/QC.cpp",
"diff": "@@ -159,7 +159,7 @@ void QC\n{\nstd::string line;\n- getline(stream, line);\n+ tools::getline(stream, line);\nauto values = split(line);\nif (values.size() < 3)\n{\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix the read of K and N by using tools::getline
|
8,488 |
26.04.2018 08:54:18
| -7,200 |
17fad641b69b80539f8380c712e46e10a10b0ab2
|
Add .mat generation.
|
[
{
"change_type": "MODIFY",
"old_path": "scripts/debug_parser/aff3ct_debug_parser.py",
"new_path": "scripts/debug_parser/aff3ct_debug_parser.py",
"diff": "@@ -4,7 +4,7 @@ import argparse\nimport struct\nimport os\nimport ctypes\n-\n+import mat4py\nclass OutputStructure:\nindex = 0\n@@ -130,6 +130,43 @@ class OutputStructure:\nc_type = \"\"\nreturn c_type\n+ def export_as_mat(self, path, frame_index=None):\n+ myframes = []\n+ sck_name = os.path.basename(path)\n+\n+ if not self.hex_format:\n+ if \"float\" in self.data_format:\n+ for frame in self.frames:\n+ myframe = []\n+ for value in frame:\n+ myframe.append(float(value))\n+ myframes.append(myframe)\n+ else:\n+ for frame in self.frames:\n+ myframe = []\n+ for value in frame:\n+ myframe.append(int(value))\n+ myframes.append(myframe)\n+ else:\n+ if \"float\" in self.data_format:\n+ for frame in self.frames:\n+ myframe = []\n+ for value in frame:\n+ myframe.append(float.fromhex(value))\n+ myframes.append(myframe)\n+ else:\n+ for frame in self.frames:\n+ myframe = []\n+ for value in frame:\n+ value = int(value, 16)\n+ if value > 0x7FFFFFFF:\n+ value -= 0x100000000\n+ myframe.append(value)\n+ myframes.append(myframe)\n+\n+ mat4py.savemat(path + '.mat', dict({sck_name : myframes}));\n+\n+\ndef export_as_bin(self, path, frame_index=None):\nif self.data_format == \"int8\":\nfloat_code = 0\n@@ -221,12 +258,13 @@ def adp_parse_args():\nparser.add_argument(\"--txt\", help=\"export as txt\", action='store_true')\nparser.add_argument(\"--bin\", help=\"export as bin\", action='store_true')\nparser.add_argument(\"--src\", help=\"export as c source\", action='store_true')\n+ parser.add_argument(\"--mat\", help=\"export as matlab .mat file\", action='store_true')\nparser.add_argument(\"--fra\", type=check_positive, help=\"export a single frame, whose index is specified\")\nparser.add_argument(\"-o\", \"--output\", type=check_directory, help=\"path to the output folder\", default=\"./\")\nargs = parser.parse_args()\n- if not (args.txt or args.bin or args.src):\n+ if not (args.txt or args.bin or args.src or args.mat):\nparser.error('At least one of the export types is required (e.g. --txt)')\nreturn args\n@@ -318,6 +356,12 @@ def main():\nbase_path = os.path.join(args.output, out_sct.name)\nout_sct.export_as_source(base_path + \".h\", args.fra)\n+ # export frames as mat file\n+ if args.mat:\n+ for out_sct in out_structures:\n+ base_path = os.path.join(args.output, out_sct.name)\n+ out_sct.export_as_mat(base_path, args.fra)\n+\nif __name__ == \"__main__\":\nmain()\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add .mat generation.
|
8,483 |
27.04.2018 16:34:20
| -7,200 |
f03aa47e37d30756557ebc404b1df34b06456d02
|
Modify Channel User
Fix the add_user part.
Add a additive_noise parameter; When true, the noise is added to the signal, else it is set as the output.
Add a file read as a text file; If can't be read, try as a binary file (as before)
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Channel/Channel.cpp",
"new_path": "src/Factory/Module/Channel/Channel.cpp",
"diff": "@@ -61,8 +61,9 @@ void Channel::parameters\nargs.add(\n{p+\"-type\"},\n- tools::Text(tools::Including_set(\"NO\", \"USER\", \"AWGN\", \"RAYLEIGH\", \"RAYLEIGH_USER\", \"BEC\", \"OPTICAL\")),\n- \"type of the channel to use in the simulation.\");\n+ tools::Text(tools::Including_set(\"NO\", \"USER\", \"USER_ADD\", \"AWGN\", \"RAYLEIGH\", \"RAYLEIGH_USER\", \"BEC\", \"OPTICAL\")),\n+ \"type of the channel to use in the simulation ('USER' has an output got from a file when 'USER_ADD' has an\"\n+ \" additive noise got from a file).\");\nargs.add(\n{p+\"-implem\"},\n@@ -144,7 +145,7 @@ void Channel::parameters\nif (this->noise != -1.f)\nheaders[p].push_back(std::make_pair(\"Sigma value\", std::to_string(this->noise)));\n- if (this->type == \"USER\" || this->type == \"RAYLEIGH_USER\")\n+ if (this->type == \"USER\" || this->type == \"USER_ADD\" || this->type == \"RAYLEIGH_USER\")\nheaders[p].push_back(std::make_pair(\"Path\", this->path));\nif (this->type == \"RAYLEIGH_USER\")\n@@ -153,7 +154,7 @@ void Channel::parameters\nif (this->type.find(\"RAYLEIGH\") != std::string::npos)\nheaders[p].push_back(std::make_pair(\"Block fading policy\", this->block_fading));\n- if ((this->type != \"NO\" && this->type != \"USER\") && full)\n+ if ((this->type != \"NO\" && this->type != \"USER\" && this->type != \"USER_ADD\") && full)\nheaders[p].push_back(std::make_pair(\"Seed\", std::to_string(this->seed)));\nheaders[p].push_back(std::make_pair(\"Complex\", this->complex ? \"on\" : \"off\"));\n@@ -187,14 +188,12 @@ module::Channel<R>* Channel::parameters\nelse if (type == \"RAYLEIGH_USER\") return new module::Channel_Rayleigh_LLR_user<R>(N, complex, path, gain_occur, n, add_users, tools::Sigma<R>((R)this->noise), n_frames);\nelse\n{\n- module::Channel<R>* c = nullptr;\n- if (type == \"USER\") c = new module::Channel_user<R>(N, path, add_users, n_frames);\n- else if (type == \"NO\" ) c = new module::Channel_NO <R>(N, add_users, n_frames);\n- else if (type == \"BEC\" ) c = new module::Channel_BEC <R>(N, seed, tools::Erasure_probability<R>((R)this->noise), n_frames);\n-\ndelete n;\n- if (c) return c;\n+ if (type == \"USER\" ) return new module::Channel_user<R>(N, path, add_users, false, n_frames);\n+ else if (type == \"USER_ADD\") return new module::Channel_user<R>(N, path, add_users, true, n_frames);\n+ else if (type == \"NO\" ) return new module::Channel_NO <R>(N, add_users, n_frames);\n+ else if (type == \"BEC\" ) return new module::Channel_BEC <R>(N, seed, tools::Erasure_probability<R>((R)this->noise), n_frames);\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/User/Channel_user.cpp",
"new_path": "src/Module/Channel/User/Channel_user.cpp",
"diff": "@@ -10,8 +10,9 @@ using namespace aff3ct::module;\ntemplate <typename R>\nChannel_user<R>\n-::Channel_user(const int N, const std::string &filename, const bool add_users, const int n_frames)\n-: Channel<R>(N, n_frames), add_users(add_users), noise_buff(), noise_counter(0)\n+::Channel_user(const int N, const std::string &filename, const bool add_users, const bool additive_noise,\n+ const int n_frames)\n+: Channel<R>(N, n_frames), add_users(add_users), additive_noise(additive_noise), noise_buff(), noise_counter(0)\n{\nconst std::string name = \"Channel_user\";\nthis->set_name(name);\n@@ -19,6 +20,76 @@ Channel_user<R>\nif (filename.empty())\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, \"'filename' should not be empty.\");\n+ try\n+ {\n+ open_as_text(filename);\n+ }\n+ catch(const tools::runtime_error&)\n+ {\n+ open_as_binary(filename);\n+ }\n+}\n+\n+template<typename R>\n+void Channel_user<R>::open_as_text(const std::string &filename)\n+{\n+ std::ifstream file(filename.c_str());\n+\n+ if (file.is_open())\n+ {\n+ unsigned n_fra = 0;\n+ int fra_size = 0;\n+\n+ file >> n_fra;\n+ file >> fra_size;\n+\n+ if (n_fra == 0 || fra_size <= 0)\n+ {\n+ std::stringstream message;\n+ message << \"'n_fra' and 'fra_size' have to be bigger than 0 ('n_fra' = \"\n+ << n_fra << \", 'fra_size' = \" << fra_size << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (fra_size == this->N)\n+ {\n+ this->noise_buff.resize(n_fra);\n+ for (unsigned i = 0; i < (unsigned)n_fra; i++)\n+ this->noise_buff[i].resize(fra_size);\n+\n+ for (unsigned i = 0; i < n_fra; i++)\n+ for (auto j = 0; j < fra_size; j++)\n+ {\n+ if (file.eof())\n+ {\n+ std::stringstream message;\n+ message << \"Not enough data in the file (got \" << i << \" frames only).\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ R value;\n+ file >> value;\n+ this->noise_buff[i][j] = value;\n+ }\n+ }\n+ else\n+ {\n+ file.close();\n+\n+ std::stringstream message;\n+ message << \"The frame size is wrong (read: \" << fra_size << \", expected: \" << this->N << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ }\n+ else\n+ {\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, \"Can't open '\" + filename + \"' file\");\n+ }\n+}\n+\n+template<typename R>\n+void Channel_user<R>::open_as_binary(const std::string &filename)\n+{\nstd::ifstream file(filename.c_str(), std::ios::binary);\nif (file.is_open())\n@@ -34,7 +105,7 @@ Channel_user<R>\nfile.clear(); // since ignore will have set eof.\nfile.seekg(8, std::ios_base::beg);\n- if (n_fra <= 0 || fra_size <= 0)\n+ if (n_fra == 0 || fra_size <= 0)\n{\nstd::stringstream message;\nmessage << \"'n_fra' and 'fra_size' have to be bigger than 0 ('n_fra' = \"\n@@ -44,12 +115,12 @@ Channel_user<R>\nconst unsigned sizeof_float = (unsigned)length / (n_fra * fra_size);\n+ if (fra_size == this->N)\n+ {\nthis->noise_buff.resize(n_fra);\nfor (unsigned i = 0; i < (unsigned)n_fra; i++)\nthis->noise_buff[i].resize(fra_size);\n- if (fra_size == this->N)\n- {\nif (sizeof_float == sizeof(R))\n{\nfor (unsigned i = 0; i < n_fra; i++)\n@@ -113,6 +184,8 @@ Channel_user<R>\ntemplate <typename R>\nvoid Channel_user<R>\n::add_noise(const R *X_N, R *Y_N, const int frame_id)\n+{\n+ if (additive_noise)\n{\nif (add_users && this->n_frames > 1)\n{\n@@ -128,14 +201,11 @@ void Channel_user<R>\nfor (auto i = 0; i < this->N; i++)\nY_N[i] += X_N[f * this->N + i];\n- for (auto f = 0; f < this->n_frames; f++)\n- {\nstd::copy(this->noise_buff[this->noise_counter].begin(),\nthis->noise_buff[this->noise_counter].end(),\n- this->noise.data() + f * this->N);\n+ this->noise.data());\nthis->noise_counter = (this->noise_counter +1) % (int)this->noise_buff.size();\n- }\nfor (auto i = 0; i < this->N; i++)\nY_N[i] += this->noise[i];\n@@ -158,6 +228,48 @@ void Channel_user<R>\n}\n}\n}\n+ else\n+ {\n+ if (add_users && this->n_frames > 1)\n+ {\n+ if (frame_id != -1)\n+ {\n+ std::stringstream message;\n+ message << \"'frame_id' has to be equal to -1 ('frame_id' = \" << frame_id << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ std::copy(this->noise_buff[this->noise_counter].begin(),\n+ this->noise_buff[this->noise_counter].end(),\n+ this->noise.data());\n+\n+ std::copy(this->noise_buff[this->noise_counter].begin(),\n+ this->noise_buff[this->noise_counter].end(),\n+ Y_N);\n+\n+ this->noise_counter = (this->noise_counter +1) % (int)this->noise_buff.size();\n+\n+ }\n+ else\n+ {\n+ const auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\n+ const auto f_stop = (frame_id < 0) ? this->n_frames : f_start + 1;\n+\n+ for (auto f = f_start; f < f_stop; f++)\n+ {\n+ std::copy(this->noise_buff[this->noise_counter].begin(),\n+ this->noise_buff[this->noise_counter].end(),\n+ this->noise.data() + f * this->N);\n+\n+ std::copy(this->noise_buff[this->noise_counter].begin(),\n+ this->noise_buff[this->noise_counter].end(),\n+ Y_N + f * this->N);\n+\n+ this->noise_counter = (this->noise_counter + 1) % (int) this->noise_buff.size();\n+ }\n+ }\n+ }\n+}\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/User/Channel_user.hpp",
"new_path": "src/Module/Channel/User/Channel_user.hpp",
"diff": "@@ -15,14 +15,19 @@ class Channel_user : public Channel<R>\n{\nprivate:\nconst bool add_users;\n+ const bool additive_noise;\nmipp::vector<mipp::vector<R>> noise_buff;\nint noise_counter;\npublic:\n- Channel_user(const int N, const std::string &filename, const bool add_users = false, const int n_frames = 1);\n+ Channel_user(const int N, const std::string &filename, const bool add_users = false, const bool additive_noise = true, const int n_frames = 1);\nvirtual ~Channel_user();\nvoid add_noise(const R *X_N, R *Y_N, const int frame_id = -1); using Channel<R>::add_noise;\n+\n+protected:\n+ void open_as_text (const std::string& filename);\n+ void open_as_binary(const std::string& filename);\n};\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Modify Channel User
Fix the add_user part.
Add a additive_noise parameter; When true, the noise is added to the signal, else it is set as the output.
Add a file read as a text file; If can't be read, try as a binary file (as before)
|
8,483 |
27.04.2018 16:41:30
| -7,200 |
79205f8df7b36d4145e1225376824ba4ece5b3f6
|
Set the right channel type with error tracker revert
|
[
{
"change_type": "MODIFY",
"old_path": "src/Launcher/Simulation/BFER_std.cpp",
"new_path": "src/Launcher/Simulation/BFER_std.cpp",
"diff": "@@ -154,7 +154,11 @@ void BFER_std<B,R,Q>\nparams.cdc->itl->core->path = params.err_track_path + std::string(\"_$snr.itl\");\n}\n+ if (params.chn->type == \"USER_ADD\" || params.chn->type == \"AWGN\" || params.chn->type == \"RAYLEIGH\" || params.chn->type == \"RAYLEIGH_USER\")\n+ params.chn->type = \"USER_ADD\";\n+ else if (params.chn->type == \"USER\" || params.chn->type == \"BEC\" || params.chn->type == \"OPTICAL\")\nparams.chn->type = \"USER\";\n+ // else params.chn->type == \"NO\" stays as it is\nparams.chn->path = params.err_track_path + std::string(\"_$snr.chn\");\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Set the right channel type with error tracker revert
|
8,483 |
27.04.2018 18:04:41
| -7,200 |
d1c2f0efe0c2bc3f1631f288a79a314c191d15fa
|
Fix Modem optical
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/Optical/Modem_optical.cpp",
"new_path": "src/Module/Modem/Optical/Modem_optical.cpp",
"diff": "@@ -89,8 +89,6 @@ void Modem_optical<int,float,float>\n}\n}\n-\n-\ntemplate <typename B,typename R, typename Q>\nvoid Modem_optical<B,R,Q>\n::_filter(const R *Y_N1, R *Y_N2, const int frame_id)\n@@ -135,7 +133,7 @@ void Modem_optical<B,R,Q>\nauto x_below = x_above - 1;\n// find which between x_below and x_above is the nearest of Y_N1[i]\n- x_pos = (Y_N1[i] - *x_below) < (Y_N1[i] - *x_above) ? x_pos - 1 : x_pos;\n+ x_pos = (Y_N1[i] - *x_below) < (*x_above - Y_N1[i]) ? x_pos - 1 : x_pos;\n}\n// then get the matching probabilities\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix Modem optical
|
8,483 |
27.04.2018 18:17:28
| -7,200 |
024f44a6221c0cd617e71a6e274d4fa066a495c9
|
Remove the Point class
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/Distribution/Distribution.hpp",
"new_path": "src/Tools/Math/Distribution/Distribution.hpp",
"diff": "#include <vector>\n-#include \"Tools/Math/Point.hpp\"\n-\nnamespace aff3ct\n{\nnamespace tools\n"
},
{
"change_type": "DELETE",
"old_path": "src/Tools/Math/Point.hpp",
"new_path": null,
"diff": "-#ifndef POINT_HPP_\n-#define POINT_HPP_\n-\n-#include <utility>\n-\n-namespace aff3ct\n-{\n-namespace tools\n-{\n-\n-template <typename T>\n-class Point\n-{\n-protected:\n- T _x, _y;\n-\n-public:\n- Point(const T& x, const T& y);\n- Point(const Point<T>& p);\n- Point();\n- ~Point();\n-\n- void x(const T& x); // set x\n- void y(const T& y); // set y\n- const T& x() const; // read x\n- const T& y() const; // read y\n-\n- bool operator==(const Point<T>& p) const; // true when x and y are equal\n-};\n-\n-/*\n- * return true when p1.x() < p2.x()\n- */\n-template <typename T>\n-bool x_cmp_lt(const Point<T>& p1, const Point<T>& p2);\n-\n-/*\n- * return true when p1.x() <= p2.x()\n- */\n-template <typename T>\n-bool x_cmp_le(const Point<T>& p1, const Point<T>& p2);\n-\n-/*\n- * return true when p1.x() > p2.x()\n- */\n-template <typename T>\n-bool x_cmp_gt(const Point<T>& p1, const Point<T>& p2);\n-\n-/*\n- * return true when p1.x() >= p2.x()\n- */\n-template <typename T>\n-bool x_cmp_ge(const Point<T>& p1, const Point<T>& p2);\n-\n-/*\n- * return true when p1.x() == p2.x()\n- */\n-template <typename T>\n-bool x_cmp_eq(const Point<T>& p1, const Point<T>& p2);\n-\n-/*\n- * return true when p1.y() < p2.y()\n- */\n-template <typename T>\n-bool y_cmp_lt(const Point<T>& p1, const Point<T>& p2);\n-\n-/*\n- * return true when p1.y() <= p2.y()\n- */\n-template <typename T>\n-bool y_cmp_le(const Point<T>& p1, const Point<T>& p2);\n-\n-/*\n- * return true when p1.y() > p2.y()\n- */\n-template <typename T>\n-bool y_cmp_gt(const Point<T>& p1, const Point<T>& p2);\n-\n-/*\n- * return true when p1.y() >= p2.y()\n- */\n-template <typename T>\n-bool y_cmp_ge(const Point<T>& p1, const Point<T>& p2);\n-\n-/*\n- * return true when p1.y() == p2.y()\n- */\n-template <typename T>\n-bool y_cmp_eq(const Point<T>& p1, const Point<T>& p2);\n-\n-}\n-}\n-\n-#include \"Point.hxx\"\n-\n-#endif // POINT_HPP_\n\\ No newline at end of file\n"
},
{
"change_type": "DELETE",
"old_path": "src/Tools/Math/Point.hxx",
"new_path": null,
"diff": "-#ifndef POINT_HXX_\n-#define POINT_HXX_\n-\n-#include \"Point.hpp\"\n-#include \"Tools/Math/utils.h\"\n-\n-namespace aff3ct\n-{\n-namespace tools\n-{\n-\n-template <typename T>\n-Point<T>\n-::Point(const T& x, const T& y)\n-{\n- x(x);\n- y(y);\n-}\n-\n-template <typename T>\n-Point<T>\n-::Point(const Point<T>& p)\n-{\n- x(p.x());\n- y(p.y());\n-}\n-\n-template <typename T>\n-Point<T>\n-::Point()\n-{\n- x((T)0);\n- y((T)0);\n-}\n-\n-template <typename T>\n-Point<T>\n-::~Point()\n-{\n-}\n-\n-template <typename T>\n-inline void Point<T>\n-::x(const T& x)\n-{\n- this->_x = x;\n-}\n-\n-template <typename T>\n-inline void Point<T>\n-::y(const T& y)\n-{\n- this->_y = y;\n-}\n-\n-template <typename T>\n-inline const T& Point<T>\n-::x() const\n-{\n- return this->_x;\n-}\n-\n-template <typename T>\n-inline const T& Point<T>\n-::y() const\n-{\n- return this->_y;\n-}\n-\n-template <typename T>\n-inline bool Point<T>\n-::operator==(const Point<T>& p) const\n-{\n- return y_cmp_eq(*this, p) && x_cmp_eq(*this, p);\n-}\n-\n-template <typename T>\n-inline bool x_cmp_lt(const Point<T>& p1, const Point<T>& p2)\n-{\n- return p1.x() < p2.x();\n-}\n-\n-template <typename T>\n-inline bool x_cmp_le(const Point<T>& p1, const Point<T>& p2)\n-{\n- return p1.x() <= p2.x();\n-}\n-\n-template <typename T>\n-inline bool x_cmp_gt(const Point<T>& p1, const Point<T>& p2)\n-{\n- return p1.x() > p2.x();\n-}\n-\n-template <typename T>\n-inline bool x_cmp_ge(const Point<T>& p1, const Point<T>& p2)\n-{\n- return p1.x() >= p2.x();\n-}\n-\n-template <typename T>\n-inline bool x_cmp_eq(const Point<T>& p1, const Point<T>& p2)\n-{\n- return comp_equal(p1.x(), p2.x());\n-}\n-\n-template <typename T>\n-inline bool y_cmp_lt(const Point<T>& p1, const Point<T>& p2)\n-{\n- return p1.y() < p2.y();\n-}\n-\n-template <typename T>\n-inline bool y_cmp_le(const Point<T>& p1, const Point<T>& p2)\n-{\n- return p1.y() <= p2.y();\n-}\n-\n-template <typename T>\n-inline bool y_cmp_gt(const Point<T>& p1, const Point<T>& p2)\n-{\n- return p1.y() > p2.y();\n-}\n-\n-template <typename T>\n-inline bool y_cmp_ge(const Point<T>& p1, const Point<T>& p2)\n-{\n- return p1.y() >= p2.y();\n-}\n-\n-template <typename T>\n-inline bool y_cmp_eq(const Point<T>& p1, const Point<T>& p2)\n-{\n- return comp_equal(p1.y(), p2.y());\n-}\n-\n-\n-\n-}\n-}\n-\n-#endif // POINT_HXX_\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/interpolation.h",
"new_path": "src/Tools/Math/interpolation.h",
"diff": "#include <vector>\n#include <utility>\n-#include \"Point.hpp\"\n-\nnamespace aff3ct\n{\nnamespace tools\n@@ -20,14 +18,6 @@ namespace tools\ntemplate <typename T>\nT linear_interpolation(const T* x_data, const T* y_data, const unsigned l_data, const T x_val);\n-/*\n- * Compute the linear interpolation of x_val from the original data pair (x,y) of length l_data.\n- * data must be sorted and strictly monotonic increasing according to the first element of its pair, x.\n- * If x_val goes out of x_data range, then return the left or right limit value in function of the violated one.\n- */\n-template <typename T>\n-T linear_interpolation(const Point<T>* data, const unsigned l_data, const T x_val);\n-\n/*\n* Compute the linear interpolation of x_vals array, of length l_vals, from the original data y_data matching with its abscissa x_data.\n* x_data, of length l_data, must be sorted and strictly monotonic increasing\n@@ -45,16 +35,6 @@ void linear_interpolation(const T* x_data, const T* y_data, const unsigned l_dat\ntemplate <typename T>\nvoid linear_interpolation(const std::vector<T>& x_data, const std::vector<T>& y_data,\nconst std::vector<T>& x_vals, std::vector<T>& y_vals);\n-\n-/*\n- * Compute the linear interpolation of x absicca of 'vals' vector, from the original data pair (x,y).\n- * data must be sorted and strictly monotonic increasing according to the first element of its pair, x.\n- * Computed interpolation is returned in the y yield of vector 'vals'.\n- */\n-template <typename T>\n-void linear_interpolation(const std::vector<Point<T>>& data,\n- std::vector<Point<T>>& vals);\n-\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/interpolation.hxx",
"new_path": "src/Tools/Math/interpolation.hxx",
"diff": "#include <mipp.h>\n#include \"interpolation.h\"\n+#include \"utils.h\"\nnamespace aff3ct\n{\n@@ -33,25 +34,6 @@ T linear_interpolation(const T* x_data, const T* y_data, const unsigned l_data,\nreturn *y_below + (*y_above - *y_below) * (x_val - *x_below) / (*x_above - *x_below);\n}\n-template <typename T>\n-T linear_interpolation(const Point<T>* data, const unsigned l_data, const T x_val)\n-{\n- // find the position of the first x that is above the x_val\n- auto p_above = std::lower_bound(data, data + l_data, x_val, [](const Point<T>& p, const T& x){return p.x() < x;});\n-\n- if (p_above == data)\n- return data->y();\n-\n- auto p_below = p_above - 1; // get the position of value just below or equal to x_val\n-\n- if ((p_above == (data + l_data)) || comp_equal(x_val, p_below->x())) // if last or p_below->x() == x_val\n- return p_below->y(); // same x so take y directly\n-\n-\n- // compute the interpolation y = y0 + (y1-y0)*(x-x0)/(x1-x0);\n- return p_below->y() + (p_above->y() - p_below->y()) * (x_val - p_below->x()) / (p_above->x() - p_below->x());\n-}\n-\ntemplate <typename T>\nvoid linear_interpolation(const T* x_data, const T* y_data, const unsigned l_data,\nconst T* x_vals, T* y_vals, const unsigned l_vals)\n@@ -71,14 +53,6 @@ void linear_interpolation(const std::vector<T>& x_data, const std::vector<T>& y_\ny_vals[j] = linear_interpolation(x_data.data(), y_data.data(), x_data.size(), x_vals[j]);\n}\n-template <typename T>\n-void linear_interpolation(const std::vector<Point<T>>& data,\n- std::vector<Point<T>>& vals)\n-{\n- for(unsigned j = 0; j < vals.size(); j++)\n- vals[j].y(linear_interpolation(data.data(), data.size(), vals[j].x()));\n-}\n-\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/numerical_integration.h",
"new_path": "src/Tools/Math/numerical_integration.h",
"diff": "#ifndef NUMERICAL_INTEGRATION_H_\n#define NUMERICAL_INTEGRATION_H_\n-#include \"Tools/Math/Point.hpp\"\n-\nnamespace aff3ct\n{\nnamespace tools\n@@ -65,29 +63,6 @@ inline R trapz_integral_seq(const R* x, const R* y, int size);\ntemplate <typename R>\ninline void cumtrapz_integral_seq(const R* x, const R* y, R* cumul, int size);\n-/*\n- * Trapezoidal numerical integration\n- * Computes the approximate integral of the point ('x','y') array of length 'size' via the trapezoidal method\n- */\n-template <typename R>\n-inline R trapz_integral_seq(const Point<R>* p, int size);\n-\n-/*\n- * Cumulative Trapezoidal numerical integration\n- * Computes the approximate cumulative integral of the point ('x','y') array of length 'size' via the trapezoidal method\n- * Return the cumulative values in the 'cumul' array of length 'size'\n- */\n-template <typename R>\n-inline void cumtrapz_integral_seq(const Point<R>* p, R* cumul, int size);\n-\n-/*\n- * Cumulative Trapezoidal numerical integration\n- * Computes the approximate cumulative integral of the point ('x','y') array of length 'size' via the trapezoidal method\n- * Return the cumulative values in the 'cumul' array of length 'size'\n- */\n-template <typename R>\n-inline void cumtrapz_integral_seq(const Point<R>* p, Point<R>* cumul, int size);\n-\n/*\n* Trapezoidal numerical integration\n* Computes the approximate integral of the function 'f' from 'min' to 'max' with 'number_steps' steps via the trapezoidal method\n@@ -160,29 +135,6 @@ template <typename R>\ninline R right_rect_integral_seq(const R* x, const R* y, int size);\n-// ======================================================================== Rectangular numerical integration with Point\n-/*\n- * Middle Rectangular numerical integration\n- * Computes the approximate integral of the point ('x','y') array of length 'size' via the middle rectangular method\n- */\n-template <typename R>\n-inline R mid_rect_integral_seq(const Point<R>* p, const int size);\n-\n-/*\n- * Left Rectangular numerical integration\n- * Computes the approximate integral of the point ('x','y') array of length 'size' via the left rectangular method\n- */\n-template <typename R>\n-inline R left_rect_integral_seq(const Point<R>* p, const int size);\n-\n-/*\n- * Right Rectangular numerical integration\n- * Computes the approximate integral of the point ('x','y') array of length 'size' via the right rectangular method\n- */\n-template <typename R>\n-inline R right_rect_integral_seq(const Point<R>* p, const int size);\n-\n-\n// =====================================================================================================================\n// ======================================================================================= Simpson numerical integration\n// =====================================================================================================================\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/numerical_integration.hxx",
"new_path": "src/Tools/Math/numerical_integration.hxx",
"diff": "@@ -179,85 +179,6 @@ inline void cumtrapz_integral_seq(const R* x, const R* y, R* cumul, int size)\ncumul[size] = area;\n}\n-template <typename R>\n-inline R trapz_integral_seq(const Point<R>* p, int size)\n-{\n- assert(p != 0);\n- assert(size != 0);\n-\n- if (size <= 1)\n- return (R)0;\n-\n- size--;\n-\n- R area = 0;\n-\n- for (auto i = 0; i < size; i++)\n- area += div2((p[i+1].y() + p[i].y())) * (p[i+1].x() - p[i].x());\n-\n- return area;\n-}\n-\n-template <typename R>\n-inline void cumtrapz_integral_seq(const Point<R>* p, R* cumul, int size)\n-{\n- assert(p != 0);\n- assert(cumul!= 0);\n- assert(size != 0);\n-\n- if (size == 0)\n- return;\n-\n- if (size == 1)\n- {\n- *cumul = 0;\n- return;\n- }\n-\n- size--;\n-\n- R area = 0;\n-\n- for (auto i = 0; i < size; i++)\n- {\n- cumul[i] = area;\n- area += div2((p[i+1].y() + p[i].y())) * (p[i+1].x() - p[i].x());\n- }\n-\n- cumul[size] = area;\n-}\n-\n-template <typename R>\n-inline void cumtrapz_integral_seq(const Point<R>* p, Point<R>* cumul, int size)\n-{\n- assert(p != 0);\n- assert(cumul!= 0);\n- assert(size != 0);\n-\n- if (size == 0)\n- return;\n-\n- if (size == 1)\n- {\n- *cumul = 0;\n- return;\n- }\n-\n- size--;\n-\n- R area = 0;\n-\n- for (auto i = 0; i < size; i++)\n- {\n- cumul[i].x(p[i].x());\n- cumul[i].y(area);\n- area += div2((p[i+1].y() + p[i].y())) * (p[i+1].x() - p[i].x());\n- }\n-\n- cumul[size].x(p[size].x());\n- cumul[size].y(area);\n-}\n-\ntemplate <typename R, typename Function>\ninline R trapz_integral_seq(Function f, const R min, const R max, const int number_steps)\n{\n@@ -404,61 +325,6 @@ inline R right_rect_integral_seq(const R* x, const R* y, int size)\nreturn area;\n}\n-\n-// ======================================================================== Rectangular numerical integration with Point\n-template <typename R>\n-inline R mid_rect_integral_seq(const Point<R>* p, const int size)\n-{\n- assert(p != 0);\n- assert(size != 0);\n-\n- if (size <= 1)\n- return (R)0;\n-\n- R area = 0;\n-\n- for (auto i = 0; i < size; i++)\n- area += div2((p[i+1].y() + p[i].y())) * (p[i+1].x() - p[i].x());\n-\n- return area;\n-}\n-\n-\n-template <typename R>\n-inline R left_rect_integral_seq(const Point<R>* p, const int size)\n-{\n- assert(p != 0);\n- assert(size != 0);\n-\n- if (size <= 1)\n- return (R)0;\n-\n- R area = 0;\n-\n- for (auto i = 0; i < size; i++)\n- area += p[i].y() * (p[i+1].x() - p[i].x());\n-\n- return area;\n-}\n-\n-\n-template <typename R>\n-inline R right_rect_integral_seq(const Point<R>* p, const int size)\n-{\n- assert(p != 0);\n- assert(size != 0);\n-\n- if (size <= 1)\n- return (R)0;\n-\n- R area = 0;\n-\n- for (auto i = 1; i < size; i++)\n- area += p[i].y() * (p[i].x() - p[i-1].x());\n-\n- return area;\n-}\n-\n// =====================================================================================================================\n// ======================================================================================= Simpson numerical integration\n// =====================================================================================================================\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Remove the Point class
|
8,483 |
30.04.2018 16:42:24
| -7,200 |
6ad399c555a73ee91f065c670c41394c8ae5e987
|
Mangae the case of double types unsupported by mipp
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Perf/common/mutual_info.cpp",
"new_path": "src/Tools/Perf/common/mutual_info.cpp",
"diff": "@@ -24,6 +24,8 @@ template <typename B, typename R>\nR aff3ct::tools::mutual_info_histo(const B* ref, const R* llr, const unsigned size)\n{\nstatic_assert(mipp::N<B>() == mipp::N<R>(), \"B and R shall have the same size\");\n+ if (std::is_same<R,double>::value)\n+ return mutual_info_histo_seq(ref, llr, size);\n/* determine the min and max value for llrs / 0 and llrs / 1\n* compute the llr_sum as the sum of the llr[i]\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Mangae the case of double types unsupported by mipp
|
8,483 |
30.04.2018 16:45:36
| -7,200 |
b47bf53c4174ff1d103377aab3ddc70689f63652
|
Fix the Distribution by keeping the first element of the cdf and by comparing bitwisely the cumul
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/Distribution/Distribution.cpp",
"new_path": "src/Tools/Math/Distribution/Distribution.cpp",
"diff": "@@ -161,6 +161,7 @@ void Distribution<R>\nconst auto min_x = this->pdf_x.front();\nconst auto max_x = this->pdf_x.back ();\nconst auto step_x = (max_x - min_x) / (interp_x.size() - 1);\n+\n// create the interpolation x vector\nR x = min_x;\nfor (unsigned i = 0; i < interp_x.size(); i++, x += step_x)\n@@ -184,9 +185,13 @@ void Distribution<R>\nstd::vector<R> cumul_y(interp_x.size());\ncumtrapz_integral_seq(interp_x.data(), interp_y.data(), cumul_y.data(), interp_x.size());\n- // keeping the parts of the cdf not parallel to the X axis\n+ // keep the first element of the cdf\n+ this->cdf_x[k].push_back((R)0);\n+ this->cdf_y[k].push_back(cumul_y[0]);\n+\n+ // keep the parts of the cdf not parallel to the X axis\nfor (unsigned i = 1; i < cumul_y.size(); i++) // keep the first index\n- if (!tools::comp_equal(cumul_y[i] - cumul_y[i-1], (R)0)) // == 0 means parallel to the X axis\n+ if (cumul_y[i] != cumul_y[i-1]) // == means parallel to the X axis\n{\nthis->cdf_x[k].push_back(interp_x[i]);\nthis->cdf_y[k].push_back(cumul_y [i]);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix the Distribution by keeping the first element of the cdf and by comparing bitwisely the cumul
|
8,483 |
02.05.2018 10:46:44
| -7,200 |
e125544d93910a51737e6b2174a9675d9a0e5697
|
Do not display the last line when killing the simulation (Monisot::is_over)
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/BFER/Terminal_BFER.cpp",
"new_path": "src/Tools/Display/Terminal/BFER/Terminal_BFER.cpp",
"diff": "@@ -226,15 +226,19 @@ void Terminal_BFER<B,R>\nTerminal::final_report(stream);\n+ auto et = duration_cast<milliseconds>(steady_clock::now() - t_snr).count() / 1000.f;\n+\n+ if (!module::Monitor::is_over() || et >= 1.f)\n+ {\nthis->_report(stream);\n- auto et = duration_cast<milliseconds>(steady_clock::now() - t_snr).count() / 1000.f;\nauto et_format = get_time_format(et);\nstream << rang::style::bold << spaced_scol_separator << rang::style::reset << std::setprecision(0) << std::fixed\n<< std::setw(column_width - 1) << et_format;\nstream << (module::Monitor::is_interrupt() ? \" x\" : \" \") << std::endl;\n+ }\nt_snr = std::chrono::steady_clock::now();\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Do not display the last line when killing the simulation (Monisot::is_over)
|
8,483 |
02.05.2018 16:38:21
| -7,200 |
dfca181d947c7bb4578c4f608c907fdc0b9f0936
|
Add a destructor to delete the noise object
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/BFER/Terminal_BFER.cpp",
"new_path": "src/Tools/Display/Terminal/BFER/Terminal_BFER.cpp",
"diff": "@@ -24,6 +24,13 @@ Terminal_BFER<B,R>\n{\n}\n+template<typename B, typename R>\n+Terminal_BFER<B, R>::~Terminal_BFER()\n+{\n+ if (this->n != nullptr)\n+ delete this->n;\n+}\n+\ntemplate <typename B, typename R>\nvoid Terminal_BFER<B,R>\n::set_noise(const Noise<float>& noise)\n@@ -56,6 +63,7 @@ void Terminal_BFER<B,R>\nauto& throughput_cols = this->cols_groups[1].second;\nbfer_title = std::make_pair(\"Bit Error Rate (BER) and Frame Error Rate (FER)\", \"\");\n+ bfer_cols.clear();\nif (this->n == nullptr)\n{\n@@ -94,6 +102,7 @@ void Terminal_BFER<B,R>\nbfer_cols.push_back(std::make_pair(\"FER\", \"\"));\nthroughput_title = std::make_pair(\"Global throughput\", \"and elapsed time\");\n+ throughput_cols.clear();\nthroughput_cols.push_back(std::make_pair(\"SIM_THR\", \"(Mb/s)\"));\nthroughput_cols.push_back(std::make_pair(\"ET/RT\", \"(hhmmss)\"));\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/BFER/Terminal_BFER.hpp",
"new_path": "src/Tools/Display/Terminal/BFER/Terminal_BFER.hpp",
"diff": "@@ -26,7 +26,7 @@ protected:\npublic:\nexplicit Terminal_BFER(const module::Monitor_BFER<B,R> &monitor, bool display_mutinfo = false);\n- virtual ~Terminal_BFER() = default;\n+ virtual ~Terminal_BFER();\nvoid set_noise(const Noise<float>& noise);\nvoid set_noise(const Noise<double>& noise);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/EXIT/Terminal_EXIT.cpp",
"new_path": "src/Tools/Display/Terminal/EXIT/Terminal_EXIT.cpp",
"diff": "@@ -23,6 +23,13 @@ Terminal_EXIT<B,R>\n{\n}\n+template<typename B, typename R>\n+Terminal_EXIT<B,R>::~Terminal_EXIT()\n+{\n+ if (this->n != nullptr)\n+ delete this->n;\n+}\n+\ntemplate <typename B, typename R>\nvoid Terminal_EXIT<B,R>\n::set_noise(const Noise<float>& noise)\n@@ -62,6 +69,7 @@ void Terminal_EXIT<B,R>\nauto& throughput_cols = this->cols_groups[1].second;\nbfer_title = std::make_pair(\"EXIT chart depending on the\", \"\");\n+ bfer_cols.clear();\nif (this->n == nullptr)\n{\n@@ -88,7 +96,7 @@ void Terminal_EXIT<B,R>\n}\nbfer_title.second += \" and the channel A noise\";\n-\n+ throughput_cols.clear();\nbfer_cols.push_back(std::make_pair(\"SIG_A\", \"(dB)\"));\nbfer_cols.push_back(std::make_pair(\"FRA\", \"\"));\nbfer_cols.push_back(std::make_pair(\"A_PRIORI\", \"(I_A)\"));\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/EXIT/Terminal_EXIT.hpp",
"new_path": "src/Tools/Display/Terminal/EXIT/Terminal_EXIT.hpp",
"diff": "@@ -27,7 +27,7 @@ protected:\npublic:\nexplicit Terminal_EXIT(const module::Monitor_EXIT<B,R> &monitor);\n- virtual ~Terminal_EXIT() = default;\n+ virtual ~Terminal_EXIT();\nvoid set_sig_a(float sig_a);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a destructor to delete the noise object
|
8,483 |
03.05.2018 08:38:35
| -7,200 |
d2d8bc2e38c2527fc388aae4f0d60ee2410cbcb9
|
Renaming Erasure Probability -> Event Probability
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Channel/Channel.cpp",
"new_path": "src/Factory/Module/Channel/Channel.cpp",
"diff": "@@ -193,7 +193,7 @@ module::Channel<R>* Channel::parameters\nif (type == \"USER\" ) return new module::Channel_user<R>(N, path, add_users, false, n_frames);\nelse if (type == \"USER_ADD\") return new module::Channel_user<R>(N, path, add_users, true, n_frames);\nelse if (type == \"NO\" ) return new module::Channel_NO <R>(N, add_users, n_frames);\n- else if (type == \"BEC\" ) return new module::Channel_BEC <R>(N, seed, tools::Erasure_probability<R>((R)this->noise), n_frames);\n+ else if (type == \"BEC\" ) return new module::Channel_BEC <R>(N, seed, tools::Event_probability<R>((R)this->noise), n_frames);\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/BEC/Channel_BEC.cpp",
"new_path": "src/Module/Channel/BEC/Channel_BEC.cpp",
"diff": "@@ -6,7 +6,7 @@ using namespace aff3ct::module;\ntemplate <typename R>\nChannel_BEC<R>\n-::Channel_BEC(const int N, const int seed, const tools::Erasure_probability<R>& noise, const int n_frames)\n+::Channel_BEC(const int N, const int seed, const tools::Event_probability<R>& noise, const int n_frames)\n: Channel<R>(N, noise, n_frames), uni_dist((R)0, (R)1)\n{\nconst std::string name = \"Channel_BEC\";\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/BEC/Channel_BEC.hpp",
"new_path": "src/Module/Channel/BEC/Channel_BEC.hpp",
"diff": "@@ -29,7 +29,7 @@ protected:\npublic:\nChannel_BEC(const int N, const int seed = 0,\n- const tools::Erasure_probability<R>& noise = tools::Erasure_probability<R>(),\n+ const tools::Event_probability<R>& noise = tools::Event_probability<R>(),\nconst int n_frames = 1);\nvirtual ~Channel_BEC() = default;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.cpp",
"new_path": "src/Simulation/BFER/BFER.cpp",
"diff": "@@ -170,7 +170,7 @@ void BFER<B,R,Q>\n{\nn = params_BFER.noise_range[params_BFER.noise_range.size() - noise_idx -1];\n- this->noise = new tools::Erasure_probability<R>(n);\n+ this->noise = new tools::Event_probability<R>(n);\n}\nelse\n{\n"
},
{
"change_type": "RENAME",
"old_path": "src/Tools/Noise/Erasure_probability.cpp",
"new_path": "src/Tools/Noise/Event_probability.cpp",
"diff": "#include <sstream>\n#include \"Tools/Exception/exception.hpp\"\n-#include \"Erasure_probability.hpp\"\n+#include \"Event_probability.hpp\"\nusing namespace aff3ct;\nusing namespace aff3ct::tools;\ntemplate<typename R>\n-Erasure_probability<R>::Erasure_probability(R noise)\n+Event_probability<R>::Event_probability(R noise)\n: Noise<R>(noise)\n{\n@@ -15,14 +15,14 @@ Erasure_probability<R>::Erasure_probability(R noise)\ntemplate <typename R>\ntemplate<typename T>\n-Erasure_probability<R>::\n-Erasure_probability(const Erasure_probability<T>& other)\n+Event_probability<R>::\n+Event_probability(const Event_probability<T>& other)\n: Noise<R>(other)\n{\n}\ntemplate <typename R>\n-void Erasure_probability<R>::\n+void Event_probability<R>::\ncheck()\n{\nauto n = this->get_noise();\n@@ -35,27 +35,27 @@ check()\n}\ntemplate<typename R>\n-Noise_type Erasure_probability<R>::get_type() const\n+Noise_type Event_probability<R>::get_type() const\n{\nreturn Noise_type::EP;\n}\ntemplate<typename R>\n-Erasure_probability<R>* Erasure_probability<R>::clone() const\n+Event_probability<R>* Event_probability<R>::clone() const\n{\n- return new Erasure_probability<R>(*this);\n+ return new Event_probability<R>(*this);\n}\ntemplate<typename R>\n-std::string Erasure_probability<R>::get_unity() const\n+std::string Event_probability<R>::get_unity() const\n{\nreturn \"\";\n}\n// ==================================================================================== explicit template instantiation\n-template class aff3ct::tools::Erasure_probability<float>;\n-template class aff3ct::tools::Erasure_probability<double>;\n+template class aff3ct::tools::Event_probability<float>;\n+template class aff3ct::tools::Event_probability<double>;\n-template aff3ct::tools::Erasure_probability<double>::Erasure_probability(const Erasure_probability<float >&);\n-template aff3ct::tools::Erasure_probability<float >::Erasure_probability(const Erasure_probability<double>&);\n+template aff3ct::tools::Event_probability<double>::Event_probability(const Event_probability<float >&);\n+template aff3ct::tools::Event_probability<float >::Event_probability(const Event_probability<double>&);\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "RENAME",
"old_path": "src/Tools/Noise/Erasure_probability.hpp",
"new_path": "src/Tools/Noise/Event_probability.hpp",
"diff": "@@ -9,26 +9,26 @@ namespace tools\n{\ntemplate <typename R = float>\n-class Erasure_probability : public Noise<R>\n+class Event_probability : public Noise<R>\n{\npublic:\n- Erasure_probability() = default;\n- explicit Erasure_probability(R noise);\n+ Event_probability() = default;\n+ explicit Event_probability(R noise);\ntemplate<typename T>\n- Erasure_probability(const Erasure_probability<T>& other);\n- virtual ~Erasure_probability() = default;\n+ Event_probability(const Event_probability<T>& other);\n+ virtual ~Event_probability() = default;\nvirtual std::string get_unity() const;\nvirtual Noise_type get_type() const;\n- virtual Erasure_probability<R>* clone() const;\n+ virtual Event_probability<R>* clone() const;\nprotected:\nvirtual void check();\n};\ntemplate <typename R = float>\n-using EP = Erasure_probability<R>;\n+using EP = Event_probability<R>;\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Noise/noise_utils.h",
"new_path": "src/Tools/Noise/noise_utils.h",
"diff": "#define NOISE_UTILS_HPP__\n#include \"Sigma.hpp\"\n-#include \"Erasure_probability.hpp\"\n+#include \"Event_probability.hpp\"\n#include \"Received_optical_power.hpp\"\nnamespace aff3ct\n@@ -20,7 +20,7 @@ struct Noise_cast\nswitch(n.get_type())\n{\ncase Noise_type::SIGMA: cast_n = new Sigma <T>(dynamic_cast<const Sigma <R>&>(n)); break;\n- case Noise_type::EP: cast_n = new Erasure_probability <T>(dynamic_cast<const Erasure_probability <R>&>(n)); break;\n+ case Noise_type::EP: cast_n = new Event_probability <T>(dynamic_cast<const Event_probability <R>&>(n)); break;\ncase Noise_type::ROP: cast_n = new Received_optical_power<T>(dynamic_cast<const Received_optical_power<R>&>(n)); break;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/aff3ct.hpp",
"new_path": "src/aff3ct.hpp",
"diff": "#include <Tools/Math/Distribution/Distributions.hpp>\n#include <Tools/Math/Galois.hpp>\n#include <Tools/Math/Point.hpp>\n-#include <Tools/Noise/Erasure_probability.hpp>\n+#include \"Tools/Noise/Event_probability.hpp\"\n#include <Tools/Noise/Noise.hpp>\n#include <Tools/Noise/Received_optical_power.hpp>\n#include <Tools/Noise/Sigma.hpp>\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Renaming Erasure Probability -> Event Probability
|
8,483 |
03.05.2018 11:57:43
| -7,200 |
9d4f06dd8f955e825bb43017d10859cac66c80f1
|
Add a remove connection in the Sparse matrix
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Sparse_matrix/Sparse_matrix.cpp",
"new_path": "src/Tools/Algo/Sparse_matrix/Sparse_matrix.cpp",
"diff": "@@ -139,6 +139,79 @@ void Sparse_matrix\nthis->n_connections++;\n}\n+void Sparse_matrix::rm_connection(const size_t row_index, const size_t col_index)\n+{\n+ if (col_index >= this->n_cols)\n+ {\n+ std::stringstream message;\n+ message << \"'col_index' has to be smaller than 'n_cols' ('col_index' = \" << col_index\n+ << \", 'n_cols' = \" << this->n_cols << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (row_index >= this->n_rows)\n+ {\n+ std::stringstream message;\n+ message << \"'row_index' has to be smaller than 'n_rows' ('row_index' = \" << row_index\n+ << \", 'n_rows' = \" << this->n_rows << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ // delete the link in the row_to_cols vector\n+ auto itr = std::find(this->row_to_cols[row_index].begin(), this->row_to_cols[row_index].end(), col_index);\n+ if (itr != this->row_to_cols[row_index].end());\n+ {\n+ this->row_to_cols[row_index].erase(itr);\n+\n+ // check if need to reduce the rows max degree\n+ if (this->row_to_cols[row_index].size() == (this->rows_max_degree-1))\n+ {\n+ bool found = false;\n+ for (auto i = this->row_to_cols.begin(); i != this->row_to_cols.end(); i++ )\n+ if (i->size() == this->rows_max_degree)\n+ {\n+ found = true;\n+ break;\n+ }\n+\n+ if (!found)\n+ this->rows_max_degree--;\n+ }\n+ }\n+\n+ // delete the link in the col_to_rows vector\n+ auto itc = std::find(this->col_to_rows[col_index].begin(), this->col_to_rows[col_index].end(), col_index);\n+ if (itc != this->col_to_rows[col_index].end());\n+ {\n+ this->col_to_rows[col_index].erase(itc);\n+\n+ // check if need to reduce the cols max degree\n+ if (this->col_to_rows[col_index].size() == (this->cols_max_degree-1))\n+ {\n+ bool found = false;\n+ for (auto i = this->col_to_rows.begin(); i != this->col_to_rows.end(); i++ )\n+ if (i->size() == this->cols_max_degree)\n+ {\n+ found = true;\n+ break;\n+ }\n+\n+ if (!found)\n+ this->cols_max_degree--;\n+ }\n+ }\n+\n+ if ((itr == this->row_to_cols[row_index].end()) != (itc == this->col_to_rows[col_index].end()))\n+ {\n+ std::stringstream message;\n+ message << \"The connection has been found only in one of the two vectors 'row_to_cols' and 'col_to_rows' \"\n+ << \"('row_index' = \" << row_index << \"'col_index' = \" << col_index << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ this->n_connections--;\n+}\n+\nSparse_matrix Sparse_matrix\n::transpose() const\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Sparse_matrix/Sparse_matrix.hpp",
"new_path": "src/Tools/Algo/Sparse_matrix/Sparse_matrix.hpp",
"diff": "@@ -40,8 +40,16 @@ public:\nconst std::vector<std::vector<unsigned int>>& get_row_to_cols() const;\nconst std::vector<std::vector<unsigned int>>& get_col_to_rows() const;\n+ /*\n+ * Add a connection\n+ */\nvoid add_connection(const size_t row_index, const size_t col_index);\n+ /*\n+ * Remove the connection\n+ */\n+ void rm_connection(const size_t row_index, const size_t col_index);\n+\n/*\n* Return the transposed matrix of this matrix\n*/\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a remove connection in the Sparse matrix
|
8,483 |
03.05.2018 12:29:51
| -7,200 |
a49e507ee8630b260be2fb697a2714fb720af471
|
Add a sequential hard decide function
|
[
{
"change_type": "DELETE",
"old_path": "src/Tools/Perf/common.cpp",
"new_path": null,
"diff": "-#include <limits>\n-#include <algorithm>\n-#include <mipp.h>\n-\n-#include \"common.h\"\n-\n-//********************************************************************************************************** hard_decide\n-\n-template <typename B, typename Q>\n-void aff3ct::tools::hard_decide(const Q *in, B *out, const int size)\n-{\n- const auto vec_loop_size = (size / mipp::nElReg<Q>()) * mipp::nElReg<Q>();\n- if (mipp::isAligned(in) && mipp::isAligned(out))\n- {\n- for (auto i = 0; i < vec_loop_size; i += mipp::nElReg<Q>())\n- {\n- const auto q_in = mipp::Reg<Q>(&in[i]);\n- const auto q_out = mipp::cast<Q,B>(q_in) >> (sizeof(B) * 8 - 1);\n- q_out.store(&out[i]);\n- }\n- }\n- else\n- {\n- for (auto i = 0; i < vec_loop_size; i += mipp::nElReg<Q>())\n- {\n- mipp::Reg<Q> q_in;\n- q_in.loadu(&in[i]);\n- const auto q_out = mipp::cast<Q,B>(q_in) >> (sizeof(B) * 8 - 1);\n- q_out.storeu(&out[i]);\n- }\n- }\n- for (auto i = vec_loop_size; i < size; i++)\n- out[i] = in[i] < 0;\n-}\n-\n-\n-\n-//************************************************************************************************* hamming_distance_seq\n-\n-template <typename B>\n-inline size_t aff3ct::tools::hamming_distance_seq(const B *in1, const B *in2, const int size)\n-{\n- size_t ham_dist = 0;\n-\n- for (auto i = 0; i < size; i++)\n- ham_dist += (!in1[i] != !in2[i])? (size_t)1 : (size_t)0;\n-\n- return ham_dist;\n-}\n-\n-\n-\n-//***************************************************************************************************** hamming_distance\n-\n-#ifdef MIPP_AVX1\n-\n-template <typename B>\n-size_t aff3ct::tools::hamming_distance(const B *in1, const B *in2, const int size)\n-{\n- return hamming_distance_seq(in1, in2, size);\n-}\n-\n-#else\n-\n-template <typename B>\n-inline mipp::Reg<B> popcnt(const mipp::Reg<B>& q_in1, const mipp::Reg<B>& q_in2)\n-{\n- const mipp::Reg<B> zeros = (B)0, ones = (B)1;\n- const auto m_in1 = q_in1 != zeros;\n- const auto m_in2 = q_in2 != zeros;\n- return mipp::blend(ones, zeros, m_in1 ^ m_in2);\n-}\n-\n-template <typename B>\n-size_t aff3ct::tools::hamming_distance(const B *in1, const B *in2, const int size)\n-{\n- mipp::Reg<B> counter = (B)0;\n-\n- const auto vec_loop_size = (size / mipp::N<B>()) * mipp::N<B>();\n-\n- for (auto i = 0; i < vec_loop_size; i += mipp::N<B>())\n- counter += popcnt<B>(in1 + i, in2 + i);\n-\n- size_t ham_dist = mipp::hadd(counter);\n-\n- ham_dist += tools::hamming_distance_seq(in1 + vec_loop_size, in2 + vec_loop_size, size - vec_loop_size);\n-\n- return ham_dist;\n-}\n-\n-namespace aff3ct\n-{\n-namespace tools\n-{\n-template <>\n-size_t hamming_distance<int16_t>(const int16_t *in1, const int16_t *in2, const int size)\n-{\n-#ifdef MIPP_BW\n- mipp::Reg<int32_t> counter32 = (int32_t)0;\n-\n- const auto vec_loop_size = mipp::N<int16_t>() < 2 ? 0 : (size / mipp::N<int16_t>()) * mipp::N<int16_t>();\n- constexpr auto stride = std::numeric_limits<int16_t>::max() * mipp::N<int16_t>();\n- for (auto ii = 0; ii < vec_loop_size; ii += stride)\n- {\n- mipp::Reg<int16_t> counter16 = (int16_t)0;\n- const auto vec_loop_size2 = std::min(vec_loop_size, ii + stride);\n- for (auto i = ii; i < vec_loop_size2; i += mipp::N<int16_t>())\n- counter16 += popcnt<int16_t>(in1 + i, in2 + i);\n-\n- counter32 += mipp::cvt<int16_t,int32_t>(counter16.low ());\n- counter32 += mipp::cvt<int16_t,int32_t>(counter16.high());\n- }\n-\n- size_t ham_dist = (size_t)mipp::hadd(counter32);\n-#else\n- const auto vec_loop_size = 0;\n- size_t ham_dist = 0;\n-#endif\n-\n- ham_dist += tools::hamming_distance_seq<int16_t>(in1 + vec_loop_size, in2 + vec_loop_size, size - vec_loop_size);\n-\n- return ham_dist;\n-}\n-\n-template <>\n-size_t hamming_distance<int8_t>(const int8_t *in1, const int8_t *in2, const int size)\n-{\n-#ifdef MIPP_BW\n- const mipp::Reg<int8_t> zeros = (int8_t)0, ones = (int8_t)1;\n- mipp::Reg<int32_t> counter32 = (int32_t)0;\n-\n- const auto vec_loop_size = mipp::N<int8_t>() < 4 ? 0 : (size / mipp::N<int8_t>()) * mipp::N<int8_t>();\n- constexpr auto stride = std::numeric_limits<int8_t>::max() * mipp::N<int8_t>();\n- for (auto ii = 0; ii < vec_loop_size; ii += stride)\n- {\n- mipp::Reg<int8_t> counter8 = (int8_t)0;\n- const auto vec_loop_size2 = std::min(vec_loop_size, ii + stride);\n- for (auto i = ii; i < vec_loop_size2; i += mipp::N<int8_t>())\n- counter8 += popcnt<int8_t>(in1 + i, in2 + i);\n-\n- const auto low = mipp::cvt<int8_t,int16_t>(counter8.low());\n- counter32 += mipp::cvt<int16_t,int32_t>(low.low ());\n- counter32 += mipp::cvt<int16_t,int32_t>(low.high());\n-\n- const auto high = mipp::cvt<int8_t,int16_t>(counter8.high());\n- counter32 += mipp::cvt<int16_t,int32_t>(high.low ());\n- counter32 += mipp::cvt<int16_t,int32_t>(high.high());\n- }\n-\n- size_t ham_dist = (size_t)mipp::hadd(counter32);\n-\n-#else\n- const auto vec_loop_size = 0;\n- size_t ham_dist = 0;\n-#endif\n-\n- ham_dist += tools::hamming_distance_seq<int8_t>(in1 + vec_loop_size, in2 + vec_loop_size, size - vec_loop_size);\n-\n- return ham_dist;\n-}\n-}\n-}\n-\n-#endif // #ifdef MIPP_AVX\n-\n-// ==================================================================================== explicit template instantiation\n-#include \"Tools/types.h\"\n-#ifdef MULTI_PREC\n-template size_t aff3ct::tools::hamming_distance<B_8 >(const B_8*, const B_8*, const int);\n-template size_t aff3ct::tools::hamming_distance<B_16>(const B_16*, const B_16*, const int);\n-template size_t aff3ct::tools::hamming_distance<B_32>(const B_32*, const B_32*, const int);\n-template size_t aff3ct::tools::hamming_distance<B_64>(const B_64*, const B_64*, const int);\n-#else\n-template size_t aff3ct::tools::hamming_distance<B>(const B*, const B*, const int);\n-#endif\n-\n-#ifdef MULTI_PREC\n-template void aff3ct::tools::hard_decide<B_8, Q_8 >(const Q_8*, B_8*, const int);\n-template void aff3ct::tools::hard_decide<B_16, Q_16>(const Q_16*, B_16*, const int);\n-template void aff3ct::tools::hard_decide<B_32, Q_32>(const Q_32*, B_32*, const int);\n-template void aff3ct::tools::hard_decide<B_64, Q_64>(const Q_64*, B_64*, const int);\n-#else\n-template void aff3ct::tools::hard_decide<B, Q>(const Q*, B*, const int);\n-#endif\n-\n-#ifdef MULTI_PREC\n-template size_t aff3ct::tools::hamming_distance_seq<B_8 >(const B_8*, const B_8*, const int);\n-template size_t aff3ct::tools::hamming_distance_seq<B_16>(const B_16*, const B_16*, const int);\n-template size_t aff3ct::tools::hamming_distance_seq<B_32>(const B_32*, const B_32*, const int);\n-template size_t aff3ct::tools::hamming_distance_seq<B_64>(const B_64*, const B_64*, const int);\n-#else\n-template size_t aff3ct::tools::hamming_distance_seq<B>(const B*, const B*, const int);\n-#endif\n-\n-// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "DELETE",
"old_path": "src/Tools/Perf/common.h",
"new_path": null,
"diff": "-#ifndef COMMON_H_\n-#define COMMON_H_\n-\n-#include <cstdint>\n-#include <cstddef>\n-\n-namespace aff3ct\n-{\n-namespace tools\n-{\n-/*\n- * take the hard decision on the array 'in' and fill 'out', both of length 'size'\n- */\n-template <typename B = int, typename Q = float>\n-void hard_decide(const Q *in, B *out, const int size);\n-\n-/*\n- * compute the Hamming distance between the arrays 'in1' and 'in2' of length 'size'\n- */\n-template <typename B = int32_t>\n-size_t hamming_distance_seq(const B *in1, const B *in2, const int size);\n-\n-/*\n- * compute the Hamming distance between the arrays 'in1' and 'in2' of length 'size'\n- * Operations are optimized with MIPP except for AVX architecture that call hamming_distance_seq.\n- */\n-template <typename B = int32_t>\n-size_t hamming_distance(const B *in1, const B *in2, const int size);\n-}\n-}\n-\n-#endif /* COMMON_H_ */\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Perf/common/hard_decide.cpp",
"new_path": "src/Tools/Perf/common/hard_decide.cpp",
"diff": "#include \"hard_decide.h\"\ntemplate <typename B, typename Q>\n-void aff3ct::tools::hard_decide(const Q *in, B *out, const int size)\n+void aff3ct::tools::hard_decide_seq(const Q *in, B *out, const unsigned size)\n{\n- const auto vec_loop_size = (size / mipp::nElReg<Q>()) * mipp::nElReg<Q>();\n+ for (unsigned i = 0; i < size; i++)\n+ out[i] = in[i] < 0;\n+}\n+\n+template <typename B, typename Q>\n+void aff3ct::tools::hard_decide(const Q *in, B *out, const unsigned size)\n+{\n+ const auto vec_loop_size = (size / (unsigned)mipp::nElReg<Q>()) * (unsigned)mipp::nElReg<Q>();\nif (mipp::isAligned(in) && mipp::isAligned(out))\n{\n- for (auto i = 0; i < vec_loop_size; i += mipp::nElReg<Q>())\n+ for (unsigned i = 0; i < vec_loop_size; i += mipp::nElReg<Q>())\n{\nconst auto q_in = mipp::Reg<Q>(&in[i]);\nconst auto q_out = mipp::cast<Q,B>(q_in) >> (sizeof(B) * 8 - 1);\n@@ -17,7 +24,7 @@ void aff3ct::tools::hard_decide(const Q *in, B *out, const int size)\n}\nelse\n{\n- for (auto i = 0; i < vec_loop_size; i += mipp::nElReg<Q>())\n+ for (unsigned i = 0; i < vec_loop_size; i += mipp::nElReg<Q>())\n{\nmipp::Reg<Q> q_in;\nq_in.loadu(&in[i]);\n@@ -25,17 +32,22 @@ void aff3ct::tools::hard_decide(const Q *in, B *out, const int size)\nq_out.storeu(&out[i]);\n}\n}\n- for (auto i = vec_loop_size; i < size; i++)\n- out[i] = in[i] < 0;\n+\n+ tools::hard_decide_seq(in + vec_loop_size, out + vec_loop_size, size - vec_loop_size);\n}\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n-template void aff3ct::tools::hard_decide<B_8, Q_8 >(const Q_8*, B_8*, const int);\n-template void aff3ct::tools::hard_decide<B_16, Q_16>(const Q_16*, B_16*, const int);\n-template void aff3ct::tools::hard_decide<B_32, Q_32>(const Q_32*, B_32*, const int);\n-template void aff3ct::tools::hard_decide<B_64, Q_64>(const Q_64*, B_64*, const int);\n+template void aff3ct::tools::hard_decide<B_8, Q_8 >(const Q_8*, B_8*, const unsigned);\n+template void aff3ct::tools::hard_decide<B_16, Q_16>(const Q_16*, B_16*, const unsigned);\n+template void aff3ct::tools::hard_decide<B_32, Q_32>(const Q_32*, B_32*, const unsigned);\n+template void aff3ct::tools::hard_decide<B_64, Q_64>(const Q_64*, B_64*, const unsigned);\n+\n+template void aff3ct::tools::hard_decide_seq<B_8, Q_8 >(const Q_8*, B_8*, const unsigned);\n+template void aff3ct::tools::hard_decide_seq<B_16, Q_16>(const Q_16*, B_16*, const unsigned);\n+template void aff3ct::tools::hard_decide_seq<B_32, Q_32>(const Q_32*, B_32*, const unsigned);\n+template void aff3ct::tools::hard_decide_seq<B_64, Q_64>(const Q_64*, B_64*, const unsigned);\n#else\ntemplate void aff3ct::tools::hard_decide<B, Q>(const Q*, B*, const int);\n#endif\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Perf/common/hard_decide.h",
"new_path": "src/Tools/Perf/common/hard_decide.h",
"diff": "@@ -11,7 +11,14 @@ namespace tools\n* take the hard decision on the array 'in' and fill 'out', both of length 'size'\n*/\ntemplate <typename B = int, typename Q = float>\n-void hard_decide(const Q *in, B *out, const int size);\n+void hard_decide_seq(const Q *in, B *out, const unsigned size);\n+\n+/*\n+ * take the hard decision on the array 'in' and fill 'out', both of length 'size'\n+ * Operations are optimized with MIPP\n+ */\n+template <typename B = int, typename Q = float>\n+void hard_decide(const Q *in, B *out, const unsigned size);\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a sequential hard decide function
|
8,483 |
03.05.2018 14:02:03
| -7,200 |
27a9915044d23b201cb544db8a1056cdbe42f380
|
Fix hard decide explicit template instanciation
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Perf/common/hard_decide.cpp",
"new_path": "src/Tools/Perf/common/hard_decide.cpp",
"diff": "@@ -49,6 +49,6 @@ template void aff3ct::tools::hard_decide_seq<B_16, Q_16>(const Q_16*, B_16*, con\ntemplate void aff3ct::tools::hard_decide_seq<B_32, Q_32>(const Q_32*, B_32*, const unsigned);\ntemplate void aff3ct::tools::hard_decide_seq<B_64, Q_64>(const Q_64*, B_64*, const unsigned);\n#else\n-template void aff3ct::tools::hard_decide<B, Q>(const Q*, B*, const int);\n+template void aff3ct::tools::hard_decide<B, Q>(const Q*, B*, const unsigned);\n#endif\n// ==================================================================================== explicit template instantiation\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix hard decide explicit template instanciation
|
8,483 |
03.05.2018 14:17:33
| -7,200 |
5d5216d039895dbab7af9d051abac461786305b9
|
Create an Erased value structure
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/BEC/Channel_BEC.cpp",
"new_path": "src/Module/Channel/BEC/Channel_BEC.cpp",
"diff": "#include <type_traits>\n+#include \"Tools/Noise/Erased_value.hpp\"\n#include \"Channel_BEC.hpp\"\nusing namespace aff3ct;\n@@ -70,7 +71,7 @@ void Channel_BEC<R>\nconst auto erasure_probability = this->n->get_noise();\n- const mipp::Reg<R> r_erased = tools::Noise<R>::erased_symbol_val;\n+ const mipp::Reg<R> r_erased = tools::Erased_value<R>::symbol;\nconst mipp::Reg<R> r_ep = erasure_probability;\nconst auto vec_loop_size = (std::is_same<R,float>::value) ? ((this->N / mipp::nElReg<R>()) * mipp::nElReg<R>()) : 0;\n@@ -84,7 +85,7 @@ void Channel_BEC<R>\n}\nfor (auto i = vec_loop_size; i < this->N; i++)\n- Y_N[i] = get_random() <= erasure_probability ? tools::Noise<R>::erased_symbol_val : X_N[i];\n+ Y_N[i] = get_random() <= erasure_probability ? tools::Erased_value<R>::symbol : X_N[i];\n}\ntemplate<typename R>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/OOK/Modem_OOK.cpp",
"new_path": "src/Module/Modem/OOK/Modem_OOK.cpp",
"diff": "#include <type_traits>\n+#include \"Tools/Noise/Erased_value.hpp\"\n#include \"Tools/Exception/exception.hpp\"\n#include \"Modem_OOK.hpp\"\n@@ -72,9 +73,9 @@ void Modem_OOK<B,R,Q>\ncase tools::Noise_type::EP:\n{\n- auto sign = (Q)tools::Noise<R>::erased_llr_val;\n+ auto sign = tools::Erased_value<Q>::llr;\nfor (auto i = 0; i < this->N_fil; i++)\n- if (Y_N1[i] == tools::Noise<R>::erased_symbol_val)\n+ if (Y_N1[i] == tools::Erased_value<Q>::symbol)\n{\nY_N2[i] = sign;\nsign *= (Q)-1;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Noise/Erased_value.hpp",
"diff": "+#ifndef ERASED_VALUE_HPP\n+#define ERASED_VALUE_HPP\n+\n+#include <type_traits>\n+#include <limits>\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+\n+template<class T>\n+constexpr typename std::enable_if<std::is_integral<T>::value, T>::type erased_value_symbol()\n+{\n+ return std::numeric_limits<T>::max();\n+}\n+\n+template<class T>\n+constexpr typename std::enable_if<std::is_floating_point<T>::value, T>::type erased_value_symbol()\n+{\n+ return std::numeric_limits<T>::infinity();\n+}\n+\n+template<class T>\n+constexpr typename std::enable_if<std::is_integral<T>::value, T>::type erased_value_llr()\n+{\n+ return 0;\n+}\n+\n+template<class T>\n+constexpr typename std::enable_if<std::is_floating_point<T>::value, T>::type erased_value_llr()\n+{\n+ return (T)0.000001;\n+}\n+\n+template<typename Q = float>\n+struct Erased_value\n+{\n+ static constexpr Q symbol = erased_value_symbol<Q>();\n+ static constexpr Q llr = erased_value_llr<Q>();\n+};\n+\n+}\n+}\n+#endif //ERASED_VALUE_HPP\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Noise/Noise.cpp",
"new_path": "src/Tools/Noise/Noise.cpp",
"diff": "using namespace aff3ct;\nusing namespace aff3ct::tools;\n-template <typename R>\n-const R aff3ct::tools::Noise<R>::erased_symbol_val = std::numeric_limits<R>::infinity();\n-template <typename R>\n-const R aff3ct::tools::Noise<R>::erased_llr_val = (R)0.00001;\n-\ntemplate <typename R>\nNoise<R>::\nNoise()\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Noise/Noise.hpp",
"new_path": "src/Tools/Noise/Noise.hpp",
"diff": "#include <utility>\n#include <string>\n-#include <limits>\nnamespace aff3ct\n{\n@@ -15,10 +14,6 @@ enum class Noise_type {SIGMA, ROP, EP};\ntemplate <typename R = float>\nclass Noise\n{\n-public:\n- static const R erased_symbol_val;\n- static const R erased_llr_val;\n-\npublic:\nNoise();\nexplicit Noise(R noise);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Create an Erased value structure
|
8,483 |
03.05.2018 15:39:03
| -7,200 |
bd8dfc8bfb7613f00e3aabcb597d9023a81276d0
|
Add precompiler check for --except-no-bt and --except-a2l with ENABLE_BACk_TRACE and NDEBUG flags
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Launcher/Launcher.cpp",
"new_path": "src/Factory/Launcher/Launcher.cpp",
"diff": "@@ -115,18 +115,22 @@ void factory::Launcher::parameters\ntools::None(),\n\"print informations about the version of the code.\");\n+#ifdef ENABLE_BACK_TRACE\nargs.add(\n{\"except-no-bt\"},\ntools::None(),\n\"do not print the backtrace when displaying exception.\",\ntools::arg_rank::ADV);\n+#endif\n+#ifndef NDEBUG\nargs.add(\n{\"except-a2l\"},\ntools::None(),\n\"enhance the backtrace when displaying exception by changing program addresses into \"\n\" file names and lines (may take some seconds).\",\ntools::arg_rank::ADV);\n+#endif\nargs.add(\n{p+\"-no-legend\"},\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add precompiler check for --except-no-bt and --except-a2l with ENABLE_BACk_TRACE and NDEBUG flags
|
8,483 |
03.05.2018 16:26:47
| -7,200 |
0c81f14a28502acc5fb704aa30a9ed2fd1a7ffd8
|
Return the exception messages when the Alist format is not respected.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/AList/AList.cpp",
"new_path": "src/Tools/Code/LDPC/AList/AList.cpp",
"diff": "@@ -20,26 +20,42 @@ Sparse_matrix AList\n{\nreturn AList::read_format1(stream);\n}\n- catch (std::exception const&)\n+ catch (std::exception const& e1)\n{\n+ auto save = exception::no_backtrace;\n+ exception::no_backtrace = true;\n+\n+ std::stringstream message;\n+ message << \"The given stream does not refer to a AList format file: \";\n+ message << std::endl << e1.what();\n+ exception::no_backtrace = save;\n+\ntry\n{\nstream.clear();\nstream.seekg(init_pos);\nreturn AList::read_format2(stream);\n}\n- catch (std::exception const&)\n+ catch (std::exception const& e2)\n{\n+ auto save = exception::no_backtrace;\n+ exception::no_backtrace = true;\n+ message << std::endl << e2.what();\n+ exception::no_backtrace = save;\n+\ntry\n{\nstream.clear();\nstream.seekg(init_pos);\nreturn AList::read_format3(stream);\n}\n- catch (std::exception const&)\n+ catch (std::exception const& e3)\n{\n- std::stringstream message;\n- message << \"The given stream does not refer to a AList format file.\";\n+ auto save = exception::no_backtrace;\n+ exception::no_backtrace = true;\n+ message << std::endl << e3.what();\n+ exception::no_backtrace = save;\n+\nthrow runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Return the exception messages when the Alist format is not respected.
|
8,483 |
03.05.2018 17:20:27
| -7,200 |
94907cadf2adf43ca640263ff7dfe495cd5fb4ae
|
Change modem optical debug path
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/Optical/Modem_optical.cpp",
"new_path": "src/Module/Modem/Optical/Modem_optical.cpp",
"diff": "using namespace aff3ct;\nusing namespace aff3ct::module;\n-\n+//\n//std::vector<std::vector<float>> llrs;\n//size_t llr_idx;\n@@ -26,7 +26,7 @@ Modem_optical<B,R,Q>\nconst std::string name = \"Modem_optical\";\nthis->set_name(name);\n-// std::ifstream file(\"/media/ohartmann/DATA/Documents/Projets/CNES_AIRBUS/vectorTestIMS/TestVec ROP -31_3970/AFF3CT/LLR.txt\");\n+// std::ifstream file(\"/media/ohartmann/DATA/Documents/Projets/CNES_AIRBUS/matrices/2018_05_03/vectorTestIMS/TestVec ROP -32/AFF3CT/LLR.txt\");\n//\n// if (!file.is_open())\n// throw tools::runtime_error();\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Change modem optical debug path
|
8,483 |
03.05.2018 17:49:20
| -7,200 |
4b17a0a600000270c1e58627ed33b77f1627d79b
|
Fix sparse matrix
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Sparse_matrix/Sparse_matrix.cpp",
"new_path": "src/Tools/Algo/Sparse_matrix/Sparse_matrix.cpp",
"diff": "@@ -180,7 +180,7 @@ void Sparse_matrix::rm_connection(const size_t row_index, const size_t col_index\n}\n// delete the link in the col_to_rows vector\n- auto itc = std::find(this->col_to_rows[col_index].begin(), this->col_to_rows[col_index].end(), col_index);\n+ auto itc = std::find(this->col_to_rows[col_index].begin(), this->col_to_rows[col_index].end(), row_index);\nif (itc != this->col_to_rows[col_index].end());\n{\nthis->col_to_rows[col_index].erase(itc);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix sparse matrix
|
8,483 |
03.05.2018 17:49:31
| -7,200 |
c76bec218767350c246221fc974fa6d967e44d62
|
Add a peeling decoder
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.cpp",
"new_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.cpp",
"diff": "#include \"Module/Decoder/LDPC/BP/Layered/ONMS/Decoder_LDPC_BP_layered_offset_normalize_min_sum.hpp\"\n#include \"Module/Decoder/LDPC/BP/Layered/ONMS/Decoder_LDPC_BP_layered_ONMS_inter.hpp\"\n#include \"Module/Decoder/LDPC/BP/Layered/AMS/Decoder_LDPC_BP_layered_approximate_min_star.hpp\"\n+#include \"Module/Decoder/LDPC/BP/Peeling/Decoder_LDPC_BP_peeling.hpp\"\n#include \"Decoder_LDPC.hpp\"\n@@ -52,7 +53,7 @@ void Decoder_LDPC::parameters\n\"path to the H matrix (AList or QC formated file).\",\ntools::arg_rank::REQ);\n- tools::add_options(args.at({p+\"-type\", \"D\"}), 0, \"BP\", \"BP_FLOODING\", \"BP_LAYERED\");\n+ tools::add_options(args.at({p+\"-type\", \"D\"}), 0, \"BP\", \"BP_FLOODING\", \"BP_LAYERED\", \"BP_PEELING\");\ntools::add_options(args.at({p+\"-implem\" }), 0, \"ONMS\", \"SPA\", \"LSPA\", \"GALA\", \"AMS\");\nargs.add(\n@@ -190,6 +191,10 @@ module::Decoder_SISO_SIHO<B,Q>* Decoder_LDPC::parameters\n{\nif (this->implem == \"ONMS\") return new module::Decoder_LDPC_BP_layered_ONMS_inter<B,Q>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, this->norm_factor, (Q)this->offset, this->enable_syndrome, this->syndrome_depth, this->n_frames);\n}\n+ else if (this->type == \"BP_PEELING\")\n+ {\n+ if (this->implem == \"STD\") return new module::Decoder_LDPC_BP_peeling<B,Q>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, this->enable_syndrome, this->syndrome_depth, false, this->n_frames);\n+ }\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Decoder/LDPC/BP/Peeling/Decoder_LDPC_BP_peeling.cpp",
"diff": "+#include \"Decoder_LDPC_BP_peeling.hpp\"\n+\n+#include \"Tools/Perf/common/hard_decide.h\"\n+#include \"Tools/Noise/Erased_value.hpp\"\n+#include \"Tools/Math/utils.h\"\n+\n+using namespace aff3ct;\n+using namespace aff3ct::module;\n+\n+template<typename B, typename R>\n+Decoder_LDPC_BP_peeling<B, R>::Decoder_LDPC_BP_peeling(const int K, const int N, const int n_ite,\n+ const tools::Sparse_matrix &H,\n+ const std::vector<unsigned> &info_bits_pos,\n+ const bool enable_syndrome, const int syndrome_depth,\n+ const bool multiframe_interleaving, const int n_frames)\n+: Decoder (K, N, n_frames, 1),\n+ Decoder_LDPC_BP<B,R> (K, N, n_ite, H, enable_syndrome, syndrome_depth, n_frames, 1),\n+ multiframe_interleaving(multiframe_interleaving ),\n+ info_bits_pos (info_bits_pos ),\n+ var_nodes (n_frames, std::vector<B>(N ) ),\n+ check_nodes (n_frames, std::vector<B>(H.get_n_cols()) )\n+{\n+ const std::string name = \"Decoder_LDPC_BP_peeling\";\n+ this->set_name(name);\n+}\n+\n+template <typename B, typename R>\n+void Decoder_LDPC_BP_peeling<B,R>\n+::_load(const R *Y_N, const int frame_id)\n+{\n+ tools::hard_decide(Y_N, var_nodes[frame_id].data(), this->N);\n+ for (auto i = 0; i < this->N; i++)\n+ if (Y_N[i] <= tools::Erased_value<R>::llr && Y_N[i] >= -tools::Erased_value<R>::llr)\n+ var_nodes[frame_id][i] = tools::Erased_value<B>::symbol;\n+}\n+\n+template <typename B, typename R>\n+void Decoder_LDPC_BP_peeling<B,R>\n+::_decode(const int frame_id)\n+{\n+ auto links = this->H;\n+\n+ std::fill(this->check_nodes[frame_id].begin(), this->check_nodes[frame_id].end(), (B)0);\n+\n+ // first propagate known values\n+ for (unsigned i = 0; i < links.get_n_rows(); i++)\n+ {\n+ auto cur_state = this->var_nodes[frame_id][i];\n+ if (cur_state != tools::Erased_value<B>::symbol)\n+ {\n+ auto& cn_list = links.get_row_to_cols()[i];\n+ while (cn_list.size())\n+ {\n+ this->check_nodes[frame_id][cn_list.front()] ^= cur_state;\n+ links.rm_connection(i, 0);\n+ }\n+ }\n+ }\n+\n+ for (auto ite = 0; ite < this->n_ite; ite++)\n+ {\n+ // find degree-1 check nodes\n+ for (unsigned i = 0; i < links.get_n_cols(); i++)\n+ {\n+ if (links.get_col_to_rows()[i].size() == 1)\n+ { // then propagate the belief\n+ auto& vn_pos = links.get_col_to_rows()[i].front();\n+ this->var_nodes [frame_id][vn_pos] = this->check_nodes[frame_id][i];\n+ this->check_nodes[frame_id][ i] = 0;\n+ links.rm_connection(vn_pos, i);\n+ }\n+ }\n+ }\n+};\n+\n+template <typename B, typename R>\n+void Decoder_LDPC_BP_peeling<B,R>\n+::_decode_hiho(const B *Y_N, B *V_K, const int frame_id)\n+{\n+// auto t_load = std::chrono::steady_clock::now(); // ---------------------------------------------------------- LOAD\n+ std::copy(Y_N, Y_N + this->N, var_nodes[frame_id].data());\n+// auto d_load = std::chrono::steady_clock::now() - t_load;\n+\n+// auto t_decod = std::chrono::steady_clock::now(); // -------------------------------------------------------- DECODE\n+ this->_decode(frame_id);\n+// auto d_decod = std::chrono::steady_clock::now() - t_decod;\n+\n+// auto t_store = std::chrono::steady_clock::now(); // --------------------------------------------------------- STORE\n+ _store(V_K, frame_id);\n+// auto d_store = std::chrono::steady_clock::now() - t_store;\n+\n+// (*this)[dec::tsk::decode_hiho].update_timer(dec::tm::decode_hiho::decode, d_decod);\n+// (*this)[dec::tsk::decode_hiho].update_timer(dec::tm::decode_hiho::store, d_store);\n+}\n+\n+template <typename B, typename R>\n+void Decoder_LDPC_BP_peeling<B,R>\n+::_decode_hiho_cw(const B *Y_N, B *V_N, const int frame_id)\n+{\n+// auto t_load = std::chrono::steady_clock::now(); // ---------------------------------------------------------- LOAD\n+ std::copy(Y_N, Y_N + this->N, var_nodes[frame_id].data());\n+// auto d_load = std::chrono::steady_clock::now() - t_load;\n+\n+// auto t_decod = std::chrono::steady_clock::now(); // -------------------------------------------------------- DECODE\n+ this->_decode(frame_id);\n+// auto d_decod = std::chrono::steady_clock::now() - t_decod;\n+\n+// auto t_store = std::chrono::steady_clock::now(); // --------------------------------------------------------- STORE\n+ _store_cw(V_N, frame_id);\n+// auto d_store = std::chrono::steady_clock::now() - t_store;\n+\n+// (*this)[dec::tsk::decode_hiho_cw].update_timer(dec::tm::decode_hiho_cw::decode, d_decod);\n+// (*this)[dec::tsk::decode_hiho_cw].update_timer(dec::tm::decode_hiho_cw::store, d_store);\n+}\n+\n+template <typename B, typename R>\n+void Decoder_LDPC_BP_peeling<B,R>\n+::_decode_siho(const R *Y_N, B *V_K, const int frame_id)\n+{\n+// auto t_load = std::chrono::steady_clock::now(); // ---------------------------------------------------------- LOAD\n+ this->_load(Y_N, frame_id);\n+// auto d_load = std::chrono::steady_clock::now() - t_load;\n+\n+// auto t_decod = std::chrono::steady_clock::now(); // -------------------------------------------------------- DECODE\n+ this->_decode(frame_id);\n+// auto d_decod = std::chrono::steady_clock::now() - t_decod;\n+\n+// auto t_store = std::chrono::steady_clock::now(); // --------------------------------------------------------- STORE\n+ _store(V_K, frame_id);\n+// auto d_store = std::chrono::steady_clock::now() - t_store;\n+\n+// (*this)[dec::tsk::decode_siho].update_timer(dec::tm::decode_siho::load, d_load);\n+// (*this)[dec::tsk::decode_siho].update_timer(dec::tm::decode_siho::decode, d_decod);\n+// (*this)[dec::tsk::decode_siho].update_timer(dec::tm::decode_siho::store, d_store);\n+}\n+\n+template <typename B, typename R>\n+void Decoder_LDPC_BP_peeling<B,R>\n+::_decode_siho_cw(const R *Y_N, B *V_N, const int frame_id)\n+{\n+// auto t_load = std::chrono::steady_clock::now(); // ---------------------------------------------------------- LOAD\n+ this->_load(Y_N, frame_id);\n+// auto d_load = std::chrono::steady_clock::now() - t_load;\n+\n+// auto t_decod = std::chrono::steady_clock::now(); // -------------------------------------------------------- DECODE\n+ this->_decode(frame_id);\n+// auto d_decod = std::chrono::steady_clock::now() - t_decod;\n+\n+// auto t_store = std::chrono::steady_clock::now(); // --------------------------------------------------------- STORE\n+ _store_cw(V_N, frame_id);\n+// auto d_store = std::chrono::steady_clock::now() - t_store;\n+\n+// (*this)[dec::tsk::decode_siho_cw].update_timer(dec::tm::decode_siho_cw::load, d_load);\n+// (*this)[dec::tsk::decode_siho_cw].update_timer(dec::tm::decode_siho_cw::decode, d_decod);\n+// (*this)[dec::tsk::decode_siho_cw].update_timer(dec::tm::decode_siho_cw::store, d_store);\n+}\n+\n+template<typename B, typename R>\n+void Decoder_LDPC_BP_peeling<B, R>::_store(B *V_K, const int frame_id)\n+{\n+ for (auto i = 0; i < this->K; i++)\n+ V_K[i] = this->var_nodes[frame_id][this->info_bits_pos[i]];\n+}\n+\n+template<typename B, typename R>\n+void Decoder_LDPC_BP_peeling<B, R>::_store_cw(B *V_N, const int frame_id)\n+{\n+ std::copy(this->var_nodes[frame_id].begin(), this->var_nodes[frame_id].end(), V_N);\n+}\n+\n+// ==================================================================================== explicit template instantiation\n+#include \"Tools/types.h\"\n+#ifdef MULTI_PREC\n+template class aff3ct::module::Decoder_LDPC_BP_peeling<B_8,Q_8>;\n+template class aff3ct::module::Decoder_LDPC_BP_peeling<B_16,Q_16>;\n+template class aff3ct::module::Decoder_LDPC_BP_peeling<B_32,Q_32>;\n+template class aff3ct::module::Decoder_LDPC_BP_peeling<B_64,Q_64>;\n+#else\n+template class aff3ct::module::Decoder_LDPC_BP_peeling<B,Q>;\n+#endif\n+// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Decoder/LDPC/BP/Peeling/Decoder_LDPC_BP_peeling.hpp",
"diff": "+#ifndef DECODER_LDPC_BP_PEELING_HPP\n+#define DECODER_LDPC_BP_PEELING_HPP\n+\n+#include \"../Decoder_LDPC_BP.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+\n+template<typename B = int, typename R = float>\n+class Decoder_LDPC_BP_peeling : public Decoder_LDPC_BP<B,R>\n+{\n+protected:\n+ const bool multiframe_interleaving;\n+\n+ const std::vector<unsigned> &info_bits_pos;\n+\n+ // data structures for iterative decoding\n+ std::vector<std::vector<B>> var_nodes;\n+ std::vector<std::vector<B>> check_nodes;\n+\n+public:\n+ Decoder_LDPC_BP_peeling(const int K, const int N, const int n_ite,\n+ const tools::Sparse_matrix &H,\n+ const std::vector<unsigned> &info_bits_pos,\n+ const bool enable_syndrome = true,\n+ const int syndrome_depth = 1,\n+ const bool multiframe_interleaving = false,\n+ const int n_frames = 1);\n+ virtual ~Decoder_LDPC_BP_peeling() = default;\n+\n+protected:\n+ void _load (const R *Y_N, const int frame_id);\n+\n+ void _store (B *V_K, const int frame_id);\n+ void _store_cw (B *V_N, const int frame_id);\n+\n+ void _decode_hiho (const B *Y_N, B *V_K, const int frame_id);\n+ void _decode_hiho_cw(const B *Y_N, B *V_N, const int frame_id);\n+ void _decode_siho (const R *Y_N, B *V_K, const int frame_id);\n+ void _decode_siho_cw(const R *Y_N, B *V_N, const int frame_id);\n+ virtual void _decode( const int frame_id);\n+\n+};\n+\n+}\n+}\n+\n+#endif //DECODER_LDPC_BP_PEELING_HPP\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a peeling decoder
|
8,483 |
03.05.2018 17:58:54
| -7,200 |
1516d912fd565f4f12d2071ae4ebc2ac9dc20773
|
Add debug to the peeling
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.cpp",
"new_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.cpp",
"diff": "@@ -203,10 +203,6 @@ module::Decoder_SISO_SIHO<B,Q>* Decoder_LDPC::parameters\n{\nif (this->implem == \"ONMS\") return new module::Decoder_LDPC_BP_layered_ONMS_inter<B,Q>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, this->norm_factor, (Q)this->offset, this->enable_syndrome, this->syndrome_depth, this->n_frames);\n}\n- else if (this->type == \"BP_PEELING\")\n- {\n- if (this->implem == \"STD\") return new module::Decoder_LDPC_BP_peeling<B,Q>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, this->enable_syndrome, this->syndrome_depth, false, this->n_frames);\n- }\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n@@ -226,6 +222,10 @@ module::Decoder_SIHO<B,Q>* Decoder_LDPC::parameters\n{\nif (this->implem == \"GALA\") return new module::Decoder_LDPC_BP_flooding_GALA<B,Q>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, this->enable_syndrome, this->syndrome_depth, this->n_frames);\n}\n+ else if (this->type == \"BP_PEELING\")\n+ {\n+ if (this->implem == \"STD\") return new module::Decoder_LDPC_BP_peeling<B,Q>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, this->enable_syndrome, this->syndrome_depth, false, this->n_frames);\n+ }\nreturn build_siso<B,Q>(H, info_bits_pos);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Peeling/Decoder_LDPC_BP_peeling.cpp",
"new_path": "src/Module/Decoder/LDPC/BP/Peeling/Decoder_LDPC_BP_peeling.cpp",
"diff": "@@ -42,6 +42,15 @@ void Decoder_LDPC_BP_peeling<B,R>\nstd::fill(this->check_nodes[frame_id].begin(), this->check_nodes[frame_id].end(), (B)0);\n+ std::cout << \"(L) var_nodes : \" << std::endl;\n+ for (unsigned i = 0; i < this->var_nodes[frame_id].size(); i++)\n+ std::cout << this->var_nodes[frame_id][i] << \" \";\n+ std::cout << std::endl;\n+ std::cout << \"(L) check_nodes : \" << std::endl;\n+ for (unsigned i = 0; i < this->check_nodes[frame_id].size(); i++)\n+ std::cout << this->check_nodes[frame_id][i] << \" \";\n+ std::cout << std::endl;\n+\n// first propagate known values\nfor (unsigned i = 0; i < links.get_n_rows(); i++)\n{\n@@ -57,6 +66,15 @@ void Decoder_LDPC_BP_peeling<B,R>\n}\n}\n+ std::cout << \"(I) var_nodes : \" << std::endl;\n+ for (unsigned i = 0; i < this->var_nodes[frame_id].size(); i++)\n+ std::cout << this->var_nodes[frame_id][i] << \" \";\n+ std::cout << std::endl;\n+ std::cout << \"(I) check_nodes : \" << std::endl;\n+ for (unsigned i = 0; i < this->check_nodes[frame_id].size(); i++)\n+ std::cout << this->check_nodes[frame_id][i] << \" \";\n+ std::cout << std::endl;\n+\nfor (auto ite = 0; ite < this->n_ite; ite++)\n{\n// find degree-1 check nodes\n@@ -70,6 +88,15 @@ void Decoder_LDPC_BP_peeling<B,R>\nlinks.rm_connection(vn_pos, i);\n}\n}\n+\n+ std::cout << \"(\" << ite << \") var_nodes : \" << std::endl;\n+ for (unsigned i = 0; i < this->var_nodes[frame_id].size(); i++)\n+ std::cout << this->var_nodes[frame_id][i] << \" \";\n+ std::cout << std::endl;\n+ std::cout << \"(\" << ite << \") check_nodes : \" << std::endl;\n+ for (unsigned i = 0; i < this->check_nodes[frame_id].size(); i++)\n+ std::cout << this->check_nodes[frame_id][i] << \" \";\n+ std::cout << std::endl;\n}\n};\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add debug to the peeling
|
8,483 |
04.05.2018 08:18:55
| -7,200 |
adcc77913a38894e430421864cda4884fafd51aa
|
Update .gitlab-ci.yml to a max-snr-time to 15 minutes for tests
|
[
{
"change_type": "MODIFY",
"old_path": ".gitlab-ci.yml",
"new_path": ".gitlab-ci.yml",
"diff": "@@ -113,4 +113,4 @@ test-regression:\n- test-regression-results/\nscript:\n- ./ci/test-build-linux-gcc.sh\n- - ./ci/test-regression.py --max-snr-time 5 --sensibility 2.5 --weak-rate 0.9 --verbose 1\n\\ No newline at end of file\n+ - ./ci/test-regression.py --max-snr-time 15 --sensibility 2.5 --weak-rate 0.9 --verbose 1\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Update .gitlab-ci.yml to a max-snr-time to 15 minutes for tests
|
8,483 |
04.05.2018 10:27:22
| -7,200 |
a52531cd1cb7bc8c662585aeb904d0483908ab3f
|
Fix the seed initialization in BEC channel and in Gaussian_noise_generator_fast::set_seed()
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/BEC/Channel_BEC.cpp",
"new_path": "src/Module/Channel/BEC/Channel_BEC.cpp",
"diff": "@@ -8,7 +8,7 @@ using namespace aff3ct::module;\ntemplate <typename R>\nChannel_BEC<R>\n::Channel_BEC(const int N, const int seed, const tools::Event_probability<R>& noise, const int n_frames)\n-: Channel<R>(N, noise, n_frames), uni_dist((R)0, (R)1)\n+: Channel<R>(N, noise, n_frames), mt19937(seed), uni_dist((R)0, (R)1)\n{\nconst std::string name = \"Channel_BEC\";\nthis->set_name(name);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Noise_generator/Gaussian_noise_generator/Fast/Gaussian_noise_generator_fast.cpp",
"new_path": "src/Tools/Algo/Noise_generator/Gaussian_noise_generator/Fast/Gaussian_noise_generator_fast.cpp",
"diff": "@@ -11,7 +11,7 @@ template <typename R>\nGaussian_noise_generator_fast<R>\n::Gaussian_noise_generator_fast(const int seed)\n: Gaussian_noise_generator<R>(),\n- mt19937(seed),\n+ mt19937(),\nmt19937_simd()\n{\nthis->set_seed(seed);\n@@ -27,6 +27,8 @@ template <typename R>\nvoid Gaussian_noise_generator_fast<R>\n::set_seed(const int seed)\n{\n+ mt19937.seed(seed);\n+\nmipp::vector<int> seeds(mipp::nElReg<int>());\nfor (auto i = 0; i < mipp::nElReg<int>(); i++)\nseeds[i] = mt19937.rand();\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix the seed initialization in BEC channel and in Gaussian_noise_generator_fast::set_seed()
|
8,483 |
04.05.2018 10:29:26
| -7,200 |
85323e86fc9065b83be9a1ff8c18ec77bb744280
|
Add a printer of the sparsed matrix
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Sparse_matrix/Sparse_matrix.cpp",
"new_path": "src/Tools/Algo/Sparse_matrix/Sparse_matrix.cpp",
"diff": "@@ -158,10 +158,12 @@ void Sparse_matrix::rm_connection(const size_t row_index, const size_t col_index\n}\n// delete the link in the row_to_cols vector\n+ bool row_found = false;\nauto itr = std::find(this->row_to_cols[row_index].begin(), this->row_to_cols[row_index].end(), col_index);\nif (itr != this->row_to_cols[row_index].end());\n{\n- this->row_to_cols[row_index].erase(itr);\n+ row_found = true;\n+ itr = this->row_to_cols[row_index].erase(itr);\n// check if need to reduce the rows max degree\nif (this->row_to_cols[row_index].size() == (this->rows_max_degree-1))\n@@ -180,9 +182,11 @@ void Sparse_matrix::rm_connection(const size_t row_index, const size_t col_index\n}\n// delete the link in the col_to_rows vector\n+ bool col_found = false;\nauto itc = std::find(this->col_to_rows[col_index].begin(), this->col_to_rows[col_index].end(), row_index);\nif (itc != this->col_to_rows[col_index].end());\n{\n+ col_found = true;\nthis->col_to_rows[col_index].erase(itc);\n// check if need to reduce the cols max degree\n@@ -201,15 +205,18 @@ void Sparse_matrix::rm_connection(const size_t row_index, const size_t col_index\n}\n}\n- if ((itr == this->row_to_cols[row_index].end()) != (itc == this->col_to_rows[col_index].end()))\n+ if (row_found != col_found)\n{\nstd::stringstream message;\nmessage << \"The connection has been found only in one of the two vectors 'row_to_cols' and 'col_to_rows' \"\n- << \"('row_index' = \" << row_index << \"'col_index' = \" << col_index << \").\";\n+ << \"('row_index' = \" << row_index << \", 'col_index' = \" << col_index\n+ << \", found in row = \" << std::boolalpha << row_found\n+ << \", found in col = \" << col_found << std::noboolalpha << \").\";\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n-\n+ else if (row_found && col_found)\nthis->n_connections--;\n+ // else the connection has not been found\n}\nSparse_matrix Sparse_matrix\n@@ -263,3 +270,48 @@ void Sparse_matrix\nfor (size_t j = 0; j < this->col_to_rows[i].size(); j++)\nthis->row_to_cols[this->col_to_rows[i][j]].push_back(i);\n}\n+\n+void Sparse_matrix\n+::print(bool transpose, std::ostream& os)\n+{\n+ if (transpose)\n+ {\n+ std::vector<unsigned> rows(this->n_rows, 0);\n+\n+ for (auto& col : this->col_to_rows)\n+ {\n+ // set the ones\n+ for (auto& row : col)\n+ rows[row] = 1;\n+\n+ for (auto& row : rows)\n+ os << row << \" \";\n+\n+ os << std::endl;\n+\n+ // reset the ones\n+ for (auto& row : col)\n+ rows[row] = 0;\n+ }\n+ }\n+ else\n+ {\n+ std::vector<unsigned> columns(this->n_cols, 0);\n+\n+ for (auto& row : this->row_to_cols)\n+ {\n+ // set the ones\n+ for (auto& col : row)\n+ columns[col] = 1;\n+\n+ for (auto& col : columns)\n+ os << col << \" \";\n+\n+ os << std::endl;\n+\n+ // reset the ones\n+ for (auto& col : row)\n+ columns[col] = 0;\n+ }\n+ }\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Sparse_matrix/Sparse_matrix.hpp",
"new_path": "src/Tools/Algo/Sparse_matrix/Sparse_matrix.hpp",
"diff": "#include <vector>\n#include <string>\n+#include <iostream>\nnamespace aff3ct\n{\n@@ -70,6 +71,12 @@ public:\n* The \"order\" parameter can be \"ASC\" for ascending or \"DSC\" for descending\n*/\nvoid sort_cols_per_density(std::string order = \"DSC\");\n+\n+ /*\n+ * Print the sparsed matrix in its full view with 0s and 1s.\n+ * 'transpose' allow the print in its transposed view\n+ */\n+ void print(bool transpose = false, std::ostream& os = std::cout);\n};\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a printer of the sparsed matrix
|
8,483 |
04.05.2018 11:21:00
| -7,200 |
0adbb1ed6c53d787fb867fb70f9eec8a237e8b0e
|
Fix the decoder Peeling
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.cpp",
"new_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.cpp",
"diff": "@@ -224,7 +224,7 @@ module::Decoder_SIHO<B,Q>* Decoder_LDPC::parameters\n}\nelse if (this->type == \"BP_PEELING\")\n{\n- if (this->implem == \"STD\") return new module::Decoder_LDPC_BP_peeling<B,Q>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, this->enable_syndrome, this->syndrome_depth, false, this->n_frames);\n+ if (this->implem == \"STD\") return new module::Decoder_LDPC_BP_peeling<B,Q>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, this->enable_syndrome, this->syndrome_depth, this->n_frames);\n}\nreturn build_siso<B,Q>(H, info_bits_pos);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Peeling/Decoder_LDPC_BP_peeling.cpp",
"new_path": "src/Module/Decoder/LDPC/BP/Peeling/Decoder_LDPC_BP_peeling.cpp",
"diff": "@@ -12,10 +12,9 @@ Decoder_LDPC_BP_peeling<B, R>::Decoder_LDPC_BP_peeling(const int K, const int N,\nconst tools::Sparse_matrix &H,\nconst std::vector<unsigned> &info_bits_pos,\nconst bool enable_syndrome, const int syndrome_depth,\n- const bool multiframe_interleaving, const int n_frames)\n+ const int n_frames)\n: Decoder (K, N, n_frames, 1),\nDecoder_LDPC_BP<B,R> (K, N, n_ite, H, enable_syndrome, syndrome_depth, n_frames, 1),\n- multiframe_interleaving(multiframe_interleaving ),\ninfo_bits_pos (info_bits_pos ),\nvar_nodes (n_frames, std::vector<B>(N ) ),\ncheck_nodes (n_frames, std::vector<B>(H.get_n_cols()) )\n@@ -42,14 +41,17 @@ void Decoder_LDPC_BP_peeling<B,R>\nstd::fill(this->check_nodes[frame_id].begin(), this->check_nodes[frame_id].end(), (B)0);\n- std::cout << \"(L) var_nodes : \" << std::endl;\n- for (unsigned i = 0; i < this->var_nodes[frame_id].size(); i++)\n- std::cout << this->var_nodes[frame_id][i] << \" \";\n- std::cout << std::endl;\n- std::cout << \"(L) check_nodes : \" << std::endl;\n- for (unsigned i = 0; i < this->check_nodes[frame_id].size(); i++)\n- std::cout << this->check_nodes[frame_id][i] << \" \";\n- std::cout << std::endl;\n+ // std::cout << \"(L) var_nodes : \" << std::endl;\n+ // for (unsigned i = 0; i < this->var_nodes[frame_id].size(); i++)\n+ // std::cout << this->var_nodes[frame_id][i] << \" \";\n+ // std::cout << std::endl;\n+ // std::cout << \"(L) check_nodes : \" << std::endl;\n+ // for (unsigned i = 0; i < this->check_nodes[frame_id].size(); i++)\n+ // std::cout << this->check_nodes[frame_id][i] << \" \";\n+ // std::cout << std::endl;\n+\n+ // std::cout << \"(L) links : \" << std::endl;\n+ // links.print(true);\n// first propagate known values\nfor (unsigned i = 0; i < links.get_n_rows(); i++)\n@@ -60,23 +62,30 @@ void Decoder_LDPC_BP_peeling<B,R>\nauto& cn_list = links.get_row_to_cols()[i];\nwhile (cn_list.size())\n{\n- this->check_nodes[frame_id][cn_list.front()] ^= cur_state;\n- links.rm_connection(i, 0);\n+ auto& cn_pos = cn_list.front();\n+\n+ this->check_nodes[frame_id][cn_pos] ^= cur_state;\n+ links.rm_connection(i, cn_pos);\n}\n}\n}\n- std::cout << \"(I) var_nodes : \" << std::endl;\n- for (unsigned i = 0; i < this->var_nodes[frame_id].size(); i++)\n- std::cout << this->var_nodes[frame_id][i] << \" \";\n- std::cout << std::endl;\n- std::cout << \"(I) check_nodes : \" << std::endl;\n- for (unsigned i = 0; i < this->check_nodes[frame_id].size(); i++)\n- std::cout << this->check_nodes[frame_id][i] << \" \";\n- std::cout << std::endl;\n+ // std::cout << \"(I) var_nodes : \" << std::endl;\n+ // for (unsigned i = 0; i < this->var_nodes[frame_id].size(); i++)\n+ // std::cout << this->var_nodes[frame_id][i] << \" \";\n+ // std::cout << std::endl;\n+ // std::cout << \"(I) check_nodes : \" << std::endl;\n+ // for (unsigned i = 0; i < this->check_nodes[frame_id].size(); i++)\n+ // std::cout << this->check_nodes[frame_id][i] << \" \";\n+ // std::cout << std::endl;\n+\n+ // std::cout << \"(I) links : \" << std::endl;\n+ // links.print(true);\nfor (auto ite = 0; ite < this->n_ite; ite++)\n{\n+ bool all_check_nodes_done = true;\n+\n// find degree-1 check nodes\nfor (unsigned i = 0; i < links.get_n_cols(); i++)\n{\n@@ -87,16 +96,21 @@ void Decoder_LDPC_BP_peeling<B,R>\nthis->check_nodes[frame_id][ i] = 0;\nlinks.rm_connection(vn_pos, i);\n}\n+ else\n+ all_check_nodes_done &= links.get_col_to_rows()[i].size() == 0;\n}\n- std::cout << \"(\" << ite << \") var_nodes : \" << std::endl;\n- for (unsigned i = 0; i < this->var_nodes[frame_id].size(); i++)\n- std::cout << this->var_nodes[frame_id][i] << \" \";\n- std::cout << std::endl;\n- std::cout << \"(\" << ite << \") check_nodes : \" << std::endl;\n- for (unsigned i = 0; i < this->check_nodes[frame_id].size(); i++)\n- std::cout << this->check_nodes[frame_id][i] << \" \";\n- std::cout << std::endl;\n+ // std::cout << \"(\" << ite << \") var_nodes : \" << std::endl;\n+ // for (unsigned i = 0; i < this->var_nodes[frame_id].size(); i++)\n+ // std::cout << this->var_nodes[frame_id][i] << \" \";\n+ // std::cout << std::endl;\n+ // std::cout << \"(\" << ite << \") check_nodes : \" << std::endl;\n+ // for (unsigned i = 0; i < this->check_nodes[frame_id].size(); i++)\n+ // std::cout << this->check_nodes[frame_id][i] << \" \";\n+ // std::cout << std::endl;\n+\n+ if (all_check_nodes_done)\n+ break;\n}\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Peeling/Decoder_LDPC_BP_peeling.hpp",
"new_path": "src/Module/Decoder/LDPC/BP/Peeling/Decoder_LDPC_BP_peeling.hpp",
"diff": "@@ -12,8 +12,6 @@ template<typename B = int, typename R = float>\nclass Decoder_LDPC_BP_peeling : public Decoder_LDPC_BP<B,R>\n{\nprotected:\n- const bool multiframe_interleaving;\n-\nconst std::vector<unsigned> &info_bits_pos;\n// data structures for iterative decoding\n@@ -26,7 +24,6 @@ public:\nconst std::vector<unsigned> &info_bits_pos,\nconst bool enable_syndrome = true,\nconst int syndrome_depth = 1,\n- const bool multiframe_interleaving = false,\nconst int n_frames = 1);\nvirtual ~Decoder_LDPC_BP_peeling() = default;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix the decoder Peeling
|
8,483 |
04.05.2018 11:36:12
| -7,200 |
2cd65c97ea4505acd7004a18a6a3c5a07bee536a
|
Add a no modification syndrome and handle the syndrome depth
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Peeling/Decoder_LDPC_BP_peeling.cpp",
"new_path": "src/Module/Decoder/LDPC/BP/Peeling/Decoder_LDPC_BP_peeling.cpp",
"diff": "@@ -84,7 +84,7 @@ void Decoder_LDPC_BP_peeling<B,R>\nfor (auto ite = 0; ite < this->n_ite; ite++)\n{\n- bool all_check_nodes_done = true;\n+ bool all_check_nodes_done = true, no_modification = true;\n// find degree-1 check nodes\nfor (unsigned i = 0; i < links.get_n_cols(); i++)\n@@ -95,6 +95,7 @@ void Decoder_LDPC_BP_peeling<B,R>\nthis->var_nodes [frame_id][vn_pos] = this->check_nodes[frame_id][i];\nthis->check_nodes[frame_id][ i] = 0;\nlinks.rm_connection(vn_pos, i);\n+ no_modification = false;\n}\nelse\nall_check_nodes_done &= links.get_col_to_rows()[i].size() == 0;\n@@ -109,9 +110,15 @@ void Decoder_LDPC_BP_peeling<B,R>\n// std::cout << this->check_nodes[frame_id][i] << \" \";\n// std::cout << std::endl;\n- if (all_check_nodes_done)\n+ if (this->enable_syndrome && (all_check_nodes_done || no_modification))\n+ {\n+ this->cur_syndrome_depth++;\n+ if (this->cur_syndrome_depth == this->syndrome_depth)\nbreak;\n}\n+ else\n+ this->cur_syndrome_depth = 0;\n+ }\n};\ntemplate <typename B, typename R>\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a no modification syndrome and handle the syndrome depth
|
8,483 |
04.05.2018 13:45:30
| -7,200 |
ea7b2e0a8312abe5d00f1f7f1b7eb6678b813ff8
|
Enhance Encoder_LDPC
Set Encoder::get_info_bits_pos as const.
Add a Sparse_matrix H in the Encoder_LDPC to factorize code when checking its dimensions and the codeword.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/AZCW/Encoder_AZCW.cpp",
"new_path": "src/Module/Encoder/AZCW/Encoder_AZCW.cpp",
"diff": "@@ -26,7 +26,7 @@ void Encoder_AZCW<B>\ntemplate <typename B>\nconst std::vector<uint32_t>& Encoder_AZCW<B>\n-::get_info_bits_pos()\n+::get_info_bits_pos() const\n{\nthrow tools::unimplemented_error(__FILE__, __LINE__, __func__);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/AZCW/Encoder_AZCW.hpp",
"new_path": "src/Module/Encoder/AZCW/Encoder_AZCW.hpp",
"diff": "@@ -16,7 +16,7 @@ public:\nEncoder_AZCW(const int K, const int N, const int n_frames = 1);\nvirtual ~Encoder_AZCW();\n- const std::vector<uint32_t>& get_info_bits_pos();\n+ const std::vector<uint32_t>& get_info_bits_pos() const;\nbool is_sys() const;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/Coset/Encoder_coset.cpp",
"new_path": "src/Module/Encoder/Coset/Encoder_coset.cpp",
"diff": "@@ -29,7 +29,7 @@ void Encoder_coset<B>\ntemplate <typename B>\nconst std::vector<uint32_t>& Encoder_coset<B>\n-::get_info_bits_pos()\n+::get_info_bits_pos() const\n{\nthrow tools::unimplemented_error(__FILE__, __LINE__, __func__);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/Coset/Encoder_coset.hpp",
"new_path": "src/Module/Encoder/Coset/Encoder_coset.hpp",
"diff": "@@ -24,7 +24,7 @@ public:\nEncoder_coset(const int K, const int N, const int seed = 0, const int n_frames = 1);\nvirtual ~Encoder_coset();\n- const std::vector<uint32_t>& get_info_bits_pos();\n+ const std::vector<uint32_t>& get_info_bits_pos() const;\nbool is_sys() const;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/Encoder.hpp",
"new_path": "src/Module/Encoder/Encoder.hpp",
"diff": "@@ -46,7 +46,7 @@ public:\nprotected:\nconst int K; /*!< Number of information bits in one frame */\nconst int N; /*!< Size of one frame (= number of bits in one frame) */\n- bool sys; /*!< Is the generated codeworde are systematics ? */\n+ bool sys; /*!< Is the generated codeword systematic ? */\nbool memorizing; /*!< If true, keep the last encoded frame(s) in memory */\nstd::vector<uint32_t> info_bits_pos; /*!< Positions of the information bits in the codeword */\n@@ -99,7 +99,7 @@ public:\nvirtual bool is_codeword(const B *X_N);\n- virtual const std::vector<uint32_t>& get_info_bits_pos();\n+ virtual const std::vector<uint32_t>& get_info_bits_pos() const;\n/*!\n* \\brief Gets the number of tail bits.\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/Encoder.hxx",
"new_path": "src/Module/Encoder/Encoder.hxx",
"diff": "@@ -230,7 +230,7 @@ is_codeword(const B *X_N)\ntemplate <typename B>\nconst std::vector<uint32_t>& Encoder<B>::\n-get_info_bits_pos()\n+get_info_bits_pos() const\n{\nreturn info_bits_pos;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/DVBS2/Encoder_LDPC_DVBS2.cpp",
"new_path": "src/Module/Encoder/LDPC/DVBS2/Encoder_LDPC_DVBS2.cpp",
"diff": "@@ -17,12 +17,6 @@ Encoder_LDPC_DVBS2<B>\nthis->set_name(name);\n}\n-template <typename B>\n-Encoder_LDPC_DVBS2<B>\n-::~Encoder_LDPC_DVBS2()\n-{\n-}\n-\ntemplate <typename B>\nvoid Encoder_LDPC_DVBS2<B>\n::_encode(const B *U_K, B *X_N, const int frame_id)\n@@ -61,7 +55,7 @@ void Encoder_LDPC_DVBS2<B>\ntemplate <typename B>\nconst std::vector<uint32_t>& Encoder_LDPC_DVBS2<B>\n-::get_info_bits_pos()\n+::get_info_bits_pos() const\n{\nreturn Encoder<B>::get_info_bits_pos();\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/DVBS2/Encoder_LDPC_DVBS2.hpp",
"new_path": "src/Module/Encoder/LDPC/DVBS2/Encoder_LDPC_DVBS2.hpp",
"diff": "@@ -19,9 +19,9 @@ class Encoder_LDPC_DVBS2 : public Encoder_LDPC<B>\npublic:\nEncoder_LDPC_DVBS2(const tools::dvbs2_values& dvbs2, const int n_frames = 1);\n- virtual ~Encoder_LDPC_DVBS2();\n+ virtual ~Encoder_LDPC_DVBS2() = default;\n- const std::vector<uint32_t>& get_info_bits_pos();\n+ const std::vector<uint32_t>& get_info_bits_pos() const;\nbool is_sys() const;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/Encoder_LDPC.cpp",
"new_path": "src/Module/Encoder/LDPC/Encoder_LDPC.cpp",
"diff": "@@ -22,57 +22,107 @@ Encoder_LDPC<B>\ntemplate <typename B>\nEncoder_LDPC<B>\n::Encoder_LDPC(const int K, const int N, const tools::Sparse_matrix &G, const int n_frames)\n-: Encoder<B>(K, N, n_frames), tG(N * K, 0)\n+: Encoder<B>(K, N, n_frames), G(G)\n{\nconst std::string name = \"Encoder_LDPC\";\nthis->set_name(name);\n- if (K != (int)G.get_n_cols())\n+ check_G_dimensions();\n+}\n+\n+template <typename B>\n+Encoder_LDPC<B>\n+::Encoder_LDPC(const int K, const int N, const tools::Sparse_matrix &G, const tools::Sparse_matrix &H, const int n_frames)\n+: Encoder<B>(K, N, n_frames), G(G), H(H)\n{\n- std::stringstream message;\n- message << \"The built G matrix has a dimension 'K' different than the given one ('K' = \" << K\n- << \", 'G.get_n_cols()' = \" << G.get_n_cols() << \").\";\n- throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ const std::string name = \"Encoder_LDPC\";\n+ this->set_name(name);\n+\n+ check_G_dimensions();\n+ check_H_dimensions();\n}\n- if (N != (int)G.get_n_rows())\n+template <typename B>\n+void Encoder_LDPC<B>\n+::check_G_dimensions()\n{\n- std::stringstream message;\n- message << \"The built G matrix has a dimension 'N' different than the given one ('N' = \" << N\n- << \", 'G.get_n_rows()' = \" << G.get_n_rows() << \").\";\n- throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ try\n+ {\n+ this->_check_G_dimensions();\n+ }\n+ catch(tools::invalid_argument&)\n+ {\n+ this->G.self_transpose();\n+ this->_check_G_dimensions();\n+ }\n}\n- auto CN_to_VN = G.get_col_to_rows();\n+template <typename B>\n+void Encoder_LDPC<B>\n+::check_H_dimensions()\n+{\n+ try\n+ {\n+ this->_check_H_dimensions();\n+ }\n+ catch(tools::invalid_argument&)\n+ {\n+ this->H.self_transpose();\n+ this->_check_H_dimensions();\n+ }\n+}\n- std::vector<B> full_G(K * N,0);\n- for (auto i = 0; i < K; i++)\n- for (size_t j = 0; j < CN_to_VN[i].size(); ++j)\n- full_G[i * N + CN_to_VN[i][j]] = 1;\n+template <typename B>\n+void Encoder_LDPC<B>\n+::_check_G_dimensions()\n+{\n+ if (this->K != (int)this->G.get_n_cols())\n+ {\n+ std::stringstream message;\n+ message << \"The built G matrix has a dimension 'K' different than the given one ('K' = \" << this->K\n+ << \", 'G.get_n_cols()' = \" << this->G.get_n_cols() << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n- tools::real_transpose(K, N, full_G, tG); // transposed for computation matter\n+ if (this->N != (int)this->G.get_n_rows())\n+ {\n+ std::stringstream message;\n+ message << \"The built G matrix has a dimension 'N' different than the given one ('N' = \" << this->N\n+ << \", 'G.get_n_rows()' = \" << this->G.get_n_rows() << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n}\ntemplate <typename B>\n-Encoder_LDPC<B>\n-::~Encoder_LDPC()\n+void Encoder_LDPC<B>\n+::_check_H_dimensions()\n+{\n+ if (this->N != (int)this->H.get_n_rows())\n{\n+ std::stringstream message;\n+ message << \"The built H matrix has a dimension 'N' different than the given one ('N' = \" << this->N\n+ << \", 'H.get_n_rows()' = \" << this->H.get_n_rows() << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n}\ntemplate <typename B>\nvoid Encoder_LDPC<B>\n::_encode(const B *U_K, B *X_N, const int frame_id)\n{\n- // Real General Matrix Multiplication\n- tools::rgemm(1, this->N, this->K, U_K, tG.data(), X_N);\n-\n- for (auto j = 0; j < this->N; ++j)\n- X_N[j] %= 2;\n+ for (unsigned i = 0; i < this->N; i++)\n+ {\n+ X_N[i] = 0;\n+ auto& links = this->G.get_cols_from_row(i);\n+ for (unsigned j = 0; j < links.size(); j++)\n+ X_N[i] += U_K[ links[j] ];\n+ X_N[i] &= (B)1; // modulo 2\n+ }\n}\ntemplate <typename B>\nconst std::vector<uint32_t>& Encoder_LDPC<B>\n-::get_info_bits_pos()\n+::get_info_bits_pos() const\n{\nthrow tools::unimplemented_error(__FILE__, __LINE__, __func__);\n}\n@@ -84,6 +134,37 @@ bool Encoder_LDPC<B>\nthrow tools::unimplemented_error(__FILE__, __LINE__, __func__);\n}\n+template <typename B>\n+bool Encoder_LDPC<B>\n+::is_codeword(const B *X_N)\n+{\n+ if (this->H.get_n_connections() == 0)\n+ throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n+\n+ auto syndrome = false;\n+\n+ const auto n_CN = (int)this->H.get_n_cols();\n+ auto i = 0;\n+ while (i < n_CN && !syndrome)\n+ {\n+ auto sign = 0;\n+\n+ const auto n_VN = (int)this->H[i].size();\n+ for (auto j = 0; j < n_VN; j++)\n+ {\n+ const auto bit = X_N[this->H[i][j]];\n+ const auto tmp_sign = bit ? -1 : 0;\n+\n+ sign ^= tmp_sign;\n+ }\n+\n+ syndrome = syndrome || sign;\n+ i++;\n+ }\n+\n+ return !syndrome;\n+}\n+\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/Encoder_LDPC.hpp",
"new_path": "src/Module/Encoder/LDPC/Encoder_LDPC.hpp",
"diff": "@@ -16,20 +16,32 @@ template <typename B = int>\nclass Encoder_LDPC : public Encoder<B>\n{\nprotected:\n- std::vector<B> tG; // the generator matrix\n+ tools::Sparse_matrix G; // the generator matrix (automatically transposed if needed in constructor)\n+ // G cols are the K dimension\n+ // G rows are the N dimension\n+ tools::Sparse_matrix H; // the decodeur matrix (automatically transposed if needed in constructor)\n+ // H cols are the M dimension (often M = N - K)\n+ // H rows are the N dimension\nprotected:\nEncoder_LDPC(const int K, const int N, const int n_frames = 1);\npublic:\nEncoder_LDPC(const int K, const int N, const tools::Sparse_matrix &G, const int n_frames = 1);\n- virtual ~Encoder_LDPC();\n+ Encoder_LDPC(const int K, const int N, const tools::Sparse_matrix &G, const tools::Sparse_matrix &H, const int n_frames = 1);\n+ virtual ~Encoder_LDPC() = default;\n- virtual const std::vector<uint32_t>& get_info_bits_pos();\n+ virtual const std::vector<uint32_t>& get_info_bits_pos() const;\nvirtual bool is_sys() const;\n+ virtual bool is_codeword(const B *X_N);\nprotected:\nvirtual void _encode(const B *U_K, B *X_N, const int frame_id);\n+\n+ void check_G_dimensions();\n+ void check_H_dimensions();\n+ virtual void _check_G_dimensions();\n+ virtual void _check_H_dimensions();\n};\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/From_H/Encoder_LDPC_from_H.cpp",
"new_path": "src/Module/Encoder/LDPC/From_H/Encoder_LDPC_from_H.cpp",
"diff": "@@ -15,90 +15,32 @@ using namespace aff3ct::module;\ntemplate <typename B>\nEncoder_LDPC_from_H<B>\n::Encoder_LDPC_from_H(const int K, const int N, const tools::Sparse_matrix &H, const int n_frames)\n-: Encoder_LDPC<B>(K, N, n_frames), G(tools::LDPC_matrix_handler::transform_H_to_G(H, this->info_bits_pos)), H(H)\n+: Encoder_LDPC<B>(K, N, n_frames)\n{\nconst std::string name = \"Encoder_LDPC_from_H\";\nthis->set_name(name);\n- // warning G is transposed !\n- if (K != (int)G.get_n_cols())\n- {\n- std::stringstream message;\n- message << \"The built G matrix has a dimension 'K' different than the given one ('K' = \" << K\n- << \", 'G.get_n_cols()' = \" << G.get_n_cols() << \").\";\n- throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n- }\n+ this->G = tools::LDPC_matrix_handler::transform_H_to_G(H, this->info_bits_pos);\n+ this->H = H;\n- if (N != (int)G.get_n_rows())\n- {\n- std::stringstream message;\n- message << \"The built G matrix has a dimension 'N' different than the given one ('N' = \" << N\n- << \", 'G.get_n_rows()' = \" << G.get_n_rows() << \").\";\n- throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n- }\n-}\n-\n-template <typename B>\n-Encoder_LDPC_from_H<B>\n-::~Encoder_LDPC_from_H()\n-{\n-}\n-\n-template <typename B>\n-void Encoder_LDPC_from_H<B>\n-::_encode(const B *U_K, B *X_N, const int frame_id)\n-{\n- for (unsigned i = 0; i < G.get_n_rows(); i++)\n- {\n- X_N[i] = 0;\n- for (unsigned j = 0; j < G.get_cols_from_row(i).size(); j++)\n- X_N[i] += U_K[ G.get_cols_from_row(i)[j] ];\n- X_N[i] %= 2;\n- }\n+ this->check_G_dimensions();\n+ this->check_H_dimensions();\n}\ntemplate <typename B>\nbool Encoder_LDPC_from_H<B>\n-::is_codeword(const B *X_N)\n-{\n- auto syndrome = false;\n-\n- const auto n_CN = (int)this->H.get_n_cols();\n- auto i = 0;\n- while (i < n_CN && !syndrome)\n- {\n- auto sign = 0;\n-\n- const auto n_VN = (int)this->H[i].size();\n- for (auto j = 0; j < n_VN; j++)\n+::is_sys() const\n{\n- const auto bit = X_N[this->H[i][j]];\n- const auto tmp_sign = bit ? -1 : 0;\n-\n- sign ^= tmp_sign;\n- }\n-\n- syndrome = syndrome || sign;\n- i++;\n- }\n-\n- return !syndrome;\n+ return Encoder<B>::is_sys();\n}\ntemplate <typename B>\nconst std::vector<uint32_t>& Encoder_LDPC_from_H<B>\n-::get_info_bits_pos()\n+::get_info_bits_pos() const\n{\nreturn Encoder<B>::get_info_bits_pos();\n}\n-template <typename B>\n-bool Encoder_LDPC_from_H<B>\n-::is_sys() const\n-{\n- return Encoder<B>::is_sys();\n-}\n-\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/From_H/Encoder_LDPC_from_H.hpp",
"new_path": "src/Module/Encoder/LDPC/From_H/Encoder_LDPC_from_H.hpp",
"diff": "@@ -16,22 +16,13 @@ namespace module\ntemplate <typename B = int>\nclass Encoder_LDPC_from_H : public Encoder_LDPC<B>\n{\n-protected:\n- tools::Sparse_matrix G; // position of ones by column\n- tools::Sparse_matrix H;\n-\npublic:\nEncoder_LDPC_from_H(const int K, const int N, const tools::Sparse_matrix &H, const int n_frames = 1);\n- virtual ~Encoder_LDPC_from_H();\n-\n- bool is_codeword(const B *X_N);\n+ virtual ~Encoder_LDPC_from_H() = default;\n- const std::vector<uint32_t>& get_info_bits_pos();\n+ const std::vector<uint32_t>& get_info_bits_pos() const;\nbool is_sys() const;\n-\n-protected:\n- void _encode(const B *U_K, B *X_N, const int frame_id);\n};\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/From_QC/Encoder_LDPC_from_QC.cpp",
"new_path": "src/Module/Encoder/LDPC/From_QC/Encoder_LDPC_from_QC.cpp",
"diff": "@@ -15,34 +15,11 @@ using namespace aff3ct::module;\ntemplate <typename B>\nEncoder_LDPC_from_QC<B>\n::Encoder_LDPC_from_QC(const int K, const int N, const tools::Sparse_matrix &_H, const int n_frames)\n-: Encoder_LDPC<B>(K, N, n_frames),\n- H((_H.get_n_rows() > _H.get_n_cols())?_H.transpose():_H),\n+: Encoder_LDPC<B>(K, N, tools::Sparse_matrix(), _H, n_frames),\ninvH2(tools::LDPC_matrix_handler::invert_H2(_H))\n{\nconst std::string name = \"Encoder_LDPC_from_QC\";\nthis->set_name(name);\n-\n- if ((N-K) != (int)H.get_n_rows())\n- {\n- std::stringstream message;\n- message << \"The built H matrix has a dimension '(N-K)' different than the given one ('(N-K)' = \" << (N-K)\n- << \", 'H.get_n_rows()' = \" << H.get_n_rows() << \").\";\n- throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- if (N != (int)H.get_n_cols())\n- {\n- std::stringstream message;\n- message << \"The built H matrix has a dimension 'N' different than the given one ('N' = \" << N\n- << \", 'H.get_n_cols()' = \" << H.get_n_cols() << \").\";\n- throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n- }\n-}\n-\n-template <typename B>\n-Encoder_LDPC_from_QC<B>\n-::~Encoder_LDPC_from_QC()\n-{\n}\ntemplate <typename B>\n@@ -58,9 +35,10 @@ void Encoder_LDPC_from_QC<B>\nmipp::vector<int8_t> tableauCalcul(M, 0);\nfor (unsigned i = 0; i < M; i++)\n{\n- for (unsigned j = 0; j < H.get_cols_from_row(i).size(); j++)\n- if (H.get_cols_from_row(i)[j] < (unsigned)this->K)\n- tableauCalcul[i] ^= U_K[ H.get_cols_from_row(i)[j] ];\n+ auto& links = this->H.get_cols_from_row(i);\n+ for (unsigned j = 0; j < links.size(); j++)\n+ if (links[j] < (unsigned)this->K)\n+ tableauCalcul[i] ^= U_K[ links[j] ];\nelse\nbreak;\n}\n@@ -74,37 +52,9 @@ void Encoder_LDPC_from_QC<B>\n}\n}\n-template <typename B>\n-bool Encoder_LDPC_from_QC<B>\n-::is_codeword(const B *X_N)\n-{\n- auto syndrome = false;\n-\n- const auto n_CN = (int)this->H.get_n_cols();\n- auto i = 0;\n- while (i < n_CN && !syndrome)\n- {\n- auto sign = 0;\n-\n- const auto n_VN = (int)this->H[i].size();\n- for (auto j = 0; j < n_VN; j++)\n- {\n- const auto bit = X_N[this->H[i][j]];\n- const auto tmp_sign = bit ? -1 : 0;\n-\n- sign ^= tmp_sign;\n- }\n-\n- syndrome = syndrome || sign;\n- i++;\n- }\n-\n- return !syndrome;\n-}\n-\ntemplate <typename B>\nconst std::vector<uint32_t>& Encoder_LDPC_from_QC<B>\n-::get_info_bits_pos()\n+::get_info_bits_pos() const\n{\nreturn Encoder<B>::get_info_bits_pos();\n}\n@@ -116,6 +66,21 @@ bool Encoder_LDPC_from_QC<B>\nreturn Encoder<B>::is_sys();\n}\n+template <typename B>\n+void Encoder_LDPC_from_QC<B>\n+::_check_H_dimensions()\n+{\n+ Encoder_LDPC<B>::check_H_dimensions();\n+\n+ if ((this->N-this->K) != (int)this->H.get_n_rows())\n+ {\n+ std::stringstream message;\n+ message << \"The built H matrix has a dimension '(N-K)' different than the given one ('(N-K)' = \" << (this->N-this->K)\n+ << \", 'H.get_n_rows()' = \" << this->H.get_n_rows() << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+}\n+\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/From_QC/Encoder_LDPC_from_QC.hpp",
"new_path": "src/Module/Encoder/LDPC/From_QC/Encoder_LDPC_from_QC.hpp",
"diff": "@@ -17,21 +17,19 @@ template <typename B = int>\nclass Encoder_LDPC_from_QC : public Encoder_LDPC<B>\n{\nprotected:\n- tools::Sparse_matrix H;\ntools::LDPC_matrix_handler::QCFull_matrix invH2;\npublic:\nEncoder_LDPC_from_QC(const int K, const int N, const tools::Sparse_matrix &H, const int n_frames = 1);\n- virtual ~Encoder_LDPC_from_QC();\n+ virtual ~Encoder_LDPC_from_QC() = default;\n- bool is_codeword(const B *X_N);\n-\n- const std::vector<uint32_t>& get_info_bits_pos();\n+ const std::vector<uint32_t>& get_info_bits_pos() const;\nbool is_sys() const;\nprotected:\nvoid _encode(const B *U_K, B *X_N, const int frame_id);\n+ void _check_H_dimensions();\n};\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/User/Encoder_user.cpp",
"new_path": "src/Module/Encoder/User/Encoder_user.cpp",
"diff": "@@ -99,7 +99,7 @@ void Encoder_user<B>\ntemplate <typename B>\nconst std::vector<uint32_t>& Encoder_user<B>\n-::get_info_bits_pos()\n+::get_info_bits_pos() const\n{\nthrow tools::unimplemented_error(__FILE__, __LINE__, __func__);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/User/Encoder_user.hpp",
"new_path": "src/Module/Encoder/User/Encoder_user.hpp",
"diff": "@@ -20,7 +20,7 @@ public:\nEncoder_user(const int K, const int N, const std::string &filename, const int n_frames = 1);\nvirtual ~Encoder_user();\n- const std::vector<uint32_t>& get_info_bits_pos();\n+ const std::vector<uint32_t>& get_info_bits_pos() const;\nbool is_sys() const;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Enhance Encoder_LDPC
Set Encoder::get_info_bits_pos as const.
Add a Sparse_matrix H in the Encoder_LDPC to factorize code when checking its dimensions and the codeword.
|
8,483 |
04.05.2018 13:51:43
| -7,200 |
08be4b477b5c6a169cd58afc18c71e28890b7fa0
|
Update .gitlab-ci.yml, let 2 minutes to test
|
[
{
"change_type": "MODIFY",
"old_path": ".gitlab-ci.yml",
"new_path": ".gitlab-ci.yml",
"diff": "@@ -113,4 +113,4 @@ test-regression:\n- test-regression-results/\nscript:\n- ./ci/test-build-linux-gcc.sh\n- - ./ci/test-regression.py --max-snr-time 15 --sensibility 2.5 --weak-rate 0.9 --verbose 1\n\\ No newline at end of file\n+ - ./ci/test-regression.py --max-snr-time 120 --sensibility 2.5 --weak-rate 0.9 --verbose 1\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Update .gitlab-ci.yml, let 2 minutes to test
|
8,483 |
04.05.2018 14:36:47
| -7,200 |
f5f0e540863447ecd2acb7867c9c5a2d37bc1caa
|
Use Sparse_matrix::get_cols_from_row method to be more clear
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Peeling/Decoder_LDPC_BP_peeling.cpp",
"new_path": "src/Module/Decoder/LDPC/BP/Peeling/Decoder_LDPC_BP_peeling.cpp",
"diff": "@@ -9,15 +9,15 @@ using namespace aff3ct::module;\ntemplate<typename B, typename R>\nDecoder_LDPC_BP_peeling<B, R>::Decoder_LDPC_BP_peeling(const int K, const int N, const int n_ite,\n- const tools::Sparse_matrix &H,\n+ const tools::Sparse_matrix &_H,\nconst std::vector<unsigned> &info_bits_pos,\nconst bool enable_syndrome, const int syndrome_depth,\nconst int n_frames)\n: Decoder (K, N, n_frames, 1),\n- Decoder_LDPC_BP<B,R> (K, N, n_ite, H, enable_syndrome, syndrome_depth, n_frames, 1),\n+ Decoder_LDPC_BP<B,R> (K, N, n_ite, _H, enable_syndrome, syndrome_depth, n_frames, 1),\ninfo_bits_pos (info_bits_pos ),\nvar_nodes (n_frames, std::vector<B>(N ) ),\n- check_nodes (n_frames, std::vector<B>(H.get_n_cols()) )\n+ check_nodes (n_frames, std::vector<B>(this->H.get_n_cols()) )\n{\nconst std::string name = \"Decoder_LDPC_BP_peeling\";\nthis->set_name(name);\n@@ -59,7 +59,7 @@ void Decoder_LDPC_BP_peeling<B,R>\nauto cur_state = this->var_nodes[frame_id][i];\nif (cur_state != tools::Erased_value<B>::symbol)\n{\n- auto& cn_list = links.get_row_to_cols()[i];\n+ auto& cn_list = links.get_cols_from_row(i);\nwhile (cn_list.size())\n{\nauto& cn_pos = cn_list.front();\n@@ -91,14 +91,14 @@ void Decoder_LDPC_BP_peeling<B,R>\n{\nif (links.get_col_to_rows()[i].size() == 1)\n{ // then propagate the belief\n- auto& vn_pos = links.get_col_to_rows()[i].front();\n+ auto& vn_pos = links.get_rows_from_col(i).front();\nthis->var_nodes [frame_id][vn_pos] = this->check_nodes[frame_id][i];\nthis->check_nodes[frame_id][ i] = 0;\nlinks.rm_connection(vn_pos, i);\nno_modification = false;\n}\nelse\n- all_check_nodes_done &= links.get_col_to_rows()[i].size() == 0;\n+ all_check_nodes_done &= links.get_rows_from_col(i).size() == 0;\n}\n// std::cout << \"(\" << ite << \") var_nodes : \" << std::endl;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Use Sparse_matrix::get_cols_from_row method to be more clear
|
8,483 |
04.05.2018 14:39:43
| -7,200 |
94e68312fbaee45bbda53dee96e7ae15ffe93611
|
Set a standard for the H matrix direction: cols are CN and rows are VN. Automatically transpose if needed
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Decoder_LDPC_BP.cpp",
"new_path": "src/Module/Decoder/LDPC/BP/Decoder_LDPC_BP.cpp",
"diff": "@@ -16,7 +16,7 @@ Decoder_LDPC_BP<B,R>\n::Decoder_LDPC_BP(const int K,\nconst int N,\nconst int n_ite,\n- const tools::Sparse_matrix &H,\n+ const tools::Sparse_matrix &_H,\nconst bool enable_syndrome,\nconst int syndrome_depth,\nconst int n_frames,\n@@ -24,7 +24,7 @@ Decoder_LDPC_BP<B,R>\n: Decoder (K, N, n_frames, simd_inter_frame_level),\nDecoder_SISO_SIHO<B,R>(K, N, n_frames, simd_inter_frame_level),\nn_ite (n_ite ),\n- H (H ),\n+ H ((_H.get_n_cols() > _H.get_n_rows()) ? _H.transpose() : _H),\nenable_syndrome (enable_syndrome ),\nsyndrome_depth (syndrome_depth ),\ncur_syndrome_depth (0 )\n@@ -46,11 +46,11 @@ Decoder_LDPC_BP<B,R>\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- if (N != (int)H.get_n_rows())\n+ if (N != (int)this->H.get_n_rows())\n{\nstd::stringstream message;\nmessage << \"'N' is not compatible with the H matrix ('N' = \" << N << \", 'H.get_n_rows()' = \"\n- << H.get_n_rows() << \").\";\n+ << this->H.get_n_rows() << \").\";\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Decoder_LDPC_BP.hpp",
"new_path": "src/Module/Decoder/LDPC/BP/Decoder_LDPC_BP.hpp",
"diff": "@@ -14,7 +14,9 @@ class Decoder_LDPC_BP : public Decoder_SISO_SIHO<B,R>\n{\nprotected:\nconst int n_ite;\n- const tools::Sparse_matrix &H;\n+ const tools::Sparse_matrix &H; // CN are along the columns -> _H.get_n_rows() == M (often M=N-K)\n+ // VN are along the rows -> _H.get_n_cols() == N\n+ // automatically transpose in the constructor if needed\nconst bool enable_syndrome;\nconst int syndrome_depth;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Flooding/AMS/Decoder_LDPC_BP_flooding_approximate_min_star.hxx",
"new_path": "src/Module/Decoder/LDPC/BP/Flooding/AMS/Decoder_LDPC_BP_flooding_approximate_min_star.hxx",
"diff": "@@ -14,13 +14,13 @@ namespace module\ntemplate <typename B, typename R, tools::proto_min<R> MIN>\nDecoder_LDPC_BP_flooding_approximate_min_star<B,R,MIN>\n::Decoder_LDPC_BP_flooding_approximate_min_star(const int K, const int N, const int n_ite,\n- const tools::Sparse_matrix &H,\n+ const tools::Sparse_matrix &_H,\nconst std::vector<unsigned> &info_bits_pos,\nconst bool enable_syndrome,\nconst int syndrome_depth,\nconst int n_frames)\n: Decoder(K, N, n_frames, 1),\n- Decoder_LDPC_BP_flooding<B,R>(K, N, n_ite, H, info_bits_pos, enable_syndrome, syndrome_depth, n_frames)\n+ Decoder_LDPC_BP_flooding<B,R>(K, N, n_ite, _H, info_bits_pos, enable_syndrome, syndrome_depth, n_frames)\n{\nconst std::string name = \"Decoder_LDPC_BP_flooding_approximate_min_star\";\nthis->set_name(name);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Flooding/Decoder_LDPC_BP_flooding.cpp",
"new_path": "src/Module/Decoder/LDPC/BP/Flooding/Decoder_LDPC_BP_flooding.cpp",
"diff": "@@ -16,18 +16,21 @@ using namespace aff3ct::module;\ntemplate <typename B, typename R>\nDecoder_LDPC_BP_flooding<B,R>\n::Decoder_LDPC_BP_flooding(const int K, const int N, const int n_ite,\n- const tools::Sparse_matrix &H,\n+ const tools::Sparse_matrix &_H,\nconst std::vector<unsigned> &info_bits_pos,\nconst bool enable_syndrome,\nconst int syndrome_depth,\nconst int n_frames)\n: Decoder (K, N, n_frames, 1),\n- Decoder_LDPC_BP<B,R> (K, N, n_ite, H, enable_syndrome, syndrome_depth, n_frames, 1),\n+ Decoder_LDPC_BP<B,R> (K, N, n_ite, _H, enable_syndrome, syndrome_depth, n_frames, 1),\nn_V_nodes (N ), // same as N but more explicit\n- n_C_nodes ((int)H.get_n_cols() ),\n- n_branches ((int)H.get_n_connections() ),\n+ n_C_nodes ((int)this->H.get_n_cols() ),\n+ n_branches ((int)this->H.get_n_connections() ),\ninit_flag (true ),\ninfo_bits_pos (info_bits_pos ),\n+ n_variables_per_parity (this->H.get_n_cols() ),\n+ n_parities_per_variable(this->H.get_n_rows() ),\n+ transpose (this->n_branches ),\nLp_N (N, -1 ), // -1 in order to fail when AZCW\nC_to_V (n_frames, std::vector<R>(this->n_branches) ),\nV_to_C (n_frames, std::vector<R>(this->n_branches) )\n@@ -35,11 +38,10 @@ Decoder_LDPC_BP_flooding<B,R>\nconst std::string name = \"Decoder_LDPC_BP_flooding\";\nthis->set_name(name);\n- transpose.resize(this->n_branches);\n- mipp::vector<unsigned char> connections(H.get_n_rows(), 0);\n+ mipp::vector<unsigned char> connections(this->H.get_n_rows(), 0);\n- const auto &CN_to_VN = H.get_col_to_rows();\n- const auto &VN_to_CN = H.get_row_to_cols();\n+ const auto &CN_to_VN = this->H.get_col_to_rows();\n+ const auto &VN_to_CN = this->H.get_row_to_cols();\nauto k = 0;\nfor (auto i = 0; i < (int)CN_to_VN.size(); i++)\n@@ -68,12 +70,10 @@ Decoder_LDPC_BP_flooding<B,R>\n}\n}\n- n_variables_per_parity.resize(H.get_n_cols());\n- for (auto i = 0; i < (int)H.get_n_cols(); i++)\n+ for (auto i = 0; i < (int)this->H.get_n_cols(); i++)\nn_variables_per_parity[i] = (unsigned char)CN_to_VN[i].size();\n- n_parities_per_variable.resize(H.get_n_rows());\n- for (auto i = 0; i < (int)H.get_n_rows(); i++)\n+ for (auto i = 0; i < (int)this->H.get_n_rows(); i++)\nn_parities_per_variable[i] = (unsigned char)VN_to_CN[i].size();\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Flooding/Gallager/Decoder_LDPC_BP_flooding_Gallager_A.cpp",
"new_path": "src/Module/Decoder/LDPC/BP/Flooding/Gallager/Decoder_LDPC_BP_flooding_Gallager_A.cpp",
"diff": "@@ -12,26 +12,26 @@ using namespace aff3ct::module;\ntemplate <typename B, typename R>\nDecoder_LDPC_BP_flooding_Gallager_A<B,R>\n-::Decoder_LDPC_BP_flooding_Gallager_A(const int K, const int N, const int n_ite, const tools::Sparse_matrix &H,\n+::Decoder_LDPC_BP_flooding_Gallager_A(const int K, const int N, const int n_ite, const tools::Sparse_matrix &_H,\nconst std::vector<unsigned> &info_bits_pos, const bool enable_syndrome,\nconst int syndrome_depth, const int n_frames)\n: Decoder (K, N, n_frames, 1),\n- Decoder_LDPC_BP<B,R> (K, N, n_ite, H, enable_syndrome, syndrome_depth, n_frames, 1),\n+ Decoder_LDPC_BP<B,R> (K, N, n_ite, _H, enable_syndrome, syndrome_depth, n_frames, 1),\nhard_decision (N ),\ninfo_bits_pos (info_bits_pos ),\nHY_N (N ),\nV_N (N ),\n- C_to_V_messages (H.get_n_connections(), 0 ),\n- V_to_C_messages (H.get_n_connections(), 0 )\n+ C_to_V_messages (this->H.get_n_connections(), 0 ),\n+ V_to_C_messages (this->H.get_n_connections(), 0 ),\n+ transpose (this->H.get_n_connections() )\n{\nconst std::string name = \"Decoder_LDPC_BP_flooding_Gallager_A\";\nthis->set_name(name);\n- transpose.resize(H.get_n_connections());\n- std::vector<unsigned char> connections(H.get_n_rows(), 0);\n+ std::vector<unsigned char> connections(this->H.get_n_rows(), 0);\n- const auto &CN_to_VN = H.get_col_to_rows();\n- const auto &VN_to_CN = H.get_row_to_cols();\n+ const auto &CN_to_VN = this->H.get_col_to_rows();\n+ const auto &VN_to_CN = this->H.get_row_to_cols();\nauto k = 0;\nfor (auto i = 0; i < (int)CN_to_VN.size(); i++)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Flooding/LSPA/Decoder_LDPC_BP_flooding_log_sum_product.cpp",
"new_path": "src/Module/Decoder/LDPC/BP/Flooding/LSPA/Decoder_LDPC_BP_flooding_log_sum_product.cpp",
"diff": "@@ -12,14 +12,14 @@ using namespace aff3ct::module;\ntemplate <typename B, typename R>\nDecoder_LDPC_BP_flooding_log_sum_product<B,R>\n::Decoder_LDPC_BP_flooding_log_sum_product(const int K, const int N, const int n_ite,\n- const tools::Sparse_matrix &H,\n+ const tools::Sparse_matrix &_H,\nconst std::vector<unsigned> &info_bits_pos,\nconst bool enable_syndrome,\nconst int syndrome_depth,\nconst int n_frames)\n: Decoder(K, N, n_frames, 1),\n- Decoder_LDPC_BP_flooding<B,R>(K, N, n_ite, H, info_bits_pos, enable_syndrome, syndrome_depth, n_frames),\n- values(H.get_cols_max_degree())\n+ Decoder_LDPC_BP_flooding<B,R>(K, N, n_ite, _H, info_bits_pos, enable_syndrome, syndrome_depth, n_frames),\n+ values(this->H.get_cols_max_degree())\n{\nconst std::string name = \"Decoder_LDPC_BP_flooding_log_sum_product\";\nthis->set_name(name);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Flooding/ONMS/Decoder_LDPC_BP_flooding_offset_normalize_min_sum.cpp",
"new_path": "src/Module/Decoder/LDPC/BP/Flooding/ONMS/Decoder_LDPC_BP_flooding_offset_normalize_min_sum.cpp",
"diff": "@@ -45,7 +45,7 @@ inline double normalize(const double val, const float factor)\ntemplate <typename B, typename R>\nDecoder_LDPC_BP_flooding_offset_normalize_min_sum<B,R>\n::Decoder_LDPC_BP_flooding_offset_normalize_min_sum(const int K, const int N, const int n_ite,\n- const tools::Sparse_matrix &H,\n+ const tools::Sparse_matrix &_H,\nconst std::vector<unsigned> &info_bits_pos,\nconst float normalize_factor,\nconst R offset,\n@@ -53,7 +53,7 @@ Decoder_LDPC_BP_flooding_offset_normalize_min_sum<B,R>\nconst int syndrome_depth,\nconst int n_frames)\n: Decoder(K, N, n_frames, 1),\n- Decoder_LDPC_BP_flooding<B,R>(K, N, n_ite, H, info_bits_pos, enable_syndrome, syndrome_depth, n_frames),\n+ Decoder_LDPC_BP_flooding<B,R>(K, N, n_ite, _H, info_bits_pos, enable_syndrome, syndrome_depth, n_frames),\nnormalize_factor(normalize_factor), offset(offset)\n{\nconst std::string name = \"Decoder_LDPC_BP_flooding_offset_normalize_min_sum\";\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Flooding/SPA/Decoder_LDPC_BP_flooding_sum_product.cpp",
"new_path": "src/Module/Decoder/LDPC/BP/Flooding/SPA/Decoder_LDPC_BP_flooding_sum_product.cpp",
"diff": "@@ -12,14 +12,14 @@ using namespace aff3ct::module;\ntemplate <typename B, typename R>\nDecoder_LDPC_BP_flooding_sum_product<B,R>\n::Decoder_LDPC_BP_flooding_sum_product(const int K, const int N, const int n_ite,\n- const tools::Sparse_matrix &H,\n+ const tools::Sparse_matrix &_H,\nconst std::vector<unsigned> &info_bits_pos,\nconst bool enable_syndrome,\nconst int syndrome_depth,\nconst int n_frames)\n: Decoder(K, N, n_frames, 1),\n- Decoder_LDPC_BP_flooding<B,R>(K, N, n_ite, H, info_bits_pos, enable_syndrome, syndrome_depth, n_frames),\n- values(H.get_cols_max_degree())\n+ Decoder_LDPC_BP_flooding<B,R>(K, N, n_ite, _H, info_bits_pos, enable_syndrome, syndrome_depth, n_frames),\n+ values(this->H.get_cols_max_degree())\n{\nconst std::string name = \"Decoder_LDPC_BP_flooding_sum_product\";\nthis->set_name(name);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Layered/AMS/Decoder_LDPC_BP_layered_approximate_min_star.hxx",
"new_path": "src/Module/Decoder/LDPC/BP/Layered/AMS/Decoder_LDPC_BP_layered_approximate_min_star.hxx",
"diff": "@@ -14,14 +14,14 @@ namespace module\ntemplate <typename B, typename R, tools::proto_min<R> MIN>\nDecoder_LDPC_BP_layered_approximate_min_star<B,R,MIN>\n::Decoder_LDPC_BP_layered_approximate_min_star(const int K, const int N, const int n_ite,\n- const tools::Sparse_matrix &H,\n+ const tools::Sparse_matrix &_H,\nconst std::vector<unsigned> &info_bits_pos,\nconst bool enable_syndrome,\nconst int syndrome_depth,\nconst int n_frames)\n: Decoder(K, N, n_frames, 1),\n- Decoder_LDPC_BP_layered<B,R>(K, N, n_ite, H, info_bits_pos, enable_syndrome, syndrome_depth, n_frames),\n- contributions(H.get_cols_max_degree()), values(H.get_cols_max_degree())\n+ Decoder_LDPC_BP_layered<B,R>(K, N, n_ite, _H, info_bits_pos, enable_syndrome, syndrome_depth, n_frames),\n+ contributions(this->H.get_cols_max_degree()), values(this->H.get_cols_max_degree())\n{\nconst std::string name = \"Decoder_LDPC_BP_layered_approximate_min_star\";\nthis->set_name(name);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Layered/Decoder_LDPC_BP_layered.cpp",
"new_path": "src/Module/Decoder/LDPC/BP/Layered/Decoder_LDPC_BP_layered.cpp",
"diff": "@@ -14,18 +14,18 @@ using namespace aff3ct::module;\ntemplate <typename B, typename R>\nDecoder_LDPC_BP_layered<B,R>\n::Decoder_LDPC_BP_layered(const int K, const int N, const int n_ite,\n- const tools::Sparse_matrix &H,\n+ const tools::Sparse_matrix &_H,\nconst std::vector<unsigned> &info_bits_pos,\nconst bool enable_syndrome,\nconst int syndrome_depth,\nconst int n_frames)\n: Decoder (K, N, n_frames, 1),\n- Decoder_LDPC_BP<B,R> (K, N, n_ite, H, enable_syndrome, syndrome_depth, n_frames, 1),\n- n_C_nodes ((int)H.get_n_cols() ),\n+ Decoder_LDPC_BP<B,R> (K, N, n_ite, _H, enable_syndrome, syndrome_depth, n_frames, 1),\n+ n_C_nodes ((int)this->H.get_n_cols() ),\ninit_flag (true ),\ninfo_bits_pos (info_bits_pos ),\nvar_nodes (n_frames, std::vector<R>(N ) ),\n- branches (n_frames, std::vector<R>(H.get_n_connections()) )\n+ branches (n_frames, std::vector<R>(this->H.get_n_connections()) )\n{\nconst std::string name = \"Decoder_LDPC_BP_layered\";\nthis->set_name(name);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Layered/LSPA/Decoder_LDPC_BP_layered_log_sum_product.cpp",
"new_path": "src/Module/Decoder/LDPC/BP/Layered/LSPA/Decoder_LDPC_BP_layered_log_sum_product.cpp",
"diff": "@@ -13,14 +13,14 @@ using namespace aff3ct::module;\ntemplate <typename B, typename R>\nDecoder_LDPC_BP_layered_log_sum_product<B,R>\n::Decoder_LDPC_BP_layered_log_sum_product(const int K, const int N, const int n_ite,\n- const tools::Sparse_matrix &H,\n+ const tools::Sparse_matrix &_H,\nconst std::vector<unsigned> &info_bits_pos,\nconst bool enable_syndrome,\nconst int syndrome_depth,\nconst int n_frames)\n: Decoder(K, N, n_frames, 1),\n- Decoder_LDPC_BP_layered<B,R>(K, N, n_ite, H, info_bits_pos, enable_syndrome, syndrome_depth, n_frames),\n- contributions(H.get_cols_max_degree()), values(H.get_cols_max_degree())\n+ Decoder_LDPC_BP_layered<B,R>(K, N, n_ite, _H, info_bits_pos, enable_syndrome, syndrome_depth, n_frames),\n+ contributions(this->H.get_cols_max_degree()), values(this->H.get_cols_max_degree())\n{\nconst std::string name = \"Decoder_LDPC_BP_layered_log_sum_product\";\nthis->set_name(name);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Layered/ONMS/Decoder_LDPC_BP_layered_ONMS_inter.cpp",
"new_path": "src/Module/Decoder/LDPC/BP/Layered/ONMS/Decoder_LDPC_BP_layered_ONMS_inter.cpp",
"diff": "@@ -16,7 +16,7 @@ using namespace aff3ct::module;\ntemplate <typename B, typename R>\nDecoder_LDPC_BP_layered_ONMS_inter<B,R>\n::Decoder_LDPC_BP_layered_ONMS_inter(const int K, const int N, const int n_ite,\n- const tools::Sparse_matrix &H,\n+ const tools::Sparse_matrix &_H,\nconst std::vector<unsigned> &info_bits_pos,\nconst float normalize_factor,\nconst R offset,\n@@ -24,16 +24,16 @@ Decoder_LDPC_BP_layered_ONMS_inter<B,R>\nconst int syndrome_depth,\nconst int n_frames)\n: Decoder (K, N, n_frames, mipp::nElReg<R>() ),\n- Decoder_LDPC_BP<B,R> (K, N, n_ite, H, enable_syndrome, syndrome_depth, n_frames, mipp::nElReg<R>() ),\n+ Decoder_LDPC_BP<B,R> (K, N, n_ite, _H, enable_syndrome, syndrome_depth, n_frames, mipp::nElReg<R>() ),\nnormalize_factor (normalize_factor ),\noffset (offset ),\n- contributions (H.get_cols_max_degree() ),\n- saturation ((R)((1 << ((sizeof(R) * 8 -2) - (int)std::log2(H.get_rows_max_degree()))) -1)),\n- n_C_nodes ((int)H.get_n_cols() ),\n+ contributions (this->H.get_cols_max_degree() ),\n+ saturation ((R)((1 << ((sizeof(R) * 8 -2) - (int)std::log2(this->H.get_rows_max_degree()))) -1)),\n+ n_C_nodes ((int)this->H.get_n_cols() ),\ninit_flag (true ),\ninfo_bits_pos (info_bits_pos ),\nvar_nodes (this->n_dec_waves, mipp::vector<mipp::Reg<R>>(N) ),\n- branches (this->n_dec_waves, mipp::vector<mipp::Reg<R>>(H.get_n_connections()) ),\n+ branches (this->n_dec_waves, mipp::vector<mipp::Reg<R>>(this->H.get_n_connections()) ),\nY_N_reorderered (N ),\nV_reorderered (N )\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Layered/ONMS/Decoder_LDPC_BP_layered_offset_normalize_min_sum.cpp",
"new_path": "src/Module/Decoder/LDPC/BP/Layered/ONMS/Decoder_LDPC_BP_layered_offset_normalize_min_sum.cpp",
"diff": "@@ -46,7 +46,7 @@ inline double normalize(const double val, const float factor)\ntemplate <typename B, typename R>\nDecoder_LDPC_BP_layered_offset_normalize_min_sum<B,R>\n::Decoder_LDPC_BP_layered_offset_normalize_min_sum(const int K, const int N, const int n_ite,\n- const tools::Sparse_matrix &H,\n+ const tools::Sparse_matrix &_H,\nconst std::vector<unsigned> &info_bits_pos,\nconst float normalize_factor,\nconst R offset,\n@@ -54,8 +54,8 @@ Decoder_LDPC_BP_layered_offset_normalize_min_sum<B,R>\nconst int syndrome_depth,\nconst int n_frames)\n: Decoder(K, N, n_frames, 1),\n- Decoder_LDPC_BP_layered<B,R>(K, N, n_ite, H, info_bits_pos, enable_syndrome, syndrome_depth, n_frames),\n- normalize_factor(normalize_factor), offset(offset), contributions(H.get_cols_max_degree())\n+ Decoder_LDPC_BP_layered<B,R>(K, N, n_ite, _H, info_bits_pos, enable_syndrome, syndrome_depth, n_frames),\n+ normalize_factor(normalize_factor), offset(offset), contributions(this->H.get_cols_max_degree())\n{\nconst std::string name = \"Decoder_LDPC_BP_layered_offset_normalize_min_sum\";\nthis->set_name(name);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Layered/SPA/Decoder_LDPC_BP_layered_sum_product.cpp",
"new_path": "src/Module/Decoder/LDPC/BP/Layered/SPA/Decoder_LDPC_BP_layered_sum_product.cpp",
"diff": "@@ -13,14 +13,14 @@ using namespace aff3ct::module;\ntemplate <typename B, typename R>\nDecoder_LDPC_BP_layered_sum_product<B,R>\n::Decoder_LDPC_BP_layered_sum_product(const int K, const int N, const int n_ite,\n- const tools::Sparse_matrix &H,\n+ const tools::Sparse_matrix &_H,\nconst std::vector<unsigned> &info_bits_pos,\nconst bool enable_syndrome,\nconst int syndrome_depth,\nconst int n_frames)\n: Decoder(K, N, n_frames, 1),\n- Decoder_LDPC_BP_layered<B,R>(K, N, n_ite, H, info_bits_pos, enable_syndrome, syndrome_depth, n_frames),\n- contributions(H.get_cols_max_degree()), values(H.get_cols_max_degree())\n+ Decoder_LDPC_BP_layered<B,R>(K, N, n_ite, _H, info_bits_pos, enable_syndrome, syndrome_depth, n_frames),\n+ contributions(this->H.get_cols_max_degree()), values(this->H.get_cols_max_degree())\n{\nconst std::string name = \"Decoder_LDPC_BP_layered_sum_product\";\nthis->set_name(name);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Set a standard for the H matrix direction: cols are CN and rows are VN. Automatically transpose if needed
|
8,483 |
04.05.2018 17:04:42
| -7,200 |
613b98841d1140c0615e6875349d9fd3fc3a0766
|
Remove the reference to Sparse matrix H
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Decoder_LDPC_BP.hpp",
"new_path": "src/Module/Decoder/LDPC/BP/Decoder_LDPC_BP.hpp",
"diff": "@@ -14,7 +14,7 @@ class Decoder_LDPC_BP : public Decoder_SISO_SIHO<B,R>\n{\nprotected:\nconst int n_ite;\n- const tools::Sparse_matrix &H; // CN are along the columns -> _H.get_n_rows() == M (often M=N-K)\n+ const tools::Sparse_matrix H; // CN are along the columns -> _H.get_n_rows() == M (often M=N-K)\n// VN are along the rows -> _H.get_n_cols() == N\n// automatically transpose in the constructor if needed\nconst bool enable_syndrome;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Remove the reference to Sparse matrix H
|
8,483 |
04.05.2018 17:07:11
| -7,200 |
01186563d03dc6c6425ebea74e8f2b3e8fe2798e
|
Set print as const
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Sparse_matrix/Sparse_matrix.cpp",
"new_path": "src/Tools/Algo/Sparse_matrix/Sparse_matrix.cpp",
"diff": "@@ -272,7 +272,7 @@ void Sparse_matrix\n}\nvoid Sparse_matrix\n-::print(bool transpose, std::ostream& os)\n+::print(bool transpose, std::ostream& os) const\n{\nif (transpose)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Sparse_matrix/Sparse_matrix.hpp",
"new_path": "src/Tools/Algo/Sparse_matrix/Sparse_matrix.hpp",
"diff": "@@ -76,7 +76,7 @@ public:\n* Print the sparsed matrix in its full view with 0s and 1s.\n* 'transpose' allow the print in its transposed view\n*/\n- void print(bool transpose = false, std::ostream& os = std::cout);\n+ void print(bool transpose = false, std::ostream& os = std::cout) const;\n};\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Set print as const
|
8,483 |
04.05.2018 17:14:58
| -7,200 |
68c6a58650444c7484ed8b84f09f5ac3b72f51a2
|
Fix the peeling decoder by propaging the found VN to its related CN
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Peeling/Decoder_LDPC_BP_peeling.cpp",
"new_path": "src/Module/Decoder/LDPC/BP/Peeling/Decoder_LDPC_BP_peeling.cpp",
"diff": "@@ -53,7 +53,7 @@ void Decoder_LDPC_BP_peeling<B,R>\n// std::cout << \"(L) links : \" << std::endl;\n// links.print(true);\n- // first propagate known values\n+ // first forward known values\nfor (unsigned i = 0; i < links.get_n_rows(); i++)\n{\nauto cur_state = this->var_nodes[frame_id][i];\n@@ -89,13 +89,26 @@ void Decoder_LDPC_BP_peeling<B,R>\n// find degree-1 check nodes\nfor (unsigned i = 0; i < links.get_n_cols(); i++)\n{\n- if (links.get_col_to_rows()[i].size() == 1)\n- { // then propagate the belief\n+ if (links.get_rows_from_col(i).size() == 1)\n+ {\n+ no_modification = false;\n+\n+ // then forward the belief\nauto& vn_pos = links.get_rows_from_col(i).front();\n- this->var_nodes [frame_id][vn_pos] = this->check_nodes[frame_id][i];\n+ auto cur_state = this->check_nodes[frame_id][i];\n+ this->var_nodes [frame_id][vn_pos] = cur_state;\nthis->check_nodes[frame_id][ i] = 0;\nlinks.rm_connection(vn_pos, i);\n- no_modification = false;\n+\n+ // and propagate it\n+ auto& cn_list = links.get_cols_from_row(vn_pos);\n+ while (cn_list.size())\n+ {\n+ auto& cn_pos = cn_list.front();\n+\n+ this->check_nodes[frame_id][cn_pos] ^= cur_state;\n+ links.rm_connection(vn_pos, cn_pos);\n+ }\n}\nelse\nall_check_nodes_done &= links.get_rows_from_col(i).size() == 0;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix the peeling decoder by propaging the found VN to its related CN
|
8,483 |
04.05.2018 17:24:46
| -7,200 |
2b881eecdc30441bb06db2cda9ddc097be78c1dc
|
Set back snr time to 5 seconds
|
[
{
"change_type": "MODIFY",
"old_path": ".gitlab-ci.yml",
"new_path": ".gitlab-ci.yml",
"diff": "@@ -113,4 +113,4 @@ test-regression:\n- test-regression-results/\nscript:\n- ./ci/test-build-linux-gcc.sh\n- - ./ci/test-regression.py --max-snr-time 120 --sensibility 2.5 --weak-rate 0.9 --verbose 1\n\\ No newline at end of file\n+ - ./ci/test-regression.py --max-snr-time 5 --sensibility 2.5 --weak-rate 0.9 --verbose 1\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Set back snr time to 5 seconds
|
8,483 |
07.05.2018 12:29:48
| -7,200 |
2b03d3e0fec5880e1984242fb93e9156936262d6
|
Add a get_closest function that finds in a array the closest position of a given value
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/general_utils.cpp",
"new_path": "src/Tools/general_utils.cpp",
"diff": "@@ -126,7 +126,6 @@ R aff3ct::tools::ebn0_to_esn0(const R ebn0, const R bit_rate, const int bps)\nreturn esn0;\n}\n-#include <iostream>\ntemplate <typename R>\nstd::vector<R> aff3ct::tools::generate_range(const std::vector<std::vector<R>>& range_description, const R default_step)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/general_utils.h",
"new_path": "src/Tools/general_utils.h",
"diff": "@@ -35,7 +35,22 @@ R ebn0_to_esn0(const R ebn0, const R bit_rate = 1, const int bps = 1);\n*/\ntemplate <typename R = float>\nstd::vector<R> generate_range(const std::vector<std::vector<R>>& range_description, const R default_step = (R)0.1);\n+\n+\n+/*\n+ * Get the nearest position of value in range [first, last[.\n+ * the reference data must be sorted and strictly monotonic increasing\n+ * If value goes out of x_data range, then return the left or right limit value in function of the violated one.\n+ */\n+template <typename BidirectionalIterator, typename T>\n+inline BidirectionalIterator get_closest(BidirectionalIterator first, BidirectionalIterator last, const T & value);\n+\n+template <typename BidirectionalIterator, typename T>\n+inline std::size_t get_closest_index(BidirectionalIterator first, BidirectionalIterator last, const T & value);\n+\n}\n}\n+#include \"general_utils.hxx\"\n+\n#endif /* GENERAL_UTILS_H_*/\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/general_utils.hxx",
"diff": "+#ifndef GENERAL_UTILS_HXX\n+#define GENERAL_UTILS_HXX\n+\n+#include <algorithm>\n+#include \"general_utils.h\"\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+\n+template <typename BidirectionalIterator, typename T>\n+BidirectionalIterator get_closest(BidirectionalIterator first, BidirectionalIterator last, const T & value)\n+{ // https://stackoverflow.com/a/701141/7219905\n+\n+ auto before = std::lower_bound(first, last, value);\n+\n+ if (before == first) return first;\n+ if (before == last) return --last; // iterator must be bidirectional\n+\n+ auto after = before;\n+ --before;\n+\n+ return (*after - value) < (value - *before) ? after : before;\n+}\n+\n+template <typename BidirectionalIterator, typename T>\n+std::size_t get_closest_index(BidirectionalIterator first, BidirectionalIterator last, const T & value)\n+{\n+ return std::distance(first, get_closest(first, last, value));\n+}\n+\n+}\n+}\n+\n+#endif //GENERAL_UTILS_HXX\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a get_closest function that finds in a array the closest position of a given value
|
8,483 |
07.05.2018 12:30:30
| -7,200 |
610544eb7079866bc5e0f6f91b1371b8b94943d8
|
Add a nearest interpolation function in more than linear interpolation
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/interpolation.h",
"new_path": "src/Tools/Math/interpolation.h",
"diff": "@@ -9,17 +9,21 @@ namespace aff3ct\nnamespace tools\n{\n+enum class Interpolation_type {LINEAR, NEAREST};\n+\n+//************************************************************************************************* LINEAR INTERPOLATION\n/*\n* Compute the linear interpolation of x_val from the original data y_data matching with its abscissa x_data.\n* x_data, of length l_data, must be sorted and strictly monotonic increasing\n- * x_data and y_data must have the same length\n+ * x_data and y_data must have the same length 'l_data'\n* If x_val goes out of x_data range, then return the left or right limit value in function of the violated one.\n*/\ntemplate <typename T>\nT linear_interpolation(const T* x_data, const T* y_data, const unsigned l_data, const T x_val);\n/*\n- * Compute the linear interpolation of x_vals array, of length l_vals, from the original data y_data matching with its abscissa x_data.\n+ * Compute the linear interpolation of x_vals array, of length l_vals, from the original data y_data matching\n+ * with its abscissa x_data.\n* x_data, of length l_data, must be sorted and strictly monotonic increasing\n* Computed interpolation is returned in the filled array y_vals of same size than x_vals\n*/\n@@ -35,6 +39,38 @@ void linear_interpolation(const T* x_data, const T* y_data, const unsigned l_dat\ntemplate <typename T>\nvoid linear_interpolation(const std::vector<T>& x_data, const std::vector<T>& y_data,\nconst std::vector<T>& x_vals, std::vector<T>& y_vals);\n+\n+\n+\n+\n+//************************************************************************************************ NEAREST INTERPOLATION\n+/*\n+ * Compute the nearest interpolation of x_val from the original data y_data matching with its abscissa x_data.\n+ * x_data, of length l_data, must be sorted and strictly monotonic increasing\n+ * x_data and y_data must have the same length 'l_data'\n+ * If x_val goes out of x_data range, then return the left or right limit value in function of the violated one.\n+ */\n+template <typename T>\n+T nearest_interpolation(const T* x_data, const T* y_data, const unsigned l_data, const T x_val);\n+\n+/*\n+ * Compute the nearest interpolation of x_vals array, of length l_vals, from the original data y_data matching\n+ * with its abscissa x_data.\n+ * x_data, of length l_data, must be sorted and strictly monotonic increasing\n+ * Computed interpolation is returned in the filled array y_vals of same size than x_vals\n+ */\n+template <typename T>\n+void nearest_interpolation(const T* x_data, const T* y_data, const unsigned l_data,\n+ const T* x_vals, T* y_vals, const unsigned l_vals);\n+\n+/*\n+ * Compute the nearest interpolation of x_vals vector, from the original data y_data matching with its abscissa x_data.\n+ * x_data must be sorted and strictly monotonic increasing\n+ * Computed interpolation is returned in the filled vector y_vals of same size than x_vals.\n+ */\n+template <typename T>\n+void nearest_interpolation(const std::vector<T>& x_data, const std::vector<T>& y_data,\n+ const std::vector<T>& x_vals, std::vector<T>& y_vals);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/interpolation.hxx",
"new_path": "src/Tools/Math/interpolation.hxx",
"diff": "#include <mipp.h>\n#include \"interpolation.h\"\n-#include \"utils.h\"\n+#include \"Tools/Math/utils.h\"\n+#include \"Tools/general_utils.h\"\nnamespace aff3ct\n{\nnamespace tools\n{\n+//************************************************************************************************* LINEAR INTERPOLATION\n+\ntemplate <typename T>\nT linear_interpolation(const T* x_data, const T* y_data, const unsigned l_data, const T x_val)\n{\n- auto x_above = std::lower_bound(x_data, x_data + l_data, x_val); // find the position of the first x that is above the x_val\n+ auto x_above = std::lower_bound(x_data, x_data + l_data, x_val); // find the position of the first x that is above\n+ // or equal to the x_val\n+\n+ auto y_above = y_data + (x_above - x_data); // get the position of the matching value y of x_above\n- if (x_above == x_data)\n- return *y_data;\n+ if (x_above == x_data || comp_equal(x_val, *x_above)) // if first or x_above == x_val\n+ return *y_above; // good x so take y directly\nauto x_below = x_above - 1; // get the position of value just below or equal to x_val\n- auto y_below = y_data + (x_below - x_data); // get the position of the matching value y of x_below\n+ auto y_below = y_above - 1; // get the position of the matching value y of x_below\nif ((x_above == (x_data + l_data)) || comp_equal(x_val, *x_below)) // if last or x_below == x_val\n- return *y_below; // same x so take y directly\n-\n+ return *y_below; // good x so take y directly\n// compute the interpolation y = y0 + (y1-y0)*(x-x0)/(x1-x0);\n- auto y_above = y_below + 1; // get the position of value just above\n-\nreturn *y_below + (*y_above - *y_below) * (x_val - *x_below) / (*x_above - *x_below);\n}\n@@ -53,6 +56,36 @@ void linear_interpolation(const std::vector<T>& x_data, const std::vector<T>& y_\ny_vals[j] = linear_interpolation(x_data.data(), y_data.data(), x_data.size(), x_vals[j]);\n}\n+\n+\n+\n+//************************************************************************************************ NEAREST INTERPOLATION\n+template <typename T>\n+T nearest_interpolation(const T* x_data, const T* y_data, const unsigned l_data, const T x_val)\n+{\n+ auto pos = get_closest_index(x_data, x_data + l_data, x_val);\n+ return y_data[pos];\n+}\n+\n+template <typename T>\n+void nearest_interpolation(const T* x_data, const T* y_data, const unsigned l_data,\n+ const T* x_vals, T* y_vals, const unsigned l_vals)\n+{\n+ for(unsigned j = 0; j < l_vals; j++)\n+ y_vals[j] = nearest_interpolation(x_data, y_data, l_data, x_vals[j]);\n+}\n+\n+template <typename T>\n+void nearest_interpolation(const std::vector<T>& x_data, const std::vector<T>& y_data,\n+ const std::vector<T>& x_vals, std::vector<T>& y_vals)\n+{\n+ assert(x_data.size() == y_data.size());\n+ assert(x_vals.size() == y_vals.size());\n+\n+ for(unsigned j = 0; j < x_vals.size(); j++)\n+ y_vals[j] = nearest_interpolation(x_data.data(), y_data.data(), x_data.size(), x_vals[j]);\n+}\n+\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a nearest interpolation function in more than linear interpolation
|
8,483 |
07.05.2018 12:31:43
| -7,200 |
5ad6f131cac3c99179d699f7b3e2380f1edb9c14
|
Add a distribution mode to use a summed CDF or a interpoled CDF; Add a method to build a summed cdf
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/Distribution/Distribution.cpp",
"new_path": "src/Tools/Math/Distribution/Distribution.cpp",
"diff": "#include <random>\n#include <sstream>\n#include <algorithm>\n+#include <vector>\n+#include <numeric>\n#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/Math/numerical_integration.h\"\n#include \"Distribution.hpp\"\nusing namespace aff3ct;\n-using namespace tools;\n+using namespace aff3ct::tools;\ntemplate <typename R>\nDistribution<R>\n-::Distribution(const std::vector<R>& _x_data, const std::vector<R>& _y_data)\n+::Distribution(const std::vector<R>& _x_data, const std::vector<R>& _y_data, Distribution_mode mode)\n: pdf_x(_x_data), pdf_y(1)\n{\n- if (pdf_x.size() != _y_data.size())\n- {\n- std::stringstream message;\n- message << \"'_x_data.size()' has to be equal to '_y_data.size()' ('_x_data.size()' = \" << pdf_x.size()\n- << \" and '_y_data.size()' = \" << _y_data.size() << \").\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- if (pdf_x.size() == 0)\n- {\n- std::stringstream message;\n- message << \"'_x_data.size()' can't be empty.\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\npdf_y.front() = _y_data;\n- compute_cdf();\n+ compute_cdf(mode);\n}\ntemplate <typename R>\nDistribution<R>\n-::Distribution(std::vector<R>&& _x_data, std::vector<R>&& _y_data)\n+::Distribution(std::vector<R>&& _x_data, std::vector<R>&& _y_data, Distribution_mode mode)\n: pdf_x(std::move(_x_data)), pdf_y(1)\n{\npdf_y.front() = std::move(_y_data);\n- if (pdf_x.size() != pdf_y.front().size())\n- {\n- std::stringstream message;\n- message << \"'_x_data.size()' has to be equal to '_y_data.size()' ('_x_data.size()' = \" << pdf_x.size()\n- << \" and '_y_data.size()' = \" << pdf_y.front().size() << \").\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ compute_cdf(mode);\n}\n- if (pdf_x.size() == 0)\n+template <typename R>\n+Distribution<R>\n+::Distribution(const std::vector<R>& _x_data, const std::vector<std::vector<R>>& _y_data, Distribution_mode mode)\n+: pdf_x(_x_data), pdf_y(_y_data)\n{\n- std::stringstream message;\n- message << \"'_x_data.size()' can't be empty.\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ compute_cdf(mode);\n}\n- compute_cdf();\n+template <typename R>\n+Distribution<R>\n+::Distribution(std::vector<R>&& _x_data, std::vector<std::vector<R>>&& _y_data, Distribution_mode mode)\n+: pdf_x(std::move(_x_data)), pdf_y(std::move(_y_data))\n+{\n+ compute_cdf(mode);\n}\ntemplate <typename R>\nDistribution<R>\n-::Distribution(const std::vector<R>& _x_data, const std::vector<std::vector<R>>& _y_data)\n-: pdf_x(_x_data), pdf_y(_y_data)\n-{\n- for (unsigned k = 0; k < pdf_y.size(); k++)\n- {\n- if (pdf_x.size() != pdf_y[k].size())\n+::~Distribution()\n{\n- std::stringstream message;\n- message << \"'_x_data.size()' has to be equal to '_y_data[\" << k << \"].size()' ('_x_data.size()' = \" << pdf_x.size()\n- << \" and '_y_data[\" << k << \"].size()' = \" << pdf_y[k].size() << \").\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n}\n- if (pdf_x.size() == 0)\n+template <typename R>\n+void Distribution<R>\n+::sort_pdf()\n{\n- std::stringstream message;\n- message << \"'_x_data.size()' can't be empty.\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n+ for (unsigned i = 1; i < this->pdf_x.size(); i++)\n+ for (unsigned j = i; j > 0 && this->pdf_x[j] < this->pdf_x[j-1]; j--)\n+ {\n+ std::swap(this->pdf_x[j], this->pdf_x[j-1]); // order the x position\n- compute_cdf();\n+ for (unsigned k = 0; k < this->pdf_y.size(); k++)\n+ std::swap(this->pdf_y[k][j], this->pdf_y[k][j-1]); // the y follow their x moving the same way\n+ }\n}\n-\ntemplate <typename R>\n-Distribution<R>\n-::Distribution(std::vector<R>&& _x_data, std::vector<std::vector<R>>&& _y_data)\n-: pdf_x(std::move(_x_data)), pdf_y(std::move(_y_data))\n-{\n- for (unsigned k = 0; k < pdf_y.size(); k++)\n+void Distribution<R>\n+::compute_cdf(Distribution_mode mode)\n{\n- if (pdf_x.size() != pdf_y[k].size())\n+ if (this->pdf_x.empty())\n{\nstd::stringstream message;\n- message << \"'_x_data.size()' has to be equal to '_y_data[\" << k << \"].size()' ('_x_data.size()' = \" << pdf_x.size()\n- << \" and '_y_data[\" << k << \"].size()' = \" << pdf_y[k].size() << \").\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n+ message << \"'pdf_x' can't be empty.\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- if (pdf_x.size() == 0)\n+ for (unsigned k = 0; k < this->pdf_y.size(); k++)\n+ {\n+ if (this->pdf_x.size() != this->pdf_y[k].size())\n{\nstd::stringstream message;\n- message << \"'_x_data.size()' can't be empty.\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ message << \"'pdf_x.size()' has to be equal to 'pdf_y[\" << k << \"].size()' ('pdf_x.size()' = \" << pdf_x.size()\n+ << \" and 'pdf_y[\" << k << \"].size()' = \" << pdf_y[k].size() << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n}\n+ sort_pdf(); // first make sure x values are sorted in ascending order\n- compute_cdf();\n-}\n+ this->cdf_x.resize(this->pdf_y.size());\n+ this->cdf_y.resize(this->pdf_y.size());\n-template <typename R>\n-Distribution<R>\n-::~Distribution()\n+ switch (mode)\n{\n+ case Distribution_mode::SUMMATION:\n+ compute_cdf_summation();\n+ break;\n+ case Distribution_mode::INTERPOLATION:\n+ compute_cdf_interpolation();\n+ break;\n+ }\n}\ntemplate <typename R>\nvoid Distribution<R>\n-::sort_pdf()\n+::compute_cdf_summation()\n{\n- for (unsigned i = 1; i < this->pdf_x.size(); i++)\n- for (unsigned j = i; j > 0 && this->pdf_x[j] < this->pdf_x[j-1]; j--)\n+ for (unsigned k = 0; k < this->pdf_y.size(); k++)\n{\n- std::swap(this->pdf_x[j], this->pdf_x[j-1]); // order the x position\n+ std::vector<R> cumul_y(this->pdf_y[k].size());\n+ std::partial_sum(this->pdf_y[k].begin(), this->pdf_y[k].end(), cumul_y.begin());\n- for (unsigned k = 0; k < this->pdf_y.size(); k++)\n- std::swap(this->pdf_y[k][j], this->pdf_y[k][j-1]); // the y follow their x moving the same way\n+ auto sum = cumul_y.back();\n+\n+ if (sum == (R) 0)\n+ {\n+ std::stringstream message;\n+ message << \"The sum of pdf_y[\" << k << \"] is null.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ // keep the parts of the cdf not parallel to the X axis -> pdf_y not null\n+ for (unsigned i = 0; i < this->pdf_y[k].size(); i++) // keep the first index\n+ if (this->pdf_y[k][i] != (R)0) // proba not null\n+ {\n+ this->cdf_x[k].push_back(this->pdf_x[i]);\n+ this->cdf_y[k].push_back(cumul_y[i]);\n+ }\n}\n}\ntemplate <typename R>\nvoid Distribution<R>\n-::compute_cdf()\n+::compute_cdf_interpolation()\n{\n- sort_pdf(); // first make sure x values are sorted in ascending order\n-\n- // then normalize it with its integral value\n+ // normalize pdf with its integral value\nthis->pdf_norm_y.resize(this->pdf_y.size());\nfor (unsigned k = 0; k < this->pdf_y.size(); k++)\n{\n@@ -151,6 +149,13 @@ void Distribution<R>\n// compute the integral of pdf_y[k] along pdf_x\nauto integ = tools::trapz_integral_seq(this->pdf_x.data(), this->pdf_y[k].data(), this->pdf_x.size());\n+ if (integ == (R)0)\n+ {\n+ std::stringstream message;\n+ message << \"The integral of pdf_y[\" << k << \"] along pdf_x is null.\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n// divide all elements by 'integ'\nstd::transform(this->pdf_y[k].begin(), this->pdf_y[k].end(), this->pdf_norm_y[k].begin(), [integ](R& y){return y/integ;});\n}\n@@ -169,9 +174,6 @@ void Distribution<R>\ninterp_x.back() = max_x; // force the value to have exactly the max instead of an approximation after all the \"+= step_x\"\n- this->cdf_x.resize(this->pdf_y.size());\n- this->cdf_y.resize(this->pdf_y.size());\n-\n// compute linear interpolation and the cumulative distribution\nfor (unsigned k = 0; k < this->pdf_y.size(); k++)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/Distribution/Distribution.hpp",
"new_path": "src/Tools/Math/Distribution/Distribution.hpp",
"diff": "@@ -8,6 +8,8 @@ namespace aff3ct\nnamespace tools\n{\n+enum class Distribution_mode {INTERPOLATION, SUMMATION};\n+\ntemplate <typename R = float>\nclass Distribution\n{\n@@ -21,10 +23,10 @@ protected:\nstd::vector<std::vector<R>> cdf_y; // cumulative density function as y\npublic:\n- Distribution(const std::vector<R>& _x_data, const std::vector<R>& _y_data);\n- Distribution(std::vector<R>&& _x_data, std::vector<R>&& _y_data);\n- Distribution(const std::vector<R>& _x_data, const std::vector<std::vector<R>>& _y_data);\n- Distribution(std::vector<R>&& _x_data, std::vector<std::vector<R>>&& _y_data);\n+ Distribution(const std::vector<R>& _x_data, const std::vector<R>& _y_data, Distribution_mode mode = Distribution_mode::SUMMATION);\n+ Distribution( std::vector<R>&& _x_data, std::vector<R>&& _y_data, Distribution_mode mode = Distribution_mode::SUMMATION);\n+ Distribution(const std::vector<R>& _x_data, const std::vector<std::vector<R>>& _y_data, Distribution_mode mode = Distribution_mode::SUMMATION);\n+ Distribution( std::vector<R>&& _x_data, std::vector<std::vector<R>>&& _y_data, Distribution_mode mode = Distribution_mode::SUMMATION);\nvirtual ~Distribution();\n@@ -35,7 +37,9 @@ public:\nconst std::vector<std::vector<R>>& get_pdf_norm_y() const;\nprotected:\n- void compute_cdf();\n+ void compute_cdf(Distribution_mode mode);\n+ void compute_cdf_interpolation();\n+ void compute_cdf_summation();\nvoid sort_pdf();\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/Distribution/Distributions.cpp",
"new_path": "src/Tools/Math/Distribution/Distributions.cpp",
"diff": "@@ -14,8 +14,8 @@ const int aff3ct::tools::Distributions<R>::saved_noise_precision = 1e6;\ntemplate<typename R>\nDistributions<R>::\n-Distributions(const std::string& filename, bool read_all_at_init)\n-: f_distributions(filename)\n+Distributions(const std::string& filename, Distribution_mode mode, bool read_all_at_init)\n+: f_distributions(filename), mode(mode)\n{\nif (f_distributions.fail())\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/Distribution/Distributions.hpp",
"new_path": "src/Tools/Math/Distribution/Distributions.hpp",
"diff": "@@ -25,6 +25,8 @@ protected:\nstd::map<int, Distribution<R>*> distributions; // distributions in function of the noise power\nstd::ifstream f_distributions;\n+ Distribution_mode mode;\n+\nstd::vector<R> noise_range;\nstd::vector<std::streampos> noise_file_index;\n@@ -36,7 +38,7 @@ protected:\nsize_t y1_pos ;\npublic:\n- explicit Distributions(const std::string& filename, bool read_all_at_init = false);\n+ explicit Distributions(const std::string& filename, Distribution_mode mode = Distribution_mode::SUMMATION, bool read_all_at_init = false);\nvirtual ~Distributions();\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a distribution mode to use a summed CDF or a interpoled CDF; Add a method to build a summed cdf
|
8,483 |
07.05.2018 12:33:33
| -7,200 |
0ed8e92c0f394fbc4d224ce303634d76e9c9bcca
|
add in User_pdf_noise_generator a mode to use a linear or a nearest interpolation while generating noise
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Noise_generator/User_pdf_noise_generator/Standard/User_pdf_noise_generator_std.cpp",
"new_path": "src/Tools/Algo/Noise_generator/User_pdf_noise_generator/Standard/User_pdf_noise_generator_std.cpp",
"diff": "@@ -8,10 +8,21 @@ using namespace aff3ct::tools;\ntemplate <typename R>\nUser_pdf_noise_generator_std<R>\n-::User_pdf_noise_generator_std(const tools::Distributions<R>& dists, const int seed)\n-: User_pdf_noise_generator<R>(dists), uniform_dist(0., 1.)\n+::User_pdf_noise_generator_std(const tools::Distributions<R>& dists, const int seed, Interpolation_type inter_type)\n+: User_pdf_noise_generator<R>(dists), uniform_dist(0., 1.), interp_function(nullptr)\n{\nthis->set_seed(seed);\n+\n+ switch (inter_type)\n+ {\n+ case Interpolation_type::LINEAR:\n+ interp_function = tools::linear_interpolation<R>;\n+ break;\n+\n+ case Interpolation_type::NEAREST:\n+ interp_function = tools::nearest_interpolation<R>;\n+ break;\n+ }\n}\ntemplate <typename R>\n@@ -44,8 +55,7 @@ void User_pdf_noise_generator_std<R>\n{\nconst auto& cdf_y = signal[i] ? dis->get_cdf_y()[1] : dis->get_cdf_y()[0];\nconst auto& cdf_x = signal[i] ? dis->get_cdf_x()[1] : dis->get_cdf_x()[0];\n- noise[i] = tools::linear_interpolation(cdf_y.data(), cdf_x.data(), cdf_x.size(),\n- this->uniform_dist(this->rd_engine));\n+ noise[i] = interp_function(cdf_y.data(), cdf_x.data(), cdf_x.size(), this->uniform_dist(this->rd_engine));\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Noise_generator/User_pdf_noise_generator/Standard/User_pdf_noise_generator_std.hpp",
"new_path": "src/Tools/Algo/Noise_generator/User_pdf_noise_generator/Standard/User_pdf_noise_generator_std.hpp",
"diff": "#include <random>\n+#include \"Tools/Math/interpolation.h\"\n#include \"../User_pdf_noise_generator.hpp\"\nnamespace aff3ct\n@@ -17,8 +18,10 @@ private:\nstd::mt19937 rd_engine; // Mersenne Twister 19937\nstd::uniform_real_distribution<R> uniform_dist;\n+ R (*interp_function)(const R*, const R*, const unsigned, const R);\n+\npublic:\n- explicit User_pdf_noise_generator_std(const tools::Distributions<R>& dists, const int seed = 0);\n+ explicit User_pdf_noise_generator_std(const tools::Distributions<R>& dists, const int seed = 0, Interpolation_type inter_type = Interpolation_type::NEAREST);\nvirtual ~User_pdf_noise_generator_std();\nvirtual void set_seed(const int seed);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Noise_generator/User_pdf_noise_generator/User_pdf_noise_generator.hpp",
"new_path": "src/Tools/Algo/Noise_generator/User_pdf_noise_generator/User_pdf_noise_generator.hpp",
"diff": "@@ -18,6 +18,8 @@ namespace aff3ct\nnamespace tools\n{\n+enum class User_pdf_noise_generator_interpolation {LINEAR, NEAREST};\n+\ntemplate <typename R = float>\nclass User_pdf_noise_generator : public Noise_generator<R>\n{\n@@ -28,7 +30,7 @@ public:\nexplicit User_pdf_noise_generator(const tools::Distributions<R>& dists)\n: distributions(dists) {}\n- virtual ~User_pdf_noise_generator() {}\n+ virtual ~User_pdf_noise_generator() = default;\nconst Distributions<R>& get_distributions()\n{\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
add in User_pdf_noise_generator a mode to use a linear or a nearest interpolation while generating noise
|
8,483 |
07.05.2018 12:34:00
| -7,200 |
007b11d2732cd92d2ad4ad89885a28dc42f83c49
|
rewrite optical demodulator to use the get_closet function
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/Optical/Modem_optical.cpp",
"new_path": "src/Module/Modem/Optical/Modem_optical.cpp",
"diff": "@@ -136,27 +136,10 @@ void Modem_optical<B,R,Q>\nconst auto& pdf_y0 = current_dist->get_pdf_y()[0];\nconst auto& pdf_y1 = current_dist->get_pdf_y()[1];\n- unsigned x_pos;\nfor (auto i = 0; i < this->N_fil; i++)\n{\n- // find the position of the first x that is above the receiver val\n- auto x_above = std::lower_bound(pdf_x.begin(), pdf_x.end(), Y_N1[i]);\n-\n- if (x_above == pdf_x.end()) // if last\n- x_pos = pdf_x.size() - 1;\n- else if (x_above == pdf_x.begin()) // if first\n- x_pos = 0;\n- else\n- {\n- x_pos = std::distance(pdf_x.begin(), x_above);\n-\n- auto x_below = x_above - 1;\n-\n- // find which between x_below and x_above is the nearest of Y_N1[i]\n- x_pos = (Y_N1[i] - *x_below) < (*x_above - Y_N1[i]) ? x_pos - 1 : x_pos;\n- }\n+ auto x_pos = tools::get_closest_index(pdf_x.begin(), pdf_x.end(), Y_N1[i]);\n- // then get the matching probabilities\nauto prob_0 = pdf_y0[x_pos] == (Q)0 ? min_value : pdf_y0[x_pos];\nauto prob_1 = pdf_y1[x_pos] == (Q)0 ? min_value : pdf_y1[x_pos];\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
rewrite optical demodulator to use the get_closet function
|
8,483 |
07.05.2018 14:30:33
| -7,200 |
11a67668090e65b41cbe609be297bfb153b060e3
|
Fix distribution cmf_summation by normalizing it
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/Distribution/Distribution.cpp",
"new_path": "src/Tools/Math/Distribution/Distribution.cpp",
"diff": "@@ -130,7 +130,7 @@ void Distribution<R>\nif (this->pdf_y[k][i] != (R)0) // proba not null\n{\nthis->cdf_x[k].push_back(this->pdf_x[i]);\n- this->cdf_y[k].push_back(cumul_y[i]);\n+ this->cdf_y[k].push_back(cumul_y[i]/sum);\n}\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix distribution cmf_summation by normalizing it
|
8,483 |
07.05.2018 18:03:55
| -7,200 |
b20b043a0244259b14109971b54e4e6d365290b5
|
Fix compile error in simple precision simulation
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Modem/Modem.cpp",
"new_path": "src/Factory/Module/Modem/Modem.cpp",
"diff": "@@ -404,11 +404,11 @@ template aff3ct::module::Modem<B_16,R_16,R_16>* aff3ct::factory::Modem::build<B_\ntemplate aff3ct::module::Modem<B_32,R_32,Q_32>* aff3ct::factory::Modem::build<B_32,R_32,Q_32>(const aff3ct::factory::Modem::parameters&, const tools::Distributions<R_32>*, const std::string&);\ntemplate aff3ct::module::Modem<B_64,R_64,Q_64>* aff3ct::factory::Modem::build<B_64,R_64,Q_64>(const aff3ct::factory::Modem::parameters&, const tools::Distributions<R_64>*, const std::string&);\n#else\n-template aff3ct::module::Modem<B,R,Q>* aff3ct::factory::Modem::parameters::build<B,R,Q>(const tools::Distributions<R>*) const;\n-template aff3ct::module::Modem<B,R,Q>* aff3ct::factory::Modem::build<B,R,Q>(const aff3ct::factory::Modem::parameters&, const tools::Distributions<R>*);\n+template aff3ct::module::Modem<B,R,Q>* aff3ct::factory::Modem::parameters::build<B,R,Q>(const tools::Distributions<R>*, const std::string&) const;\n+template aff3ct::module::Modem<B,R,Q>* aff3ct::factory::Modem::build<B,R,Q>(const aff3ct::factory::Modem::parameters&, const tools::Distributions<R>*, const std::string&);\n#if !defined(PREC_32_BIT) && !defined(PREC_64_BIT)\n-template aff3ct::module::Modem<B,R,R>* aff3ct::factory::Modem::parameters::build<B,R,R>(const tools::Distributions<R>*) const;\n-template aff3ct::module::Modem<B,R,R>* aff3ct::factory::Modem::build<B,R,R>(const aff3ct::factory::Modem::parameters&, const tools::Distributions<R>*);\n+template aff3ct::module::Modem<B,R,R>* aff3ct::factory::Modem::parameters::build<B,R,R>(const tools::Distributions<R>*, const std::string&) const;\n+template aff3ct::module::Modem<B,R,R>* aff3ct::factory::Modem::build<B,R,R>(const aff3ct::factory::Modem::parameters&, const tools::Distributions<R>*, const std::string&);\n#endif\n#endif\n// ==================================================================================== explicit template instantiation\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix compile error in simple precision simulation
|
8,490 |
08.05.2018 11:33:43
| -7,200 |
7f929fb61b207c276cbfa1f293372db68583edd4
|
Refacto LDPC BP + clean GALA + improve Sparse_matrix perf. with inline.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.hpp",
"new_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.hpp",
"diff": "@@ -33,7 +33,7 @@ struct Decoder_LDPC : public Decoder\nfloat norm_factor = 1.f;\nfloat offset = 0.f;\nbool enable_syndrome = true;\n- int syndrome_depth = 2;\n+ int syndrome_depth = 1;\nint n_ite = 10;\n// ---------------------------------------------------------------------------------------------------- METHODS\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Flooding/Decoder_LDPC_BP_flooding.hpp",
"new_path": "src/Module/Decoder/LDPC/BP/Flooding/Decoder_LDPC_BP_flooding.hpp",
"diff": "@@ -14,17 +14,11 @@ template <typename B = int, typename R = float, class Update_rule = tools::Updat\nclass Decoder_LDPC_BP_flooding : public Decoder_LDPC_BP<B,R>\n{\nprotected:\n- const int n_var_nodes; // number of variable nodes (N)\n- const int n_chk_nodes; // number of check nodes (N - K)\n- const int n_branches; // number of branched in the bi-partite graph (connexions between the var and check nodes)\nconst std::vector<uint32_t> &info_bits_pos;\nUpdate_rule up_rule;\n- std::vector<uint8_t > chk_degrees;\n- std::vector<uint8_t > var_degrees;\nstd::vector<uint32_t > transpose;\n-\nstd::vector<R > post; // a posteriori information\nstd::vector<std::vector<R>> chk_to_var; // check nodes to variable nodes messages\nstd::vector<std::vector<R>> var_to_chk; // variable nodes to check nodes messages\n@@ -48,8 +42,9 @@ protected:\nvoid _decode_siho_cw(const R *Y_N, B *V_N, const int frame_id);\nvoid _decode (const R *Y_N, const int frame_id);\n- void _compute_post (const R *Y_N, const std::vector<R> &chk_to_var);\n- void _decode_single_ite(const R *Y_N, std::vector<R> &var_to_chk, std::vector<R> &chk_to_var);\n+ void _initialize_var_to_chk(const R *Y_N, const std::vector<R> &chk_to_var, std::vector<R> &var_to_chk);\n+ void _decode_single_ite (const std::vector<R> &var_to_chk, std::vector<R> &chk_to_var);\n+ void _compute_post (const R *Y_N, const std::vector<R> &chk_to_var, std::vector<R> &post);\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Flooding/Decoder_LDPC_BP_flooding.hxx",
"new_path": "src/Module/Decoder/LDPC/BP/Flooding/Decoder_LDPC_BP_flooding.hxx",
"diff": "@@ -23,20 +23,17 @@ Decoder_LDPC_BP_flooding<B,R,Update_rule>\nconst int n_frames)\n: Decoder (K, N, n_frames, 1),\nDecoder_LDPC_BP<B,R>(K, N, n_ite, H, enable_syndrome, syndrome_depth, n_frames, 1),\n- n_var_nodes (N ),\n- n_chk_nodes ((int)H.get_n_cols() ),\n- n_branches ((int)H.get_n_connections() ),\ninfo_bits_pos (info_bits_pos ),\nup_rule (up_rule ),\n+ transpose (H.get_n_connections() ),\npost (N, -1 ),\n- chk_to_var (n_frames, std::vector<R>(this->n_branches) ),\n- var_to_chk (n_frames, std::vector<R>(this->n_branches) ),\n+ chk_to_var (n_frames, std::vector<R>(H.get_n_connections()) ),\n+ var_to_chk (n_frames, std::vector<R>(H.get_n_connections()) ),\ninit_flag (true )\n{\nconst std::string name = \"Decoder_LDPC_BP_flooding<\" + this->up_rule.get_name() + \">\";\nthis->set_name(name);\n- transpose.resize(this->n_branches);\nmipp::vector<unsigned char> connections(H.get_n_rows(), 0);\nconst auto &chk_to_var_id = H.get_col_to_rows();\n@@ -68,14 +65,6 @@ Decoder_LDPC_BP_flooding<B,R,Update_rule>\nk++;\n}\n}\n-\n- chk_degrees.resize(H.get_n_cols());\n- for (auto i = 0; i < (int)H.get_n_cols(); i++)\n- chk_degrees[i] = (unsigned char)chk_to_var_id[i].size();\n-\n- var_degrees.resize(H.get_n_rows());\n- for (auto i = 0; i < (int)H.get_n_rows(); i++)\n- var_degrees[i] = (unsigned char)var_to_chk_id[i].size();\n}\ntemplate <typename B, typename R, class Update_rule>\n@@ -174,27 +163,6 @@ void Decoder_LDPC_BP_flooding<B,R,Update_rule>\n// (*this)[dec::tsk::decode_siho_cw].update_timer(dec::tm::decode_siho_cw::store, d_store);\n}\n-template <typename B, typename R, class Update_rule>\n-void Decoder_LDPC_BP_flooding<B,R,Update_rule>\n-::_compute_post(const R *Y_N, const std::vector<R> &chk_to_var)\n-{\n- // compute the a posteriori info\n- const auto *chk_to_var_ptr = chk_to_var.data();\n- for (auto v = 0; v < this->n_var_nodes; v++)\n- {\n- const auto var_degree = this->var_degrees[v];\n-\n- auto sum_chk_to_var = (R)0;\n- for (auto c = 0; c < var_degree; c++)\n- sum_chk_to_var += chk_to_var_ptr[c];\n-\n- // filling the output\n- this->post[v] = Y_N[v] + sum_chk_to_var;\n-\n- chk_to_var_ptr += var_degree;\n- }\n-}\n-\ntemplate <typename B, typename R, class Update_rule>\nvoid Decoder_LDPC_BP_flooding<B,R,Update_rule>\n::_decode(const R *Y_N, const int frame_id)\n@@ -205,32 +173,34 @@ void Decoder_LDPC_BP_flooding<B,R,Update_rule>\nfor (; ite < this->n_ite; ite++)\n{\nthis->up_rule.begin_ite(ite);\n- this->_decode_single_ite(Y_N, this->var_to_chk[frame_id], this->chk_to_var[frame_id]);\n+ this->_initialize_var_to_chk(Y_N, this->chk_to_var[frame_id], this->var_to_chk[frame_id]);\n+ this->_decode_single_ite(this->var_to_chk[frame_id], this->chk_to_var[frame_id]);\nthis->up_rule.end_ite();\nif (this->enable_syndrome && ite != this->n_ite -1)\n{\n- this->_compute_post(Y_N, this->chk_to_var[frame_id]);\n+ this->_compute_post(Y_N, this->chk_to_var[frame_id], this->post);\nif (this->check_syndrome_soft(this->post.data()))\nbreak;\n}\n}\nif (ite == this->n_ite)\n- this->_compute_post(Y_N, this->chk_to_var[frame_id]);\n+ this->_compute_post(Y_N, this->chk_to_var[frame_id], this->post);\nthis->up_rule.end_decoding();\n}\ntemplate <typename B, typename R, class Update_rule>\nvoid Decoder_LDPC_BP_flooding<B,R,Update_rule>\n-::_decode_single_ite(const R *Y_N, std::vector<R> &var_to_chk, std::vector<R> &chk_to_var)\n+::_initialize_var_to_chk(const R *Y_N, const std::vector<R> &chk_to_var, std::vector<R> &var_to_chk)\n{\nauto *chk_to_var_ptr = chk_to_var.data();\nauto *var_to_chk_ptr = var_to_chk.data();\n- for (auto v = 0; v < this->n_var_nodes; v++)\n+ const auto n_var_nodes = (int)this->H.get_n_rows();;\n+ for (auto v = 0; v < n_var_nodes; v++)\n{\n- const auto var_degree = this->var_degrees[v];\n+ const auto var_degree = (int)this->H.get_row_to_cols()[v].size();\nauto sum_chk_to_var = (R)0;\nfor (auto c = 0; c < var_degree; c++)\n@@ -243,13 +213,19 @@ void Decoder_LDPC_BP_flooding<B,R,Update_rule>\nchk_to_var_ptr += var_degree;\nvar_to_chk_ptr += var_degree;\n}\n+}\n+template <typename B, typename R, class Update_rule>\n+void Decoder_LDPC_BP_flooding<B,R,Update_rule>\n+::_decode_single_ite(const std::vector<R> &var_to_chk, std::vector<R> &chk_to_var)\n+{\nauto transpose_ptr = this->transpose.data();\n// flooding scheduling\n- for (auto c = 0; c < this->n_chk_nodes; c++)\n+ const auto n_chk_nodes = (int)this->H.get_n_cols();\n+ for (auto c = 0; c < n_chk_nodes; c++)\n{\n- const auto chk_degree = this->chk_degrees[c];\n+ const auto chk_degree = (int)this->H.get_col_to_rows()[c].size();\nthis->up_rule.begin_chk_node_in(c, chk_degree);\nfor (auto v = 0; v < chk_degree; v++)\n@@ -264,5 +240,27 @@ void Decoder_LDPC_BP_flooding<B,R,Update_rule>\ntranspose_ptr += chk_degree;\n}\n}\n+\n+template <typename B, typename R, class Update_rule>\n+void Decoder_LDPC_BP_flooding<B,R,Update_rule>\n+::_compute_post(const R *Y_N, const std::vector<R> &chk_to_var, std::vector<R> &post)\n+{\n+ // compute the a posteriori info\n+ const auto *chk_to_var_ptr = chk_to_var.data();\n+ const auto n_var_nodes = (int)this->H.get_n_rows();;\n+ for (auto v = 0; v < n_var_nodes; v++)\n+ {\n+ const auto var_degree = (int)this->H.get_row_to_cols()[v].size();\n+\n+ auto sum_chk_to_var = (R)0;\n+ for (auto c = 0; c < var_degree; c++)\n+ sum_chk_to_var += chk_to_var_ptr[c];\n+\n+ // filling the output\n+ post[v] = Y_N[v] + sum_chk_to_var;\n+\n+ chk_to_var_ptr += var_degree;\n+ }\n+}\n}\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Flooding/Gallager/Decoder_LDPC_BP_flooding_Gallager_A.cpp",
"new_path": "src/Module/Decoder/LDPC/BP/Flooding/Gallager/Decoder_LDPC_BP_flooding_Gallager_A.cpp",
"diff": "#include <sstream>\n#include \"Tools/Exception/exception.hpp\"\n+#include \"Tools/Perf/common.h\"\n#include \"Tools/Math/utils.h\"\n#include \"Decoder_LDPC_BP_flooding_Gallager_A.hpp\"\n@@ -17,12 +18,11 @@ Decoder_LDPC_BP_flooding_Gallager_A<B,R>\nconst int syndrome_depth, const int n_frames)\n: Decoder (K, N, n_frames, 1),\nDecoder_LDPC_BP<B,R>(K, N, n_ite, H, enable_syndrome, syndrome_depth, n_frames, 1),\n- hard_decision (N ),\ninfo_bits_pos (info_bits_pos ),\nHY_N (N ),\nV_N (N ),\n- C_to_V_messages (H.get_n_connections(), 0 ),\n- V_to_C_messages (H.get_n_connections(), 0 )\n+ chk_to_var (H.get_n_connections(), 0 ),\n+ var_to_chk (H.get_n_connections(), 0 )\n{\nconst std::string name = \"Decoder_LDPC_BP_flooding_Gallager_A\";\nthis->set_name(name);\n@@ -30,28 +30,28 @@ Decoder_LDPC_BP_flooding_Gallager_A<B,R>\ntranspose.resize(H.get_n_connections());\nstd::vector<unsigned char> connections(H.get_n_rows(), 0);\n- const auto &CN_to_VN = H.get_col_to_rows();\n- const auto &VN_to_CN = H.get_row_to_cols();\n+ const auto &chk_to_var_id = H.get_col_to_rows();\n+ const auto &var_to_chk_id = H.get_row_to_cols();\nauto k = 0;\n- for (auto i = 0; i < (int)CN_to_VN.size(); i++)\n+ for (auto i = 0; i < (int)chk_to_var_id.size(); i++)\n{\n- for (auto j = 0; j < (int)CN_to_VN[i].size(); j++)\n+ for (auto j = 0; j < (int)chk_to_var_id[i].size(); j++)\n{\n- auto id_V = CN_to_VN[i][j];\n+ auto var_id = chk_to_var_id[i][j];\nauto branch_id = 0;\n- for (auto ii = 0; ii < (int)id_V; ii++)\n- branch_id += (int)VN_to_CN[ii].size();\n- branch_id += connections[id_V];\n- connections[id_V]++;\n+ for (auto ii = 0; ii < (int)var_id; ii++)\n+ branch_id += (int)var_to_chk_id[ii].size();\n+ branch_id += connections[var_id];\n+ connections[var_id]++;\n- if (connections[id_V] > (int)VN_to_CN[id_V].size())\n+ if (connections[var_id] > (int)var_to_chk_id[var_id].size())\n{\nstd::stringstream message;\n- message << \"'connections[id_V]' has to be equal or smaller than 'VN_to_CN[id_V].size()' \"\n- << \"('id_V' = \" << id_V << \", 'connections[id_V]' = \" << connections[id_V]\n- << \", 'VN_to_CN[id_V].size()' = \" << VN_to_CN[id_V].size() << \")'.\";\n+ message << \"'connections[var_id]' has to be equal or smaller than 'var_to_chk_id[var_id].size()' \"\n+ << \"('var_id' = \" << var_id << \", 'connections[var_id]' = \" << connections[var_id]\n+ << \", 'var_to_chk_id[var_id].size()' = \" << var_to_chk_id[var_id].size() << \").\";\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n@@ -67,104 +67,6 @@ Decoder_LDPC_BP_flooding_Gallager_A<B,R>\n{\n}\n-template <typename B, typename R>\n-void Decoder_LDPC_BP_flooding_Gallager_A<B,R>\n-::_decode(const B *Y_N)\n-{\n- for (auto ite = 0; ite < this->n_ite; ite++)\n- {\n- auto C_to_V_mess_ptr = C_to_V_messages.data();\n- auto V_to_C_mess_ptr = V_to_C_messages.data();\n-\n- // V -> C (for each variable nodes)\n- for (auto i = 0; i < (int)this->H.get_n_rows(); i++)\n- {\n- const auto node_degree = (int)this->H.get_row_to_cols()[i].size();\n-\n- for (auto j = 0; j < node_degree; j++)\n- {\n- auto cur_state = Y_N[i];\n- if (ite > 0)\n- {\n- auto count = 0;\n- for (auto k = 0; k < node_degree; k++)\n- if (k != j && C_to_V_mess_ptr[k] != cur_state)\n- count++;\n-\n- cur_state = count == (node_degree -1) ? !cur_state : cur_state;\n- }\n-\n- V_to_C_mess_ptr[j] = (int8_t)cur_state;\n- }\n-\n- C_to_V_mess_ptr += node_degree; // jump to the next node\n- V_to_C_mess_ptr += node_degree; // jump to the next node\n- }\n-\n- // C -> V (for each check nodes)\n- auto transpose_ptr = this->transpose.data();\n- for (auto i = 0; i < (int)this->H.get_n_cols(); i++)\n- {\n- const auto node_degree = (int)this->H.get_col_to_rows()[i].size();\n-\n- // accumulate the incoming information in CN\n- auto acc = 0;\n- for (auto j = 0; j < node_degree; j++)\n- acc ^= V_to_C_messages[transpose_ptr[j]];\n-\n- // regenerate the CN outcoming values\n- for (auto j = 0; j < node_degree; j++)\n- C_to_V_messages[transpose_ptr[j]] = acc ^ V_to_C_messages[transpose_ptr[j]];\n-\n- transpose_ptr += node_degree; // jump to the next node\n- }\n-\n- if (this->enable_syndrome && ite != this->n_ite -1)\n- {\n- auto C_to_V_ptr = C_to_V_messages.data();\n- // for the K variable nodes (make a majority vote with the entering messages)\n- for (auto i = 0; i < this->N; i++)\n- {\n- const auto node_degree = (int)this->H.get_row_to_cols()[i].size();\n- auto count = 0;\n-\n- for (auto j = 0; j < node_degree; j++)\n- count += C_to_V_ptr[j] ? 1 : -1;\n-\n- if (node_degree % 2 == 0)\n- count += Y_N[i] ? 1 : -1;\n-\n- // take the hard decision\n- this->V_N[i] = count > 0 ? 1 : 0;\n-\n- C_to_V_ptr += node_degree; // jump to the next node\n- }\n-\n- if (this->check_syndrome_hard(this->V_N.data()))\n- break;\n- }\n- }\n-\n- auto C_to_V_ptr = C_to_V_messages.data();\n- // for the K variable nodes (make a majority vote with the entering messages)\n- for (auto i = 0; i < this->N; i++)\n- {\n- const auto node_degree = (int)this->H.get_row_to_cols()[i].size();\n- auto count = 0;\n-\n- for (auto j = 0; j < node_degree; j++)\n- count += C_to_V_ptr[j] ? 1 : -1;\n-\n- if (node_degree % 2 == 0)\n- count += Y_N[i] ? 1 : -1;\n-\n- // take the hard decision\n- this->V_N[i] = count > 0 ? 1 : 0;\n-\n- C_to_V_ptr += node_degree; // jump to the next node\n- }\n-}\n-\ntemplate <typename B, typename R>\nvoid Decoder_LDPC_BP_flooding_Gallager_A<B,R>\n::_decode_hiho(const B *Y_N, B *V_K, const int frame_id)\n@@ -203,7 +105,7 @@ void Decoder_LDPC_BP_flooding_Gallager_A<B,R>\n::_decode_siho(const R *Y_N, B *V_K, const int frame_id)\n{\n// auto t_load = std::chrono::steady_clock::now(); // ---------------------------------------------------------- LOAD\n- hard_decision.decode_siho(Y_N, HY_N.data());\n+ tools::hard_decide(Y_N, HY_N.data(), this->N);\n// auto d_load = std::chrono::steady_clock::now() - t_load;\n// auto t_decod = std::chrono::steady_clock::now(); // -------------------------------------------------------- DECODE\n@@ -225,7 +127,7 @@ void Decoder_LDPC_BP_flooding_Gallager_A<B,R>\n::_decode_siho_cw(const R *Y_N, B *V_N, const int frame_id)\n{\n// auto t_load = std::chrono::steady_clock::now(); // ---------------------------------------------------------- LOAD\n- hard_decision.decode_siho(Y_N, HY_N.data());\n+ tools::hard_decide(Y_N, HY_N.data(), this->N);\n// auto d_load = std::chrono::steady_clock::now() - t_load;\n// auto t_decod = std::chrono::steady_clock::now(); // -------------------------------------------------------- DECODE\n@@ -241,6 +143,112 @@ void Decoder_LDPC_BP_flooding_Gallager_A<B,R>\n// (*this)[dec::tsk::decode_siho_cw].update_timer(dec::tm::decode_siho_cw::store, d_store);\n}\n+template <typename B, typename R>\n+void Decoder_LDPC_BP_flooding_Gallager_A<B,R>\n+::_decode(const B *Y_N)\n+{\n+ auto ite = 0;\n+ for (; ite < this->n_ite; ite++)\n+ {\n+ this->_initialize_var_to_chk(Y_N, chk_to_var, var_to_chk, ite == 0);\n+ this->_decode_single_ite(this->var_to_chk, this->chk_to_var);\n+\n+ if (this->enable_syndrome && ite != this->n_ite -1)\n+ {\n+ // for the K variable nodes (make a majority vote with the entering messages)\n+ this->_make_majority_vote(Y_N, this->V_N);\n+ if (this->check_syndrome_hard(this->V_N.data()))\n+ break;\n+ }\n+ }\n+ if (ite == this->n_ite)\n+ this->_make_majority_vote(Y_N, this->V_N);\n+}\n+\n+template <typename B, typename R>\n+void Decoder_LDPC_BP_flooding_Gallager_A<B,R>\n+::_initialize_var_to_chk(const B *Y_N, const std::vector<int8_t> &chk_to_var, std::vector<int8_t> &var_to_chk,\n+ const bool first_ite)\n+{\n+ auto chk_to_var_ptr = chk_to_var.data();\n+ auto var_to_chk_ptr = var_to_chk.data();\n+\n+ // for each variable nodes\n+ const auto n_var_nodes = (int)this->H.get_n_rows();\n+ for (auto v = 0; v < n_var_nodes; v++)\n+ {\n+ const auto var_degree = (int)this->H.get_row_to_cols()[v].size();\n+\n+ for (auto c = 0; c < var_degree; c++)\n+ {\n+ auto cur_state = Y_N[v];\n+ if (!first_ite)\n+ {\n+ auto count = 0;\n+ for (auto cc = 0; cc < var_degree; cc++)\n+ if (cc != c && chk_to_var_ptr[cc] != cur_state)\n+ count++;\n+\n+ cur_state = count == (var_degree -1) ? !cur_state : cur_state;\n+ }\n+\n+ var_to_chk_ptr[c] = (int8_t)cur_state;\n+ }\n+\n+ chk_to_var_ptr += var_degree;\n+ var_to_chk_ptr += var_degree;\n+ }\n+}\n+\n+template <typename B, typename R>\n+void Decoder_LDPC_BP_flooding_Gallager_A<B,R>\n+::_decode_single_ite(const std::vector<int8_t> &var_to_chk, std::vector<int8_t> &chk_to_var)\n+{\n+ auto transpose_ptr = this->transpose.data();\n+\n+ // for each check nodes\n+ const auto n_chk_nodes = (int)this->H.get_n_cols();\n+ for (auto c = 0; c < n_chk_nodes; c++)\n+ {\n+ const auto chk_degree = (int)this->H.get_col_to_rows()[c].size();\n+\n+ auto acc = 0;\n+ for (auto v = 0; v < chk_degree; v++)\n+ acc ^= var_to_chk[transpose_ptr[v]];\n+\n+ for (auto v = 0; v < chk_degree; v++)\n+ chk_to_var[transpose_ptr[v]] = acc ^ var_to_chk[transpose_ptr[v]];\n+\n+ transpose_ptr += chk_degree;\n+ }\n+}\n+\n+template <typename B, typename R>\n+void Decoder_LDPC_BP_flooding_Gallager_A<B,R>\n+::_make_majority_vote(const B *Y_N, std::vector<int8_t> &V_N)\n+{\n+ auto chk_to_var_ptr = this->chk_to_var.data();\n+\n+ // for the K variable nodes (make a majority vote with the entering messages)\n+ const auto n_var_nodes = (int)this->H.get_n_rows();\n+ for (auto v = 0; v < n_var_nodes; v++)\n+ {\n+ const auto var_degree = (int)this->H.get_row_to_cols()[v].size();\n+ auto count = 0;\n+\n+ for (auto c = 0; c < var_degree; c++)\n+ count += chk_to_var_ptr[c] ? 1 : -1;\n+\n+ if (var_degree % 2 == 0)\n+ count += Y_N[v] ? 1 : -1;\n+\n+ // take the hard decision\n+ V_N[v] = count > 0 ? 1 : 0;\n+\n+ chk_to_var_ptr += var_degree;\n+ }\n+}\n+\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Flooding/Gallager/Decoder_LDPC_BP_flooding_Gallager_A.hpp",
"new_path": "src/Module/Decoder/LDPC/BP/Flooding/Gallager/Decoder_LDPC_BP_flooding_Gallager_A.hpp",
"diff": "#include <cstdint>\n-#include \"Module/Decoder/NO/Decoder_NO.hpp\"\n-\n#include \"Tools/Algo/Sparse_matrix/Sparse_matrix.hpp\"\n#include \"Module/Decoder/LDPC/BP/Decoder_LDPC_BP.hpp\"\n@@ -16,15 +14,13 @@ namespace module\ntemplate <typename B = int, typename R = float>\nclass Decoder_LDPC_BP_flooding_Gallager_A : public Decoder_LDPC_BP<B,R>\n{\n-private:\n- Decoder_NO<B,R> hard_decision;\n-\nprotected:\n- const std::vector<unsigned> &info_bits_pos;\n+ const std::vector<uint32_t> &info_bits_pos;\n+\nstd::vector<B > HY_N; // input LLRs (transformed in bit)\nstd::vector<int8_t > V_N; // decoded bits\n- std::vector<int8_t> C_to_V_messages; // check nodes to variable nodes messages\n- std::vector<int8_t> V_to_C_messages; // variable nodes to check nodes messages\n+ std::vector<int8_t > chk_to_var; // check nodes to variable nodes messages\n+ std::vector<int8_t > var_to_chk; // variable nodes to check nodes messages\nstd::vector<unsigned> transpose;\npublic:\n@@ -36,11 +32,16 @@ public:\nvirtual ~Decoder_LDPC_BP_flooding_Gallager_A();\nprotected:\n- void _decode (const B *Y_N );\nvoid _decode_hiho (const B *Y_N, B *V_K, const int frame_id);\nvoid _decode_hiho_cw(const B *Y_N, B *V_K, const int frame_id);\nvoid _decode_siho (const R *Y_N, B *V_K, const int frame_id);\nvoid _decode_siho_cw(const R *Y_N, B *V_K, const int frame_id);\n+\n+ void _decode (const B *Y_N);\n+ void _initialize_var_to_chk(const B *Y_N, const std::vector<int8_t> &chk_to_var, std::vector<int8_t> &var_to_chk,\n+ const bool first_ite);\n+ void _decode_single_ite (const std::vector<int8_t> &var_to_chk, std::vector<int8_t> &chk_to_var);\n+ void _make_majority_vote (const B *Y_N, std::vector<int8_t> &V_N);\n};\ntemplate <typename B = int, typename R = float>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Layered/Decoder_LDPC_BP_layered.hpp",
"new_path": "src/Module/Decoder/LDPC/BP/Layered/Decoder_LDPC_BP_layered.hpp",
"diff": "@@ -14,8 +14,7 @@ template <typename B = int, typename R = float, class Update_rule = tools::Updat\nclass Decoder_LDPC_BP_layered : public Decoder_LDPC_BP<B,R>\n{\nprotected:\n- const int n_chk_nodes; // number of check nodes (N - K)\n- const std::vector<unsigned> &info_bits_pos;\n+ const std::vector<uint32_t> &info_bits_pos;\nUpdate_rule up_rule;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Layered/Decoder_LDPC_BP_layered.hxx",
"new_path": "src/Module/Decoder/LDPC/BP/Layered/Decoder_LDPC_BP_layered.hxx",
"diff": "@@ -23,7 +23,6 @@ Decoder_LDPC_BP_layered<B,R,Update_rule>\nconst int n_frames)\n: Decoder (K, N, n_frames, 1),\nDecoder_LDPC_BP<B,R>(K, N, n_ite, H, enable_syndrome, syndrome_depth, n_frames, 1),\n- n_chk_nodes ((int)H.get_n_cols() ),\ninfo_bits_pos (info_bits_pos ),\nup_rule (up_rule ),\nvar_nodes (n_frames, std::vector<R>(N ) ),\n@@ -133,7 +132,6 @@ void Decoder_LDPC_BP_layered<B,R,Update_rule>\n// (*this)[dec::tsk::decode_siho_cw].update_timer(dec::tm::decode_siho_cw::store, d_store);\n}\n-// BP algorithm\ntemplate <typename B, typename R, class Update_rule>\nvoid Decoder_LDPC_BP_layered<B,R,Update_rule>\n::_decode(const int frame_id)\n@@ -161,7 +159,8 @@ void Decoder_LDPC_BP_layered<B,R,Update_rule>\nauto kw = 0;\n// layered scheduling\n- for (auto c = 0; c < this->n_chk_nodes; c++)\n+ const auto n_chk_nodes = (int)this->H.get_n_cols();\n+ for (auto c = 0; c < n_chk_nodes; c++)\n{\nconst auto chk_degree = (int)this->H[c].size();\nthis->up_rule.begin_chk_node_in(c, chk_degree);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Sparse_matrix/Sparse_matrix.cpp",
"new_path": "src/Tools/Algo/Sparse_matrix/Sparse_matrix.cpp",
"diff": "#include <string>\n#include <sstream>\n#include <vector>\n-#include <algorithm>\n#include \"Tools/Exception/exception.hpp\"\n@@ -27,74 +26,6 @@ Sparse_matrix\n{\n}\n-unsigned Sparse_matrix\n-::get_n_rows() const\n-{\n- return this->n_rows;\n-}\n-\n-unsigned Sparse_matrix\n-::get_n_cols() const\n-{\n- return this->n_cols;\n-}\n-\n-unsigned Sparse_matrix\n-::get_rows_max_degree() const\n-{\n- return this->rows_max_degree;\n-}\n-\n-unsigned Sparse_matrix\n-::get_cols_max_degree() const\n-{\n- return this->cols_max_degree;\n-}\n-\n-unsigned Sparse_matrix\n-::get_n_connections() const\n-{\n- return this->n_connections;\n-}\n-\n-const std::vector<unsigned>& Sparse_matrix\n-::get_cols_from_row(const size_t row_index) const\n-{\n- return this->row_to_cols[row_index];\n-}\n-\n-const std::vector<unsigned>& Sparse_matrix\n-::get_rows_from_col(const size_t col_index) const\n-{\n- return this->col_to_rows[col_index];\n-}\n-\n-const std::vector<unsigned>& Sparse_matrix\n-::operator[](const size_t col_index) const\n-{\n- return this->get_rows_from_col(col_index);\n-}\n-\n-bool Sparse_matrix\n-::at(const size_t row_index, const size_t col_index) const\n-{\n- auto it = std::find(this->row_to_cols[row_index].begin(), this->row_to_cols[row_index].end(), col_index);\n-\n- return (it != this->row_to_cols[row_index].end());\n-}\n-\n-const std::vector<std::vector<unsigned int>>& Sparse_matrix\n-::get_row_to_cols() const\n-{\n- return this->row_to_cols;\n-}\n-\n-const std::vector<std::vector<unsigned int>>& Sparse_matrix\n-::get_col_to_rows() const\n-{\n- return this->col_to_rows;\n-}\n-\nvoid Sparse_matrix\n::add_connection(const size_t row_index, const size_t col_index)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Sparse_matrix/Sparse_matrix.hpp",
"new_path": "src/Tools/Algo/Sparse_matrix/Sparse_matrix.hpp",
"diff": "#include <vector>\n#include <string>\n+#include <algorithm>\nnamespace aff3ct\n{\n@@ -22,23 +23,64 @@ private:\npublic:\nSparse_matrix(const unsigned n_rows = 0, const unsigned n_cols = 1);\n+\nvirtual ~Sparse_matrix();\n- unsigned get_n_rows () const;\n- unsigned get_n_cols () const;\n- unsigned get_rows_max_degree() const;\n- unsigned get_cols_max_degree() const;\n- unsigned get_n_connections () const;\n+ inline unsigned get_n_rows() const\n+ {\n+ return this->n_rows;\n+ }\n- const std::vector<unsigned>& get_cols_from_row(const size_t row_index) const;\n- const std::vector<unsigned>& get_rows_from_col(const size_t col_index) const;\n+ inline unsigned get_n_cols() const\n+ {\n+ return this->n_cols;\n+ }\n- const std::vector<unsigned>& operator[](const size_t col_index) const;\n+ inline unsigned get_rows_max_degree() const\n+ {\n+ return this->rows_max_degree;\n+ }\n- bool at(const size_t row_index, const size_t col_index) const;\n+ inline unsigned get_cols_max_degree() const\n+ {\n+ return this->cols_max_degree;\n+ }\n+\n+ inline unsigned get_n_connections() const\n+ {\n+ return this->n_connections;\n+ }\n+\n+ const std::vector<unsigned>& get_cols_from_row(const size_t row_index) const\n+ {\n+ return this->row_to_cols[row_index];\n+ }\n- const std::vector<std::vector<unsigned int>>& get_row_to_cols() const;\n- const std::vector<std::vector<unsigned int>>& get_col_to_rows() const;\n+ const std::vector<unsigned>& get_rows_from_col(const size_t col_index) const\n+ {\n+ return this->col_to_rows[col_index];\n+ }\n+\n+ inline const std::vector<unsigned>& operator[](const size_t col_index) const\n+ {\n+ return this->get_rows_from_col(col_index);\n+ }\n+\n+ inline bool at(const size_t row_index, const size_t col_index) const\n+ {\n+ auto it = std::find(this->row_to_cols[row_index].begin(), this->row_to_cols[row_index].end(), col_index);\n+ return (it != this->row_to_cols[row_index].end());\n+ }\n+\n+ inline const std::vector<std::vector<unsigned>>& get_row_to_cols() const\n+ {\n+ return this->row_to_cols;\n+ }\n+\n+ inline const std::vector<std::vector<unsigned>>& get_col_to_rows() const\n+ {\n+ return this->col_to_rows;\n+ }\nvoid add_connection(const size_t row_index, const size_t col_index);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Refacto LDPC BP + clean GALA + improve Sparse_matrix perf. with inline.
|
8,490 |
08.05.2018 14:06:01
| -7,200 |
663d260b6bac22f9525ac4f76d7a9835e5ec2483
|
Add a new class dedicated to the LDPC syndrome checking.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Decoder_LDPC_BP.cpp",
"new_path": "src/Module/Decoder/LDPC/BP/Decoder_LDPC_BP.cpp",
"diff": "@@ -13,9 +13,7 @@ using namespace aff3ct::module;\ntemplate <typename B, typename R>\nDecoder_LDPC_BP<B,R>\n-::Decoder_LDPC_BP(const int K,\n- const int N,\n- const int n_ite,\n+::Decoder_LDPC_BP(const int K, const int N, const int n_ite,\nconst tools::Sparse_matrix &H,\nconst bool enable_syndrome,\nconst int syndrome_depth,\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Decoder_LDPC_BP.hpp",
"new_path": "src/Module/Decoder/LDPC/BP/Decoder_LDPC_BP.hpp",
"diff": "#define DECODER_LDPC_BP_HPP_\n#include \"Tools/Algo/Sparse_matrix/Sparse_matrix.hpp\"\n+#include \"Tools/Code/LDPC/Syndrome/LDPC_syndrome.hpp\"\n#include \"../../Decoder_SISO_SIHO.hpp\"\n@@ -21,9 +22,7 @@ protected:\nint cur_syndrome_depth;\npublic:\n- Decoder_LDPC_BP(const int K,\n- const int N,\n- const int n_ite,\n+ Decoder_LDPC_BP(const int K, const int N, const int n_ite,\nconst tools::Sparse_matrix &H,\nconst bool enable_syndrome = true,\nconst int syndrome_depth = 1,\n@@ -36,30 +35,11 @@ public:\n{\nif (this->enable_syndrome)\n{\n- auto syndrome = false;\n-\n- const auto n_CN = (int)this->H.get_n_cols();\n- for (auto i = 0; i < n_CN; i++)\n- {\n- auto sign = 0;\n-\n- const auto n_VN = (int)this->H[i].size();\n- for (auto j = 0; j < n_VN; j++)\n- {\n- const auto value = Y_N[this->H[i][j]];\n- const auto tmp_sign = std::signbit((float)value) ? -1 : 0;\n-\n- sign ^= tmp_sign;\n+ const auto syndrome = tools::LDPC_syndrome::check_soft(Y_N, this->H);\n+ this->cur_syndrome_depth = syndrome ? (this->cur_syndrome_depth +1) % this->syndrome_depth : 0;\n+ return syndrome && (this->cur_syndrome_depth == 0);\n}\n-\n- syndrome = syndrome || sign;\n- }\n-\n- this->cur_syndrome_depth = (syndrome == 0) ? (this->cur_syndrome_depth +1) % this->syndrome_depth : 0;\n-\n- return (syndrome == 0) && (this->cur_syndrome_depth == 0);\n- }\n-\n+ else\nreturn false;\n}\n@@ -68,30 +48,11 @@ public:\n{\nif (this->enable_syndrome)\n{\n- auto syndrome = false;\n-\n- const auto n_CN = (int)this->H.get_n_cols();\n- for (auto i = 0; i < n_CN; i++)\n- {\n- auto sign = 0;\n-\n- const auto n_VN = (int)this->H[i].size();\n- for (auto j = 0; j < n_VN; j++)\n- {\n- const auto bit = V_N[this->H[i][j]];\n- const auto tmp_sign = bit ? -1 : 0;\n-\n- sign ^= tmp_sign;\n+ const auto syndrome = tools::LDPC_syndrome::check_hard(V_N, this->H);\n+ this->cur_syndrome_depth = syndrome ? (this->cur_syndrome_depth +1) % this->syndrome_depth : 0;\n+ return syndrome && (this->cur_syndrome_depth == 0);\n}\n-\n- syndrome = syndrome || sign;\n- }\n-\n- this->cur_syndrome_depth = (syndrome == 0) ? (this->cur_syndrome_depth +1) % this->syndrome_depth : 0;\n-\n- return (syndrome == 0) && (this->cur_syndrome_depth == 0);\n- }\n-\n+ else\nreturn false;\n}\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/From_H/Encoder_LDPC_from_H.cpp",
"new_path": "src/Module/Encoder/LDPC/From_H/Encoder_LDPC_from_H.cpp",
"diff": "#include <functional>\n#include <sstream>\n+#include \"Tools/Code/LDPC/Syndrome/LDPC_syndrome.hpp\"\n#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/Math/matrix.h\"\n@@ -61,28 +62,7 @@ template <typename B>\nbool Encoder_LDPC_from_H<B>\n::is_codeword(const B *X_N)\n{\n- auto syndrome = false;\n-\n- const auto n_CN = (int)this->H.get_n_cols();\n- auto i = 0;\n- while (i < n_CN && !syndrome)\n- {\n- auto sign = 0;\n-\n- const auto n_VN = (int)this->H[i].size();\n- for (auto j = 0; j < n_VN; j++)\n- {\n- const auto bit = X_N[this->H[i][j]];\n- const auto tmp_sign = bit ? -1 : 0;\n-\n- sign ^= tmp_sign;\n- }\n-\n- syndrome = syndrome || sign;\n- i++;\n- }\n-\n- return !syndrome;\n+ return tools::LDPC_syndrome::check_hard(X_N, this->H);\n}\ntemplate <typename B>\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Code/LDPC/Syndrome/LDPC_syndrome.hpp",
"diff": "+#ifndef LDPC_SYNDROME_HPP_\n+#define LDPC_SYNDROME_HPP_\n+\n+#include <vector>\n+\n+#include \"Tools/Algo/Sparse_matrix/Sparse_matrix.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+struct LDPC_syndrome\n+{\n+public:\n+ template <typename B>\n+ static inline bool check_hard(const std::vector<B> &X_N, const Sparse_matrix &H);\n+\n+ template <typename B>\n+ static inline bool check_hard(const B *X_N, const Sparse_matrix &H);\n+\n+ template <typename R>\n+ static inline bool check_soft(const std::vector<R> &Y_N, const Sparse_matrix &H);\n+\n+ template <typename R>\n+ static inline bool check_soft(const R *Y_N, const Sparse_matrix &H);\n+};\n+}\n+}\n+\n+#include \"LDPC_syndrome.hxx\"\n+\n+#endif /* LDPC_SYNDROME_HPP_ */\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Code/LDPC/Syndrome/LDPC_syndrome.hxx",
"diff": "+#include \"LDPC_syndrome.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+\n+template <typename B>\n+bool LDPC_syndrome\n+::check_hard(const B *X_N, const Sparse_matrix &H)\n+{\n+ auto syndrome = false;\n+\n+ const auto n_chk_nodes = (int)H.get_n_cols();\n+ auto c = 0;\n+ while (c < n_chk_nodes && !syndrome)\n+ {\n+ auto sign = 0;\n+\n+ const auto chk_degree = (int)H[c].size();\n+ for (auto v = 0; v < chk_degree; v++)\n+ {\n+ const auto bit = X_N[H[c][v]];\n+ const auto tmp_sign = bit ? -1 : 0;\n+\n+ sign ^= tmp_sign;\n+ }\n+\n+ syndrome = syndrome || sign;\n+ c++;\n+ }\n+\n+ return !syndrome;\n+}\n+\n+template <typename B>\n+bool LDPC_syndrome\n+::check_hard(const std::vector<B> &X_N, const Sparse_matrix &H)\n+{\n+ return LDPC_syndrome::check_hard<B>(X_N.data(), H);\n+}\n+\n+template <typename R>\n+bool LDPC_syndrome\n+::check_soft(const R *Y_N, const Sparse_matrix &H)\n+{\n+ auto syndrome = false;\n+\n+ const auto n_chk_nodes = (int)H.get_n_cols();\n+ auto c = 0;\n+ while (c < n_chk_nodes && !syndrome)\n+ {\n+ auto sign = 0;\n+\n+ const auto chk_degree = (int)H[c].size();\n+ for (auto v = 0; v < chk_degree; v++)\n+ {\n+ const auto llr = Y_N[H[c][v]];\n+ const auto tmp_sign = (llr < 0) ? -1 : 0;\n+\n+ sign ^= tmp_sign;\n+ }\n+\n+ syndrome = syndrome || sign;\n+ c++;\n+ }\n+\n+ return !syndrome;\n+}\n+\n+template <typename R>\n+bool LDPC_syndrome\n+::check_soft(const std::vector<R> &Y_N, const Sparse_matrix &H)\n+{\n+ return LDPC_syndrome::check_soft<R>(Y_N.data(), H);\n+}\n+\n+}\n+}\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a new class dedicated to the LDPC syndrome checking.
|
8,490 |
08.05.2018 14:57:01
| -7,200 |
e73f590398574e07bacbdee1547302aa6d6324c3
|
Refacto LDPC BP + add decoder HIHO interface to GALA.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Decoder_LDPC_BP.cpp",
"new_path": "src/Module/Decoder/LDPC/BP/Decoder_LDPC_BP.cpp",
"diff": "-#include <chrono>\n-#include <limits>\n-#include <cmath>\n-#include <stdexcept>\n+#include <sstream>\n-#include \"Tools/Perf/common.h\"\n-#include \"Tools/Math/utils.h\"\n+#include \"Tools/Exception/exception.hpp\"\n#include \"Decoder_LDPC_BP.hpp\"\nusing namespace aff3ct;\nusing namespace aff3ct::module;\n-template <typename B, typename R>\n-Decoder_LDPC_BP<B,R>\n+Decoder_LDPC_BP\n::Decoder_LDPC_BP(const int K, const int N, const int n_ite,\nconst tools::Sparse_matrix &H,\nconst bool enable_syndrome,\n- const int syndrome_depth,\n- const int n_frames,\n- const int simd_inter_frame_level)\n-: Decoder (K, N, n_frames, simd_inter_frame_level),\n- Decoder_SISO_SIHO<B,R>(K, N, n_frames, simd_inter_frame_level),\n- n_ite (n_ite ),\n+ const int syndrome_depth)\n+: n_ite (n_ite ),\nH (H ),\nenable_syndrome (enable_syndrome),\nsyndrome_depth (syndrome_depth ),\ncur_syndrome_depth(0 )\n{\n- const std::string name = \"Decoder_LDPC_BP\";\n- this->set_name(name);\n-\nif (n_ite <= 0)\n{\nstd::stringstream message;\n@@ -53,20 +41,7 @@ Decoder_LDPC_BP<B,R>\n}\n}\n-template <typename B, typename R>\n-Decoder_LDPC_BP<B,R>\n+Decoder_LDPC_BP\n::~Decoder_LDPC_BP()\n{\n}\n\\ No newline at end of file\n-\n-// ==================================================================================== explicit template instantiation\n-#include \"Tools/types.h\"\n-#ifdef MULTI_PREC\n-template class aff3ct::module::Decoder_LDPC_BP<B_8,Q_8>;\n-template class aff3ct::module::Decoder_LDPC_BP<B_16,Q_16>;\n-template class aff3ct::module::Decoder_LDPC_BP<B_32,Q_32>;\n-template class aff3ct::module::Decoder_LDPC_BP<B_64,Q_64>;\n-#else\n-template class aff3ct::module::Decoder_LDPC_BP<B,Q>;\n-#endif\n-// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Decoder_LDPC_BP.hpp",
"new_path": "src/Module/Decoder/LDPC/BP/Decoder_LDPC_BP.hpp",
"diff": "#include \"Tools/Algo/Sparse_matrix/Sparse_matrix.hpp\"\n#include \"Tools/Code/LDPC/Syndrome/LDPC_syndrome.hpp\"\n-#include \"../../Decoder_SISO_SIHO.hpp\"\n-\nnamespace aff3ct\n{\nnamespace module\n{\n-template <typename B = int, typename R = float>\n-class Decoder_LDPC_BP : public Decoder_SISO_SIHO<B,R>\n+class Decoder_LDPC_BP\n{\nprotected:\nconst int n_ite;\n@@ -25,13 +22,12 @@ public:\nDecoder_LDPC_BP(const int K, const int N, const int n_ite,\nconst tools::Sparse_matrix &H,\nconst bool enable_syndrome = true,\n- const int syndrome_depth = 1,\n- const int n_frames = 1,\n- const int simd_inter_frame_level = 1);\n+ const int syndrome_depth = 1);\n+\nvirtual ~Decoder_LDPC_BP();\n- template <typename T>\n- inline bool check_syndrome_soft(const T* Y_N)\n+ template <typename R>\n+ inline bool check_syndrome_soft(const R* Y_N)\n{\nif (this->enable_syndrome)\n{\n@@ -43,8 +39,8 @@ public:\nreturn false;\n}\n- template <typename T>\n- inline bool check_syndrome_hard(const T* V_N)\n+ template <typename B>\n+ inline bool check_syndrome_hard(const B* V_N)\n{\nif (this->enable_syndrome)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Flooding/Decoder_LDPC_BP_flooding.hpp",
"new_path": "src/Module/Decoder/LDPC/BP/Flooding/Decoder_LDPC_BP_flooding.hpp",
"diff": "#include \"Tools/Algo/Sparse_matrix/Sparse_matrix.hpp\"\n#include \"Tools/Code/LDPC/Update_rule/SPA/Update_rule_SPA.hpp\"\n+#include \"../../../Decoder_SISO_SIHO.hpp\"\n#include \"../Decoder_LDPC_BP.hpp\"\nnamespace aff3ct\n@@ -11,7 +12,7 @@ namespace aff3ct\nnamespace module\n{\ntemplate <typename B = int, typename R = float, class Update_rule = tools::Update_rule_SPA<R>>\n-class Decoder_LDPC_BP_flooding : public Decoder_LDPC_BP<B,R>\n+class Decoder_LDPC_BP_flooding : public Decoder_SISO_SIHO<B,R>, public Decoder_LDPC_BP\n{\nprotected:\nconst std::vector<uint32_t> &info_bits_pos;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Flooding/Decoder_LDPC_BP_flooding.hxx",
"new_path": "src/Module/Decoder/LDPC/BP/Flooding/Decoder_LDPC_BP_flooding.hxx",
"diff": "@@ -22,7 +22,8 @@ Decoder_LDPC_BP_flooding<B,R,Update_rule>\nconst int syndrome_depth,\nconst int n_frames)\n: Decoder (K, N, n_frames, 1 ),\n- Decoder_LDPC_BP<B,R>(K, N, n_ite, H, enable_syndrome, syndrome_depth, n_frames, 1),\n+ Decoder_SISO_SIHO<B,R>(K, N, n_frames, 1 ),\n+ Decoder_LDPC_BP (K, N, n_ite, H, enable_syndrome, syndrome_depth),\ninfo_bits_pos (info_bits_pos ),\nup_rule (up_rule ),\ntranspose (H.get_n_connections() ),\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Flooding/Gallager/Decoder_LDPC_BP_flooding_Gallager_A.cpp",
"new_path": "src/Module/Decoder/LDPC/BP/Flooding/Gallager/Decoder_LDPC_BP_flooding_Gallager_A.cpp",
"diff": "@@ -17,7 +17,8 @@ Decoder_LDPC_BP_flooding_Gallager_A<B,R>\nconst std::vector<unsigned> &info_bits_pos, const bool enable_syndrome,\nconst int syndrome_depth, const int n_frames)\n: Decoder (K, N, n_frames, 1 ),\n- Decoder_LDPC_BP<B,R>(K, N, n_ite, H, enable_syndrome, syndrome_depth, n_frames, 1),\n+ Decoder_SIHO_HIHO<B,R>(K, N, n_frames, 1 ),\n+ Decoder_LDPC_BP (K, N, n_ite, H, enable_syndrome, syndrome_depth),\ninfo_bits_pos (info_bits_pos ),\nHY_N (N ),\nV_N (N ),\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Flooding/Gallager/Decoder_LDPC_BP_flooding_Gallager_A.hpp",
"new_path": "src/Module/Decoder/LDPC/BP/Flooding/Gallager/Decoder_LDPC_BP_flooding_Gallager_A.hpp",
"diff": "#include \"Tools/Algo/Sparse_matrix/Sparse_matrix.hpp\"\n-#include \"Module/Decoder/LDPC/BP/Decoder_LDPC_BP.hpp\"\n+#include \"../../../../Decoder_SIHO_HIHO.hpp\"\n+#include \"../../Decoder_LDPC_BP.hpp\"\nnamespace aff3ct\n{\nnamespace module\n{\ntemplate <typename B = int, typename R = float>\n-class Decoder_LDPC_BP_flooding_Gallager_A : public Decoder_LDPC_BP<B,R>\n+class Decoder_LDPC_BP_flooding_Gallager_A : public Decoder_SIHO_HIHO<B,R>, public Decoder_LDPC_BP\n{\nprotected:\nconst std::vector<uint32_t> &info_bits_pos;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Layered/Decoder_LDPC_BP_layered.hpp",
"new_path": "src/Module/Decoder/LDPC/BP/Layered/Decoder_LDPC_BP_layered.hpp",
"diff": "#include \"Tools/Algo/Sparse_matrix/Sparse_matrix.hpp\"\n#include \"Tools/Code/LDPC/Update_rule/SPA/Update_rule_SPA.hpp\"\n+#include \"../../../Decoder_SISO_SIHO.hpp\"\n#include \"../Decoder_LDPC_BP.hpp\"\nnamespace aff3ct\n@@ -11,7 +12,7 @@ namespace aff3ct\nnamespace module\n{\ntemplate <typename B = int, typename R = float, class Update_rule = tools::Update_rule_SPA<R>>\n-class Decoder_LDPC_BP_layered : public Decoder_LDPC_BP<B,R>\n+class Decoder_LDPC_BP_layered : public Decoder_SISO_SIHO<B,R>, public Decoder_LDPC_BP\n{\nprotected:\nconst std::vector<uint32_t> &info_bits_pos;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Layered/Decoder_LDPC_BP_layered.hxx",
"new_path": "src/Module/Decoder/LDPC/BP/Layered/Decoder_LDPC_BP_layered.hxx",
"diff": "@@ -22,7 +22,8 @@ Decoder_LDPC_BP_layered<B,R,Update_rule>\nconst int syndrome_depth,\nconst int n_frames)\n: Decoder (K, N, n_frames, 1 ),\n- Decoder_LDPC_BP<B,R>(K, N, n_ite, H, enable_syndrome, syndrome_depth, n_frames, 1),\n+ Decoder_SISO_SIHO<B,R>(K, N, n_frames, 1 ),\n+ Decoder_LDPC_BP (K, N, n_ite, H, enable_syndrome, syndrome_depth),\ninfo_bits_pos (info_bits_pos ),\nup_rule (up_rule ),\nvar_nodes (n_frames, std::vector<R>(N )),\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Layered/ONMS/Decoder_LDPC_BP_layered_ONMS_inter.cpp",
"new_path": "src/Module/Decoder/LDPC/BP/Layered/ONMS/Decoder_LDPC_BP_layered_ONMS_inter.cpp",
"diff": "@@ -24,7 +24,8 @@ Decoder_LDPC_BP_layered_ONMS_inter<B,R>\nconst int syndrome_depth,\nconst int n_frames)\n: Decoder (K, N, n_frames, mipp::nElReg<R>() ),\n- Decoder_LDPC_BP<B,R> (K, N, n_ite, H, enable_syndrome, syndrome_depth, n_frames, mipp::nElReg<R>() ),\n+ Decoder_SISO_SIHO<B,R>(K, N, n_frames, mipp::nElReg<R>() ),\n+ Decoder_LDPC_BP (K, N, n_ite, H, enable_syndrome, syndrome_depth ),\nnormalize_factor (normalize_factor ),\noffset (offset ),\ncontributions (H.get_cols_max_degree() ),\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Layered/ONMS/Decoder_LDPC_BP_layered_ONMS_inter.hpp",
"new_path": "src/Module/Decoder/LDPC/BP/Layered/ONMS/Decoder_LDPC_BP_layered_ONMS_inter.hpp",
"diff": "#include \"Tools/Algo/Sparse_matrix/Sparse_matrix.hpp\"\n+#include \"../../../../Decoder_SISO_SIHO.hpp\"\n#include \"../../Decoder_LDPC_BP.hpp\"\nnamespace aff3ct\n@@ -12,7 +13,7 @@ namespace aff3ct\nnamespace module\n{\ntemplate <typename B = int, typename R = float>\n-class Decoder_LDPC_BP_layered_ONMS_inter : public Decoder_LDPC_BP<B,R>\n+class Decoder_LDPC_BP_layered_ONMS_inter : public Decoder_SISO_SIHO<B,R>, public Decoder_LDPC_BP\n{\nprivate:\nconst float normalize_factor;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Refacto LDPC BP + add decoder HIHO interface to GALA.
|
8,490 |
08.05.2018 16:13:44
| -7,200 |
69c90a0bbe89b0bc52a58b62f43c6e6e46f90101
|
Refacto LDPC BP ONMS inter frame.
|
[
{
"change_type": "MODIFY",
"old_path": "refs",
"new_path": "refs",
"diff": "-Subproject commit 9e9cb5c9dc4ad62609d80a5a73f6ba36cad2819a\n+Subproject commit ab0f3d812bbe385ce9d454489819a6b167f68d9a\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.cpp",
"new_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.cpp",
"diff": "@@ -61,7 +61,7 @@ void Decoder_LDPC::parameters\ntools::add_options(args.at({p+\"-type\", \"D\"}), 0, \"BP_FLOODING\", \"BP_LAYERED\");\n- tools::add_options(args.at({p+\"-implem\" }), 0, \"SPA\", \"LSPA\", \"MS\", \"OMS\", \"NMS\", \"ONMS\", \"AMS\", \"GALA\");\n+ tools::add_options(args.at({p+\"-implem\" }), 0, \"SPA\", \"LSPA\", \"MS\", \"OMS\", \"NMS\", \"AMS\", \"GALA\");\nargs.add(\n{p+\"-ite\", \"i\"},\n@@ -71,12 +71,12 @@ void Decoder_LDPC::parameters\nargs.add(\n{p+\"-off\"},\ntools::Real(),\n- \"offset used in the offset min-sum BP algorithm (works only with \\\"--dec-implem ONMS\\\").\");\n+ \"offset used in the offset min-sum BP algorithm (works only with \\\"--dec-implem NMS\\\").\");\nargs.add(\n{p+\"-norm\"},\ntools::Real(tools::Positive()),\n- \"normalization factor used in the normalized min-sum BP algorithm (works only with \\\"--dec-implem ONMS\\\").\");\n+ \"normalization factor used in the normalized min-sum BP algorithm (works only with \\\"--dec-implem NMS\\\").\");\nargs.add(\n{p+\"-no-synd\"},\n@@ -150,10 +150,10 @@ void Decoder_LDPC::parameters\nheaders[p].push_back(std::make_pair(\"Num. of iterations (i)\", std::to_string(this->n_ite)));\n- if (this->implem == \"NMS\" || this->implem == \"ONMS\")\n+ if (this->implem == \"NMS\")\nheaders[p].push_back(std::make_pair(\"Normalize factor\", std::to_string(this->norm_factor)));\n- if (this->implem == \"OMS\" || this->implem == \"ONMS\")\n+ if (this->implem == \"OMS\")\nheaders[p].push_back(std::make_pair(\"Offset\", std::to_string(this->offset)));\nstd::string syndrome = this->enable_syndrome ? \"on\" : \"off\";\n@@ -206,7 +206,8 @@ module::Decoder_SISO_SIHO<B,Q>* Decoder_LDPC::parameters\n}\nelse if (this->type == \"BP_LAYERED\" && this->simd_strategy == \"INTER\")\n{\n- if (this->implem == \"ONMS\") return new module::Decoder_LDPC_BP_layered_ONMS_inter<B,Q>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, this->norm_factor, (Q)this->offset, this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ if (this->implem == \"NMS\") return new module::Decoder_LDPC_BP_layered_ONMS_inter<B,Q>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, this->norm_factor, (Q)0 , this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->implem == \"OMS\") return new module::Decoder_LDPC_BP_layered_ONMS_inter<B,Q>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, 1.f , (Q)this->offset, this->enable_syndrome, this->syndrome_depth, this->n_frames);\n}\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Layered/ONMS/Decoder_LDPC_BP_layered_ONMS_inter.cpp",
"new_path": "src/Module/Decoder/LDPC/BP/Layered/ONMS/Decoder_LDPC_BP_layered_ONMS_inter.cpp",
"diff": "@@ -23,14 +23,13 @@ Decoder_LDPC_BP_layered_ONMS_inter<B,R>\nconst bool enable_syndrome,\nconst int syndrome_depth,\nconst int n_frames)\n-: Decoder (K, N, n_frames, mipp::nElReg<R>() ),\n- Decoder_SISO_SIHO<B,R>(K, N, n_frames, mipp::nElReg<R>() ),\n+: Decoder (K, N, n_frames, mipp::N<R>() ),\n+ Decoder_SISO_SIHO<B,R>(K, N, n_frames, mipp::N<R>() ),\nDecoder_LDPC_BP (K, N, n_ite, H, enable_syndrome, syndrome_depth ),\nnormalize_factor (normalize_factor ),\noffset (offset ),\ncontributions (H.get_cols_max_degree() ),\nsaturation ((R)((1 << ((sizeof(R) * 8 -2) - (int)std::log2(H.get_rows_max_degree()))) -1)),\n- n_C_nodes ((int)H.get_n_cols() ),\ninit_flag (true ),\ninfo_bits_pos (info_bits_pos ),\nvar_nodes (this->n_dec_waves, mipp::vector<mipp::Reg<R>>(N) ),\n@@ -81,9 +80,9 @@ void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\nif (cur_wave == this->n_dec_waves -1) this->init_flag = false;\n}\n- std::vector<const R*> frames(mipp::nElReg<R>());\n- for (auto f = 0; f < mipp::nElReg<R>(); f++) frames[f] = Y_N + f * this->N;\n- tools::Reorderer_static<R,mipp::nElReg<R>()>::apply(frames, (R*)this->Y_N_reorderered.data(), this->N);\n+ std::vector<const R*> frames(mipp::N<R>());\n+ for (auto f = 0; f < mipp::N<R>(); f++) frames[f] = Y_N + f * this->N;\n+ tools::Reorderer_static<R,mipp::N<R>()>::apply(frames, (R*)this->Y_N_reorderered.data(), this->N);\nfor (auto i = 0; i < (int)var_nodes[cur_wave].size(); i++)\nthis->var_nodes[cur_wave][i] += this->Y_N_reorderered[i]; // var_nodes contain previous extrinsic information\n@@ -99,14 +98,14 @@ void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n// actual decoding\nif (typeid(R) == typeid(short) || typeid(R) == typeid(signed char))\n{\n- if (normalize_factor == 0.125f) this->BP_decode<1>(frame_id);\n- else if (normalize_factor == 0.250f) this->BP_decode<2>(frame_id);\n- else if (normalize_factor == 0.375f) this->BP_decode<3>(frame_id);\n- else if (normalize_factor == 0.500f) this->BP_decode<4>(frame_id);\n- else if (normalize_factor == 0.625f) this->BP_decode<5>(frame_id);\n- else if (normalize_factor == 0.750f) this->BP_decode<6>(frame_id);\n- else if (normalize_factor == 0.875f) this->BP_decode<7>(frame_id);\n- else if (normalize_factor == 1.000f) this->BP_decode<8>(frame_id);\n+ if (normalize_factor == 0.125f) this->_decode<1>(frame_id);\n+ else if (normalize_factor == 0.250f) this->_decode<2>(frame_id);\n+ else if (normalize_factor == 0.375f) this->_decode<3>(frame_id);\n+ else if (normalize_factor == 0.500f) this->_decode<4>(frame_id);\n+ else if (normalize_factor == 0.625f) this->_decode<5>(frame_id);\n+ else if (normalize_factor == 0.750f) this->_decode<6>(frame_id);\n+ else if (normalize_factor == 0.875f) this->_decode<7>(frame_id);\n+ else if (normalize_factor == 1.000f) this->_decode<8>(frame_id);\nelse\n{\nstd::stringstream message;\n@@ -117,18 +116,18 @@ void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n}\nelse // float or double\n{\n- if (normalize_factor == 1.000f) this->BP_decode<8>(frame_id);\n- else this->BP_decode<0>(frame_id);\n+ if (normalize_factor == 1.000f) this->_decode<8>(frame_id);\n+ else this->_decode<0>(frame_id);\n}\n// prepare for next round by processing extrinsic information\nconst auto cur_wave = frame_id / this->simd_inter_frame_level;\n- for (auto i = 0; i < this->N; i++)\n- this->var_nodes[cur_wave][i] -= Y_N_reorderered[i];\n+ for (auto v = 0; v < this->N; v++)\n+ this->var_nodes[cur_wave][v] -= Y_N_reorderered[v];\n- std::vector<R*> frames(mipp::nElReg<R>());\n- for (auto f = 0; f < mipp::nElReg<R>(); f++) frames[f] = Y_N2 + f * this->N;\n- tools::Reorderer_static<R,mipp::nElReg<R>()>::apply_rev((R*)this->var_nodes[cur_wave].data(), frames, this->N);\n+ std::vector<R*> frames(mipp::N<R>());\n+ for (auto f = 0; f < mipp::N<R>(); f++) frames[f] = Y_N2 + f * this->N;\n+ tools::Reorderer_static<R,mipp::N<R>()>::apply_rev((R*)this->var_nodes[cur_wave].data(), frames, this->N);\n}\ntemplate <typename B, typename R>\n@@ -143,14 +142,14 @@ void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n// actual decoding\nif (typeid(R) == typeid(short) || typeid(R) == typeid(signed char))\n{\n- if (normalize_factor == 0.125f) this->BP_decode<1>(frame_id);\n- else if (normalize_factor == 0.250f) this->BP_decode<2>(frame_id);\n- else if (normalize_factor == 0.375f) this->BP_decode<3>(frame_id);\n- else if (normalize_factor == 0.500f) this->BP_decode<4>(frame_id);\n- else if (normalize_factor == 0.625f) this->BP_decode<5>(frame_id);\n- else if (normalize_factor == 0.750f) this->BP_decode<6>(frame_id);\n- else if (normalize_factor == 0.875f) this->BP_decode<7>(frame_id);\n- else if (normalize_factor == 1.000f) this->BP_decode<8>(frame_id);\n+ if (normalize_factor == 0.125f) this->_decode<1>(frame_id);\n+ else if (normalize_factor == 0.250f) this->_decode<2>(frame_id);\n+ else if (normalize_factor == 0.375f) this->_decode<3>(frame_id);\n+ else if (normalize_factor == 0.500f) this->_decode<4>(frame_id);\n+ else if (normalize_factor == 0.625f) this->_decode<5>(frame_id);\n+ else if (normalize_factor == 0.750f) this->_decode<6>(frame_id);\n+ else if (normalize_factor == 0.875f) this->_decode<7>(frame_id);\n+ else if (normalize_factor == 1.000f) this->_decode<8>(frame_id);\nelse\n{\nstd::stringstream message;\n@@ -161,8 +160,8 @@ void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n}\nelse // float or double\n{\n- if (normalize_factor == 1.000f) this->BP_decode<8>(frame_id);\n- else this->BP_decode<0>(frame_id);\n+ if (normalize_factor == 1.000f) this->_decode<8>(frame_id);\n+ else this->_decode<0>(frame_id);\n}\n// auto d_decod = std::chrono::steady_clock::now() - t_decod;\n@@ -176,9 +175,9 @@ void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\nV_reorderered[i] = mipp::cast<R,B>(this->var_nodes[cur_wave][k]) >> (sizeof(B) * 8 - 1);\n}\n- std::vector<B*> frames(mipp::nElReg<R>());\n- for (auto f = 0; f < mipp::nElReg<R>(); f++) frames[f] = V_K + f * this->K;\n- tools::Reorderer_static<B,mipp::nElReg<R>()>::apply_rev((B*)V_reorderered.data(), frames, this->K);\n+ std::vector<B*> frames(mipp::N<R>());\n+ for (auto f = 0; f < mipp::N<R>(); f++) frames[f] = V_K + f * this->K;\n+ tools::Reorderer_static<B,mipp::N<R>()>::apply_rev((B*)V_reorderered.data(), frames, this->K);\n// auto d_store = std::chrono::steady_clock::now() - t_store;\n// (*this)[dec::tsk::decode_siho].update_timer(dec::tm::decode_siho::load, d_load);\n@@ -198,14 +197,14 @@ void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n// actual decoding\nif (typeid(R) == typeid(short) || typeid(R) == typeid(signed char))\n{\n- if (normalize_factor == 0.125f) this->BP_decode<1>(frame_id);\n- else if (normalize_factor == 0.250f) this->BP_decode<2>(frame_id);\n- else if (normalize_factor == 0.375f) this->BP_decode<3>(frame_id);\n- else if (normalize_factor == 0.500f) this->BP_decode<4>(frame_id);\n- else if (normalize_factor == 0.625f) this->BP_decode<5>(frame_id);\n- else if (normalize_factor == 0.750f) this->BP_decode<6>(frame_id);\n- else if (normalize_factor == 0.875f) this->BP_decode<7>(frame_id);\n- else if (normalize_factor == 1.000f) this->BP_decode<8>(frame_id);\n+ if (normalize_factor == 0.125f) this->_decode<1>(frame_id);\n+ else if (normalize_factor == 0.250f) this->_decode<2>(frame_id);\n+ else if (normalize_factor == 0.375f) this->_decode<3>(frame_id);\n+ else if (normalize_factor == 0.500f) this->_decode<4>(frame_id);\n+ else if (normalize_factor == 0.625f) this->_decode<5>(frame_id);\n+ else if (normalize_factor == 0.750f) this->_decode<6>(frame_id);\n+ else if (normalize_factor == 0.875f) this->_decode<7>(frame_id);\n+ else if (normalize_factor == 1.000f) this->_decode<8>(frame_id);\nelse\n{\nstd::stringstream message;\n@@ -216,8 +215,8 @@ void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n}\nelse // float or double\n{\n- if (normalize_factor == 1.000f) this->BP_decode<8>(frame_id);\n- else this->BP_decode<0>(frame_id);\n+ if (normalize_factor == 1.000f) this->_decode<8>(frame_id);\n+ else this->_decode<0>(frame_id);\n}\n// auto d_decod = std::chrono::steady_clock::now() - t_decod;\n@@ -225,12 +224,12 @@ void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n// take the hard decision\nconst auto cur_wave = frame_id / this->simd_inter_frame_level;\nconst auto zero = mipp::Reg<R>((R)0);\n- for (auto i = 0; i < this->N; i++)\n- V_reorderered[i] = mipp::cast<R,B>(this->var_nodes[cur_wave][i]) >> (sizeof(B) * 8 - 1);\n+ for (auto v = 0; v < this->N; v++)\n+ V_reorderered[v] = mipp::cast<R,B>(this->var_nodes[cur_wave][v]) >> (sizeof(B) * 8 - 1);\n- std::vector<B*> frames(mipp::nElReg<R>());\n- for (auto f = 0; f < mipp::nElReg<R>(); f++) frames[f] = V_N + f * this->N;\n- tools::Reorderer_static<B,mipp::nElReg<R>()>::apply_rev((B*)V_reorderered.data(), frames, this->N);\n+ std::vector<B*> frames(mipp::N<R>());\n+ for (auto f = 0; f < mipp::N<R>(); f++) frames[f] = V_N + f * this->N;\n+ tools::Reorderer_static<B,mipp::N<R>()>::apply_rev((B*)V_reorderered.data(), frames, this->N);\n// auto d_store = std::chrono::steady_clock::now() - t_store;\n// (*this)[dec::tsk::decode_siho_cw].update_timer(dec::tm::decode_siho_cw::load, d_load);\n@@ -238,11 +237,10 @@ void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n// (*this)[dec::tsk::decode_siho_cw].update_timer(dec::tm::decode_siho_cw::store, d_store);\n}\n-// BP algorithm\ntemplate <typename B, typename R>\ntemplate <int F>\nvoid Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n-::BP_decode(const int frame_id)\n+::_decode(const int frame_id)\n{\nconst auto cur_wave = frame_id / this->simd_inter_frame_level;\n@@ -250,10 +248,10 @@ void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\nfor (auto ite = 0; ite < this->n_ite; ite++)\n{\n- this->BP_process<F>(this->var_nodes[cur_wave], this->branches[cur_wave]);\n+ this->_decode_single_ite<F>(this->var_nodes[cur_wave], this->branches[cur_wave]);\n// stop criterion\n- if (this->enable_syndrome && this->check_syndrome(frame_id))\n+ if (this->enable_syndrome && this->_check_syndrome(frame_id))\n{\ncur_syndrome_depth++;\nif (cur_syndrome_depth == this->syndrome_depth)\n@@ -264,36 +262,10 @@ void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n}\n}\n-template <typename B, typename R>\n-bool Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n-::check_syndrome(const int frame_id)\n-{\n- const auto cur_wave = frame_id / this->simd_inter_frame_level;\n- const auto zero = mipp::Msk<mipp::N<B>()>(false);\n- auto syndrome = zero;\n-\n- //auto k = 0;\n- for (auto i = 0; i < this->n_C_nodes; i++)\n- {\n- auto sign = zero;\n-\n- const auto n_VN = (int)this->H[i].size();\n- for (auto j = 0; j < n_VN; j++)\n- {\n- const auto value = this->var_nodes[cur_wave][this->H[i][j]];// - this->branches[cur_wave][k++];\n- sign ^= mipp::sign(value);\n- }\n-\n- syndrome |= sign;\n- }\n-\n- return (mipp::testz(syndrome));\n-}\n-\n// --------------------------------------------------------------------------------------------------------------------\n// --------------------------------------------------------------------------------------------------------- SIMD TOOLS\n-// saturation\n+// --------------------------------------------------------------------------------------------------------- saturation\ntemplate <typename R>\ninline mipp::Reg<R> simd_sat(const mipp::Reg<R> val, const R saturation)\n{\n@@ -305,7 +277,7 @@ inline mipp::Reg<short> simd_sat(const mipp::Reg<short> v, const short s)\nreturn mipp::sat(v, (short)-s, (short)+s);\n}\n-// normalization\n+// ------------------------------------------------------------------------------------------------------ normalization\ntemplate <typename R, int F = 0> inline mipp::Reg<R> simd_normalize(const mipp::Reg<R> val, const float factor)\n{\nreturn val * mipp::Reg<R>((R)factor);\n@@ -328,30 +300,31 @@ template <> inline mipp::Reg<double> simd_normalize<double,8>(const mipp::Reg<do\ntemplate <typename B, typename R>\ntemplate <int F>\nvoid Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n-::BP_process(mipp::vector<mipp::Reg<R>> &var_nodes, mipp::vector<mipp::Reg<R>> &branches)\n+::_decode_single_ite(mipp::vector<mipp::Reg<R>> &var_nodes, mipp::vector<mipp::Reg<R>> &branches)\n{\nauto kr = 0;\nauto kw = 0;\nconst auto zero_msk = mipp::Msk<mipp::N<B>()>(false);\nconst auto zero = mipp::Reg<R>((R)0);\n- for (auto i = 0; i < this->n_C_nodes; i++)\n+ const auto n_chk_nodes = (int)H.get_n_cols();\n+ for (auto c = 0; c < n_chk_nodes; c++)\n{\nauto sign = zero_msk;\nauto min1 = mipp::Reg<R>(std::numeric_limits<R>::max());\nauto min2 = mipp::Reg<R>(std::numeric_limits<R>::max());\n- const auto n_VN = (int)this->H[i].size();\n- for (auto j = 0; j < n_VN; j++)\n+ const auto chk_degree = (int)this->H[c].size();\n+ for (auto v = 0; v < chk_degree; v++)\n{\n- contributions[j] = var_nodes[this->H[i][j]] - branches[kr++];\n- const auto v_abs = mipp::abs (contributions[j]);\n- const auto c_sign = mipp::sign(contributions[j]);\n- const auto v_temp = min1;\n+ contributions[v] = var_nodes[this->H[c][v]] - branches[kr++];\n+ const auto var_abs = mipp::abs (contributions[v]);\n+ const auto var_sign = mipp::sign(contributions[v]);\n+ const auto tmp = min1;\n- sign ^= c_sign;\n- min1 = mipp::min(min1, v_abs );\n- min2 = mipp::min(min2, mipp::max(v_abs, v_temp));\n+ sign ^= var_sign;\n+ min1 = mipp::min(min1, var_abs );\n+ min2 = mipp::min(min2, mipp::max(var_abs, tmp));\n}\nauto cste1 = simd_sat<R>(simd_normalize<R,F>(min2 - offset, normalize_factor), saturation);\n@@ -360,18 +333,45 @@ void Decoder_LDPC_BP_layered_ONMS_inter<B,R>\ncste1 = mipp::blend(zero, cste1, zero > cste1);\ncste2 = mipp::blend(zero, cste2, zero > cste2);\n- for (auto j = 0; j < n_VN; j++)\n+ for (auto v = 0; v < chk_degree; v++)\n+ {\n+ const auto var_val = contributions[v];\n+ const auto var_abs = mipp::abs(var_val);\n+ auto res_abs = mipp::blend(cste1, cste2, var_abs == min1);\n+ const auto res_sng = sign ^ mipp::sign(var_val);\n+ const auto res = mipp::copysign(res_abs, res_sng);\n+\n+ branches[kw++] = res;\n+ var_nodes[this->H[c][v]] = contributions[v] + res;\n+ }\n+ }\n+}\n+\n+template <typename B, typename R>\n+bool Decoder_LDPC_BP_layered_ONMS_inter<B,R>\n+::_check_syndrome(const int frame_id)\n{\n- const auto value = contributions[j];\n- const auto v_abs = mipp::abs(value);\n- auto v_res = mipp::blend(cste1, cste2, v_abs == min1);\n- const auto v_sig = sign ^ mipp::sign(value);\n- v_res = mipp::copysign(v_res, v_sig);\n+ const auto cur_wave = frame_id / this->simd_inter_frame_level;\n+ const auto zero = mipp::Msk<mipp::N<B>()>(false);\n+ auto syndrome = zero;\n- branches[kw++] = v_res;\n- var_nodes[this->H[i][j]] = contributions[j] + v_res;\n+ auto n_chk_nodes = (int)H.get_n_cols();\n+ auto c = 0;\n+ while (c < n_chk_nodes && mipp::testz(syndrome))\n+ {\n+ auto sign = zero;\n+ const auto chk_degree = (int)this->H[c].size();\n+ for (auto v = 0; v < chk_degree; v++)\n+ {\n+ const auto value = this->var_nodes[cur_wave][this->H[c][v]];\n+ sign ^= mipp::sign(value);\n}\n+\n+ syndrome |= sign;\n+ c++;\n}\n+\n+ return (mipp::testz(syndrome));\n}\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Layered/ONMS/Decoder_LDPC_BP_layered_ONMS_inter.hpp",
"new_path": "src/Module/Decoder/LDPC/BP/Layered/ONMS/Decoder_LDPC_BP_layered_ONMS_inter.hpp",
"diff": "@@ -22,7 +22,6 @@ private:\nprotected:\nconst R saturation;\n- const int n_C_nodes; // number of check nodes (= N - K)\n// reset so C_to_V and V_to_C structures can be cleared only at the beginning of the loop in iterative decoding\nbool init_flag;\n@@ -50,19 +49,16 @@ public:\nvoid reset();\nprotected:\n- void _load (const R *Y_N, const int frame_id);\nvoid _decode_siso (const R *Y_N1, R *Y_N2, const int frame_id);\nvoid _decode_siho (const R *Y_N, B *V_K, const int frame_id);\nvoid _decode_siho_cw(const R *Y_N, B *V_N, const int frame_id);\n- // BP functions for decoding\n+ void _load(const R *Y_N, const int frame_id);\ntemplate <int F = 1>\n- void BP_decode(const int frame_id);\n-\n- bool check_syndrome(const int frame_id);\n-\n+ void _decode(const int frame_id);\ntemplate <int F = 1>\n- void BP_process(mipp::vector<mipp::Reg<R>> &var_nodes, mipp::vector<mipp::Reg<R>> &branches);\n+ void _decode_single_ite(mipp::vector<mipp::Reg<R>> &var_nodes, mipp::vector<mipp::Reg<R>> &branches);\n+ bool _check_syndrome(const int frame_id);\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Update_rule/AMS/Update_rule_AMS.hpp",
"new_path": "src/Tools/Code/LDPC/Update_rule/AMS/Update_rule_AMS.hpp",
"diff": "@@ -59,13 +59,13 @@ public:\ninline void compute_chk_node_in(const int var_id, const R var_val)\n{\n- const auto val_abs = (R)std::abs(var_val);\n- const auto val_sgn = std::signbit((float)var_val) ? -1 : 0;\n+ const auto var_abs = (R)std::abs(var_val);\n+ const auto var_sgn = std::signbit((float)var_val) ? -1 : 0;\nconst auto tmp = this->min;\n- this->sign ^= val_sgn;\n- this->min = std::min(this->min, val_abs);\n- this->delta_min = MIN(this->delta_min, (val_abs == this->min) ? tmp : val_abs);\n+ this->sign ^= var_sgn;\n+ this->min = std::min(this->min, var_abs);\n+ this->delta_min = MIN(this->delta_min, (var_abs == this->min) ? tmp : var_abs);\n}\ninline void end_chk_node_in()\n@@ -81,8 +81,8 @@ public:\ninline R compute_chk_node_out(const int var_id, const R var_val)\n{\n- const auto val_abs = (R)std::abs(var_val);\n- auto res_abs = ((val_abs == this->min) ? this->delta_min : this->delta);\n+ const auto var_abs = (R)std::abs(var_val);\n+ auto res_abs = ((var_abs == this->min) ? this->delta_min : this->delta);\nconst auto res_sgn = this->sign ^ (std::signbit((float)var_val) ? -1 : 0);\nreturn (R)std::copysign(res_abs, res_sgn);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Update_rule/LSPA/Update_rule_LSPA.hpp",
"new_path": "src/Tools/Code/LDPC/Update_rule/LSPA/Update_rule_LSPA.hpp",
"diff": "@@ -67,12 +67,12 @@ public:\ninline void compute_chk_node_in(const int var_id, const R var_val)\n{\n- const auto val_abs = (R)std::abs(var_val);\n- const auto tan_val_abs = std::tanh(val_abs * (R)0.5);\n- const auto res = (tan_val_abs != 0) ? (R)std::log(tan_val_abs) : std::numeric_limits<R>::min();\n- const auto val_sign = std::signbit((float)var_val) ? -1 : 0;\n+ const auto var_abs = (R)std::abs(var_val);\n+ const auto tan_var_abs = std::tanh(var_abs * (R)0.5);\n+ const auto res = (tan_var_abs != 0) ? (R)std::log(tan_var_abs) : std::numeric_limits<R>::min();\n+ const auto var_sign = std::signbit((float)var_val) ? -1 : 0;\n- this->sign ^= val_sign;\n+ this->sign ^= var_sign;\nthis->sum += res;\nthis->values[var_id] = res;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Update_rule/MS/Update_rule_MS.hpp",
"new_path": "src/Tools/Code/LDPC/Update_rule/MS/Update_rule_MS.hpp",
"diff": "@@ -67,13 +67,13 @@ public:\ninline void compute_chk_node_in(const int var_id, const R var_val)\n{\n- const auto val_abs = (R)std::abs(var_val);\n- const auto val_sign = std::signbit((float)var_val) ? -1 : 0;\n+ const auto var_abs = (R)std::abs(var_val);\n+ const auto var_sign = std::signbit((float)var_val) ? -1 : 0;\nconst auto tmp = min1;\n- this->sign ^= val_sign;\n- this->min1 = std::min(this->min1, val_abs );\n- this->min2 = std::min(this->min2, std::max(val_abs, tmp));\n+ this->sign ^= var_sign;\n+ this->min1 = std::min(this->min1, var_abs );\n+ this->min2 = std::min(this->min2, std::max(var_abs, tmp));\n}\ninline void end_chk_node_in()\n@@ -89,8 +89,8 @@ public:\ninline R compute_chk_node_out(const int var_id, const R var_val)\n{\n- const auto val_abs = (R)std::abs(var_val);\n- const auto res_abs = ((val_abs == this->min1) ? this->cst1 : this->cst2);\n+ const auto var_abs = (R)std::abs(var_val);\n+ const auto res_abs = ((var_abs == this->min1) ? this->cst1 : this->cst2);\nconst auto res_sng = this->sign ^ (std::signbit((float)var_val) ? -1 : 0);\nreturn (R)std::copysign(res_abs, res_sng);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Update_rule/SPA/Update_rule_SPA.hpp",
"new_path": "src/Tools/Code/LDPC/Update_rule/SPA/Update_rule_SPA.hpp",
"diff": "@@ -67,11 +67,11 @@ public:\ninline void compute_chk_node_in(const int var_id, const R var_val)\n{\n- const auto val_abs = (R)std::abs(var_val);\n- const auto res = (R)std::tanh(val_abs * (R)0.5);\n- const auto val_sign = std::signbit((float)var_val) ? -1 : 0;\n+ const auto var_abs = (R)std::abs(var_val);\n+ const auto res = (R)std::tanh(var_abs * (R)0.5);\n+ const auto var_sign = std::signbit((float)var_val) ? -1 : 0;\n- this->sign ^= val_sign;\n+ this->sign ^= var_sign;\nthis->product *= res;\nthis->values[var_id] = res;\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Refacto LDPC BP ONMS inter frame.
|
8,483 |
09.05.2018 11:30:13
| -7,200 |
f562d5c2cdb45ebaa1477cee525de1f3444851b6
|
Move str2type and type2str method outside the Noise class as normal functions; Move erased_symbol_val and erased_llr_val attributes outside the Noise class as templated functions
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/BEC/Channel_BEC.cpp",
"new_path": "src/Module/Channel/BEC/Channel_BEC.cpp",
"diff": "@@ -70,7 +70,7 @@ void Channel_BEC<R>\nconst auto event_probability = this->n->get_noise();\n- const mipp::Reg<R> r_erased = tools::Noise<R>::erased_symbol_val;\n+ const mipp::Reg<R> r_erased = tools::erased_symbol_val<R>();\nconst mipp::Reg<R> r_ep = event_probability;\nconst auto vec_loop_size = (std::is_same<R,float>::value) ? ((this->N / mipp::nElReg<R>()) * mipp::nElReg<R>()) : 0;\n@@ -84,7 +84,7 @@ void Channel_BEC<R>\n}\nfor (auto i = vec_loop_size; i < this->N; i++)\n- Y_N[i] = get_random() <= event_probability ? tools::Noise<R>::erased_symbol_val : X_N[i];\n+ Y_N[i] = get_random() <= event_probability ? tools::erased_symbol_val<R>() : X_N[i];\n}\ntemplate<typename R>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/OOK/Modem_OOK_BEC.cpp",
"new_path": "src/Module/Modem/OOK/Modem_OOK_BEC.cpp",
"diff": "@@ -30,9 +30,9 @@ template <typename B, typename R, typename Q>\nvoid Modem_OOK_BEC<B,R,Q>\n::_demodulate(const Q *Y_N1, Q *Y_N2, const int frame_id)\n{\n- auto sign = (Q)tools::Noise<R>::erased_llr_val;\n+ auto sign = tools::erased_llr_val<Q>();\nfor (auto i = 0; i < this->N_fil; i++)\n- if (Y_N1[i] == tools::Noise<R>::erased_symbol_val)\n+ if (Y_N1[i] == tools::erased_symbol_val<Q>())\n{\nY_N2[i] = sign;\nsign *= (Q)-1;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Noise/Noise.cpp",
"new_path": "src/Tools/Noise/Noise.cpp",
"diff": "using namespace aff3ct;\nusing namespace aff3ct::tools;\n-template <typename R>\n-const R aff3ct::tools::Noise<R>::erased_symbol_val = std::numeric_limits<R>::infinity();\n-template <typename R>\n-const R aff3ct::tools::Noise<R>::erased_llr_val = (R)0.00001;\n+inline Noise_type aff3ct::tools::str2type(const std::string& str)\n+{\n+ Noise_type t;\n+\n+ if (str == \"SIGMA\")\n+ t = Noise_type::SIGMA;\n+ else if (str == \"ROP\")\n+ t = Noise_type::ROP;\n+ else if (str == \"EP\")\n+ t = Noise_type::EP;\n+ else\n+ {\n+ std::stringstream message;\n+ message << \"The string 'str' does not represent a noise type ('str' = \" << str << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ return t;\n+}\n+\n+inline std::string aff3ct::tools::type2str(Noise_type t)\n+{\n+ std::string str;\n+\n+ switch(t)\n+ {\n+ case Noise_type::SIGMA:\n+ str = \"SIGMA\";\n+ break;\n+ case Noise_type::EP:\n+ str = \"EP\";\n+ break;\n+ case Noise_type::ROP:\n+ str = \"ROP\";\n+ break;\n+ }\n+\n+ if (str.empty()) // this 'if' is a test outside the switch case (instead of default) to keep the compiler check that all\n+ // cases of 'Noise_type' are well represented.\n+ {\n+ std::stringstream message;\n+ message << \"The type 't' does not represent a noise type ('t' = \" << (int8_t)t << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ return str;\n+}\n+\ntemplate <typename R>\nNoise<R>::\n@@ -101,65 +145,6 @@ check()\n// nothing to check\n}\n-template <typename R>\n-Noise_type Noise<R>::\n-str2type(const std::string& str)\n-{\n- Noise_type t;\n-\n- if (str == \"SIGMA\")\n- t = Noise_type::SIGMA;\n- else if (str == \"ROP\")\n- t = Noise_type::ROP;\n- else if (str == \"EP\")\n- t = Noise_type::EP;\n- else\n- {\n- std::stringstream message;\n- message << \"The string 'str' does not represent a noise type ('str' = \" << str << \").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- return t;\n-}\n-\n-template <typename R>\n-std::string Noise<R>::\n-type2str()\n-{\n- return type2str(this->get_type());\n-}\n-\n-template <typename R>\n-std::string Noise<R>::\n-type2str(Noise_type t)\n-{\n- std::string str;\n-\n- switch(t)\n- {\n- case Noise_type::SIGMA:\n- str = \"SIGMA\";\n- break;\n- case Noise_type::EP:\n- str = \"EP\";\n- break;\n- case Noise_type::ROP:\n- str = \"ROP\";\n- break;\n- }\n-\n- if (str.empty()) // this 'if' is a test outside the switch case (instead of default) to keep the compiler check that all\n- // cases of 'Noise_type' are well represented.\n- {\n- std::stringstream message;\n- message << \"The type 't' does not represent a noise type ('t' = \" << (int8_t)t << \").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- return str;\n-}\n-\ntemplate<typename R>\nbool Noise<R>\n::is_of_type(Noise_type t) const noexcept\n@@ -174,7 +159,7 @@ void Noise<R>\nif (!is_of_type(t))\n{\nstd::stringstream message;\n- message << \"The given noise value does not represent a '\" << type2str(t) << \"' noise type.\";\n+ message << \"The given noise value does not represent a '\" << type2str(get_type()) << \"' noise type.\";\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Noise/Noise.hpp",
"new_path": "src/Tools/Noise/Noise.hpp",
"diff": "@@ -12,13 +12,13 @@ namespace tools\nenum class Noise_type {SIGMA, ROP, EP};\n+inline Noise_type str2type(const std::string& str);\n+inline std::string type2str(Noise_type t);\n+\n+\ntemplate <typename R = float>\nclass Noise\n{\n-public:\n- static const R erased_symbol_val;\n- static const R erased_llr_val;\n-\npublic:\nNoise();\nexplicit Noise(R noise);\n@@ -38,13 +38,10 @@ public:\nvirtual std::string get_unity() const = 0; // return a string with the unity of the noise type\nvirtual Noise_type get_type () const = 0;\n+\nbool is_of_type (Noise_type t) const noexcept;\nvoid is_of_type_throw(Noise_type t) const;\n- static Noise_type str2type(const std::string &str);\n- static std::string type2str(Noise_type t);\n- std::string type2str();\n-\nvirtual Noise<R>* clone() const = 0;\nprotected:\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Noise/noise_utils.h",
"new_path": "src/Tools/Noise/noise_utils.h",
"diff": "#ifndef NOISE_UTILS_HPP__\n#define NOISE_UTILS_HPP__\n+#include \"Tools/Math/utils.h\"\n+\n#include \"Sigma.hpp\"\n#include \"Event_probability.hpp\"\n#include \"Received_optical_power.hpp\"\n@@ -13,7 +15,7 @@ namespace tools\ntemplate <typename T, typename R>\nstruct Noise_cast\n{\n- static Noise<T>* cast(const Noise<R>& n)\n+ inline static Noise<T>* cast(const Noise<R>& n)\n{\nNoise<T> * cast_n = nullptr;\n@@ -31,18 +33,25 @@ struct Noise_cast\ntemplate <typename R>\nstruct Noise_cast<R,R>\n{\n- static Noise<R>* cast(const Noise<R>& n)\n+ inline static Noise<R>* cast(const Noise<R>& n)\n{\nreturn n.clone();\n}\n};\ntemplate <typename T, typename R>\n-Noise<T>* cast(const Noise<R>& n)\n+inline Noise<T>* cast(const Noise<R>& n)\n{\nreturn Noise_cast<T,R>::cast(n);\n}\n+\n+template <typename R>\n+constexpr R erased_symbol_val() { return tools::sat_val<R>(); }\n+template <typename R>\n+constexpr R erased_llr_val() { return (R)1e-5; }\n+\n+\n}\n}\n#endif // NOISE_UTILS_HPP__\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Move str2type and type2str method outside the Noise class as normal functions; Move erased_symbol_val and erased_llr_val attributes outside the Noise class as templated functions
|
8,483 |
09.05.2018 11:53:48
| -7,200 |
d7d896b2f61a30518691575ccf024417cb082a93
|
Set automatically the noise type of the simulation in function of the selected channel type
|
[
{
"change_type": "MODIFY",
"old_path": "src/Launcher/Simulation/BFER_std.cpp",
"new_path": "src/Launcher/Simulation/BFER_std.cpp",
"diff": "@@ -114,6 +114,16 @@ void BFER_std<B,R,Q>\nparams.chn->store(this->arg_vals);\n+ auto psim = params.get_prefix();\n+ if (!this->arg_vals.exist({psim+\"-noise-type\", \"E\"}))\n+ {\n+ if (params.chn->type == \"OPTICAL\")\n+ params.noise_type = \"ROP\";\n+ else if (params.chn->type == \"BEC\" || params.chn->type == \"BSC\")\n+ params.noise_type = \"EP\";\n+ // else let the default value EBN0 or ESNO\n+ }\n+\nparams.qnt->size = params.mdm->N;\nif (std::is_integral<Q>())\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Set automatically the noise type of the simulation in function of the selected channel type
|
8,483 |
09.05.2018 15:37:01
| -7,200 |
ef5402de9a6d65d8e8665fd7fb8a5a6606a206df
|
Remove compilation warning comparison signed/unsigned
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/Encoder_LDPC.cpp",
"new_path": "src/Module/Encoder/LDPC/Encoder_LDPC.cpp",
"diff": "@@ -110,7 +110,7 @@ template <typename B>\nvoid Encoder_LDPC<B>\n::_encode(const B *U_K, B *X_N, const int frame_id)\n{\n- for (unsigned i = 0; i < this->N; i++)\n+ for (auto i = 0; i < this->N; i++)\n{\nX_N[i] = 0;\nauto& links = this->G.get_cols_from_row(i);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Remove compilation warning comparison signed/unsigned
|
8,483 |
09.05.2018 17:31:17
| -7,200 |
404568d739fb5c05edaab8e73e165e508dd3766e
|
Add a event generator using MKL and GSL
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Channel/Channel.cpp",
"new_path": "src/Factory/Module/Channel/Channel.cpp",
"diff": "#include \"Tools/Algo/Draw_generator/Event_generator/Standard/Event_generator_std.hpp\"\n#include \"Tools/Algo/Draw_generator/Event_generator/Fast/Event_generator_fast.hpp\"\n#ifdef CHANNEL_MKL\n+#include \"Tools/Algo/Draw_generator/Event_generator/MKL/Event_generator_MKL.hpp\"\n#include \"Tools/Algo/Draw_generator/Gaussian_noise_generator/MKL/Gaussian_noise_generator_MKL.hpp\"\n#endif\n#ifdef CHANNEL_GSL\n+#include \"Tools/Algo/Draw_generator/Event_generator/GSL/Event_generator_GSL.hpp\"\n#include \"Tools/Algo/Draw_generator/Gaussian_noise_generator/GSL/Gaussian_noise_generator_GSL.hpp\"\n#endif\n#include \"Tools/Algo/Draw_generator/User_pdf_noise_generator/Standard/User_pdf_noise_generator_std.hpp\"\n@@ -173,12 +175,12 @@ module::Channel<R>* Channel::parameters\ntools::Event_generator<R>* n = nullptr;\nif (implem == \"STD\" ) n = new tools::Event_generator_std <R>(seed);\nelse if (implem == \"FAST\") n = new tools::Event_generator_fast<R>(seed);\n-//#ifdef CHANNEL_MKL\n-// else if (implem == \"MKL\" ) n = new tools::Event_generator_MKL <R>(seed);\n-//#endif\n-//#ifdef CHANNEL_GSL\n-// else if (implem == \"GSL\" ) n = new tools::Event_generator_GSL <R>(seed);\n-//#endif\n+#ifdef CHANNEL_MKL\n+ else if (implem == \"MKL\" ) n = new tools::Event_generator_MKL<R>(seed);\n+#endif\n+#ifdef CHANNEL_GSL\n+ else if (implem == \"GSL\" ) n = new tools::Event_generator_GSL<R>(seed);\n+#endif\nelse\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/BEC/Channel_BEC.cpp",
"new_path": "src/Module/Channel/BEC/Channel_BEC.cpp",
"diff": "@@ -14,7 +14,7 @@ Channel_BEC<R>\ntemplate<typename R>\nChannel_BEC<R>::Channel_BEC(const int N, tools::Event_generator<R> *event_generator,\nconst tools::Event_probability<R> &noise, const int n_frames)\n-: Channel<R>(N, noise, n_frames), event_generator(event_generator)\n+: Channel<R>(N, noise, n_frames), event_generator(event_generator), event_draw(this->N)\n{\nconst std::string name = \"Channel_BEC\";\nthis->set_name(name);\n@@ -27,24 +27,26 @@ void Channel_BEC<R>\nthis->check_noise();\nconst auto event_probability = this->n->get_noise();\n- event_generator->generate(this->noise.data(), (unsigned)this->N, event_probability);\n+ event_generator->generate(this->event_draw.data(), (unsigned)this->N, event_probability);\n-\n- const mipp::Reg<R> r_erased = tools::erased_symbol_val<R>();\n- const mipp::Reg<R> r_zero = (R)false;\n-\n- const auto vec_loop_size = (this->N / mipp::nElReg<R>()) * mipp::nElReg<R>();\n-\n- for (auto i = 0; i < vec_loop_size; i += mipp::nElReg<R>())\n- {\n- const auto r_in = mipp::Reg<R>(X_N + i);\n- const auto r_event = mipp::Reg<R>(&this->noise[i]);\n- const auto r_out = mipp::blend(r_in, r_erased, r_event == r_zero);\n- r_out.store(Y_N + i);\n- }\n-\n- for (auto i = vec_loop_size; i < this->N; i++)\n- Y_N[i] = this->noise[i] ? tools::erased_symbol_val<R>() : X_N[i];\n+ for (auto i = 0; i < this->N; i++)\n+ Y_N[i] = event_draw[i] ? tools::erased_symbol_val<R>() : X_N[i];\n+//\n+// const mipp::Reg<R> r_erased = tools::erased_symbol_val<R>();\n+// const mipp::Reg<R> r_zero = (R)false;\n+//\n+// const auto vec_loop_size = (this->N / mipp::nElReg<R>()) * mipp::nElReg<R>();\n+//\n+// for (auto i = 0; i < vec_loop_size; i += mipp::nElReg<R>())\n+// {\n+// const auto r_in = mipp::Reg<R>(X_N + i);\n+// const auto r_event = mipp::Reg<R>(&this->noise[i]);\n+// const auto r_out = mipp::blend(r_in, r_erased, r_event == r_zero);\n+// r_out.store(Y_N + i);\n+// }\n+//\n+// for (auto i = vec_loop_size; i < this->N; i++)\n+// Y_N[i] = this->noise[i] ? tools::erased_symbol_val<R>() : X_N[i];\n}\ntemplate<typename R>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/BEC/Channel_BEC.hpp",
"new_path": "src/Module/Channel/BEC/Channel_BEC.hpp",
"diff": "@@ -20,6 +20,7 @@ class Channel_BEC : public Channel<R>\n{\nprotected:\ntools::Event_generator<R> *event_generator;\n+ std::vector<tools::event_type> event_draw;\npublic:\nChannel_BEC(const int N, tools::Event_generator<R> *event_generator = new tools::Event_generator_std<R>(),\n@@ -29,6 +30,7 @@ public:\nChannel_BEC(const int N, const int seed,\nconst tools::Event_probability<R>& noise = tools::Event_probability<R>(),\nconst int n_frames = 1);\n+\nvirtual ~Channel_BEC() = default;\nprotected:\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/BSC/Channel_BSC.cpp",
"new_path": "src/Module/Channel/BSC/Channel_BSC.cpp",
"diff": "@@ -18,9 +18,10 @@ Channel_BSC<R>\n}\ntemplate<typename R>\n-Channel_BSC<R>::Channel_BSC(const int N, tools::Event_generator<R> *event_generator,\n+Channel_BSC<R>\n+::Channel_BSC(const int N, tools::Event_generator<R> *event_generator,\nconst tools::Event_probability<R> &noise, const int n_frames)\n- : Channel<R>(N, noise, n_frames), event_generator(event_generator)\n+: Channel<R>(N, noise, n_frames), event_generator(event_generator), event_draw(this->N)\n{\nconst std::string name = \"Channel_BSC\";\nthis->set_name(name);\n@@ -33,28 +34,31 @@ void Channel_BSC<R>\nthis->check_noise();\nconst auto event_probability = this->n->get_noise();\n- event_generator->generate(this->noise.data(), (unsigned)this->N, event_probability);\n-\n- const mipp::Reg<R> r_zero = (R)false;\n- const mipp::Reg<R> r_0 = (R)0.0;\n- const mipp::Reg<R> r_1 = (R)1.0;\n-\n- const auto vec_loop_size = (this->N / mipp::nElReg<R>()) * mipp::nElReg<R>();\n-\n- for (auto i = 0; i < vec_loop_size; i += mipp::nElReg<R>())\n- {\n- const auto r_in = mipp::Reg<R>(X_N + i);\n- const auto r_event = mipp::Reg<R>(&this->noise[i]);\n-\n- const auto m_zero = r_in == r_0;\n- const auto m_event = r_event == r_zero;\n-\n- const auto r_out = mipp::blend(r_0, r_1, m_event ^ m_zero);\n- r_out.store(Y_N + i);\n- }\n-\n- for (auto i = vec_loop_size; i < this->N; i++)\n- Y_N[i] = this->noise[i] != (X_N[i] == (R)0.0) ? (R)0.0 : (R)1.0;\n+ event_generator->generate(this->event_draw.data(), (unsigned)this->N, event_probability);\n+\n+ for (auto i = 0; i < this->N; i++)\n+ Y_N[i] = event_draw[i] != (X_N[i] == (R)0.0) ? (R)0.0 : (R)1.0;\n+\n+// const mipp::Reg<R> r_zero = (R)false;\n+// const mipp::Reg<R> r_0 = (R)0.0;\n+// const mipp::Reg<R> r_1 = (R)1.0;\n+//\n+// const auto vec_loop_size = (this->N / mipp::nElReg<R>()) * mipp::nElReg<R>();\n+//\n+// for (auto i = 0; i < vec_loop_size; i += mipp::nElReg<R>())\n+// {\n+// const auto r_in = mipp::Reg<R>(X_N + i);\n+// const auto r_event = mipp::Reg<R>(&this->noise[i]);\n+//\n+// const auto m_zero = r_in == r_0;\n+// const auto m_event = r_event == r_zero;\n+//\n+// const auto r_out = mipp::blend(r_0, r_1, m_event ^ m_zero);\n+// r_out.store(Y_N + i);\n+// }\n+//\n+// for (auto i = vec_loop_size; i < this->N; i++)\n+// Y_N[i] = this->noise[i] != (X_N[i] == (R)0.0) ? (R)0.0 : (R)1.0;\n}\ntemplate<typename R>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/BSC/Channel_BSC.hpp",
"new_path": "src/Module/Channel/BSC/Channel_BSC.hpp",
"diff": "@@ -20,6 +20,7 @@ class Channel_BSC : public Channel<R>\n{\nprotected:\ntools::Event_generator<R> *event_generator;\n+ std::vector<tools::event_type> event_draw;\npublic:\nChannel_BSC(const int N, tools::Event_generator<R> *event_generator = new tools::Event_generator_std<R>(),\n@@ -29,6 +30,7 @@ public:\nChannel_BSC(const int N, const int seed,\nconst tools::Event_probability<R>& noise = tools::Event_probability<R>(),\nconst int n_frames = 1);\n+\nvirtual ~Channel_BSC() = default;\nprotected:\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Draw_generator/Event_generator/Event_generator.hpp",
"new_path": "src/Tools/Algo/Draw_generator/Event_generator/Event_generator.hpp",
"diff": "#ifndef EVENT_GENERATOR_HPP\n#define EVENT_GENERATOR_HPP\n+#include <cstdint>\n+#include <vector>\n#include \"../Draw_generator.hpp\"\nnamespace aff3ct\n@@ -8,6 +10,8 @@ namespace aff3ct\nnamespace tools\n{\n+using event_type = int32_t;\n+\ntemplate <typename R = float>\nclass Event_generator : public Draw_generator<R>\n{\n@@ -16,7 +20,13 @@ public:\nvirtual ~Event_generator() = default;\n- virtual void generate(R *draw, const unsigned length, const R event_probability) = 0;\n+ template <class A = std::allocator<event_type>>\n+ void generate(std::vector<event_type,A> &draw, const R event_probability)\n+ {\n+ this->generate(draw.data(), (unsigned)draw.size(), event_probability);\n+ }\n+\n+ virtual void generate(event_type *draw, const unsigned length, const R event_probability) = 0;\n};\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Draw_generator/Event_generator/Fast/Event_generator_fast.cpp",
"new_path": "src/Tools/Algo/Draw_generator/Event_generator/Fast/Event_generator_fast.cpp",
"diff": "@@ -51,7 +51,7 @@ mipp::Reg<float> Event_generator_fast<float>\n::get_random_simd()\n{\n// return a vector of numbers between [0,1]\n- return mt19937_simd.randf_oo();\n+ return mt19937_simd.randf_cc();\n}\n}\n}\n@@ -72,15 +72,27 @@ float Event_generator_fast<float>\ntemplate <typename R>\nvoid Event_generator_fast<R>\n-::generate(R *draw, const unsigned length, const R event_probability)\n+::generate(event_type *draw, const unsigned length, const R event_probability)\n{\n- const mipp::Reg<R> r_ep = event_probability;\n- const mipp::Reg<R> r_one = (R)true;\n- const mipp::Reg<R> r_zero = (R)false;\n+ throw runtime_error(__FILE__, __LINE__, __func__, \"The MT19937 random generator does not support this type.\");\n+}\n+\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+template <>\n+void Event_generator_fast<float>\n+::generate(int32_t *draw, const unsigned length, const float event_probability)\n+{\n+ const mipp::Reg<float > r_ep = event_probability;\n+ const mipp::Reg<int32_t> r_one = true;\n+ const mipp::Reg<int32_t> r_zero = false;\n- const unsigned vec_loop_size = (std::is_same<R,float>::value) ? ((length / mipp::N<R>()) * mipp::N<R>()) : 0;\n+ const unsigned vec_loop_size = (length / mipp::N<float>()) * mipp::N<float>();\n- for (unsigned i = 0; i < vec_loop_size; i += mipp::N<R>())\n+ for (unsigned i = 0; i < vec_loop_size; i += mipp::N<float>())\n{\nconst auto r_draw = get_random_simd();\nconst auto r_out = mipp::blend(r_one, r_zero, r_draw <= r_ep);\n@@ -91,6 +103,8 @@ void Event_generator_fast<R>\ndraw[i] = get_random() <= event_probability;\n}\n+}\n+}\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Draw_generator/Event_generator/Fast/Event_generator_fast.hpp",
"new_path": "src/Tools/Algo/Draw_generator/Event_generator/Fast/Event_generator_fast.hpp",
"diff": "@@ -27,7 +27,7 @@ public:\nvirtual void set_seed(const int seed);\n- virtual void generate(R *draw, const unsigned length, const R event_probability);\n+ virtual void generate(event_type *draw, const unsigned length, const R event_probability);\nprivate:\ninline mipp::Reg<R> get_random_simd();\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Algo/Draw_generator/Event_generator/GSL/Event_generator_GSL.cpp",
"diff": "+#ifdef CHANNEL_GSL\n+\n+#include \"Tools/Exception/exception.hpp\"\n+\n+#include \"Event_generator_GSL.hpp\"\n+\n+using namespace aff3ct;\n+using namespace aff3ct::tools;\n+\n+template <typename R>\n+Event_generator_GSL<R>\n+::Event_generator_GSL(const int seed)\n+: Event_generator<R>(), rng(gsl_rng_alloc(gsl_rng_mt19937))\n+{\n+ this->set_seed(seed);\n+}\n+\n+template <typename R>\n+Event_generator_GSL<R>\n+::~Event_generator_GSL()\n+{\n+ gsl_rng_free(rng);\n+}\n+\n+template <typename R>\n+void Event_generator_GSL<R>\n+::set_seed(const int seed)\n+{\n+ gsl_rng_set(rng, seed);\n+}\n+\n+template <typename R>\n+void Event_generator_GSL<R>\n+::generate(event_type *draw, const unsigned length, const R event_probability)\n+{\n+ for (unsigned i = 0; i < length; i++)\n+ draw[i] = (event_type)gsl_ran_bernoulli(rng, event_probability);\n+}\n+\n+// ==================================================================================== explicit template instantiation\n+#include \"Tools/types.h\"\n+#ifdef MULTI_PREC\n+template class aff3ct::tools::Event_generator_GSL<R_32>;\n+template class aff3ct::tools::Event_generator_GSL<R_64>;\n+#else\n+template class aff3ct::tools::Event_generator_GSL<R>;\n+#endif\n+// ==================================================================================== explicit template instantiation\n+\n+#endif // GSL\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Algo/Draw_generator/Event_generator/GSL/Event_generator_GSL.hpp",
"diff": "+#ifdef CHANNEL_GSL\n+\n+#ifndef EVENT_GENERATOR_GSL_HPP\n+#define EVENT_GENERATOR_GSL_HPP\n+\n+#include <gsl/gsl_randist.h>\n+#include <gsl/gsl_rng.h>\n+\n+#include \"../Event_generator.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+\n+template <typename R = float>\n+class Event_generator_GSL : public Event_generator<R>\n+{\n+private:\n+ gsl_rng *rng;\n+\n+public:\n+ explicit Event_generator_GSL(const int seed = 0);\n+\n+ virtual ~Event_generator_GSL();\n+\n+ virtual void set_seed(const int seed);\n+\n+ virtual void generate(event_type *draw, const unsigned length, const R event_probability);\n+};\n+\n+}\n+}\n+\n+#endif //EVENT_GENERATOR_GSL_HPP\n+\n+#endif // GSL\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Algo/Draw_generator/Event_generator/MKL/Event_generator_MKL.cpp",
"diff": "+#ifdef CHANNEL_MKL\n+\n+#include \"Tools/Exception/exception.hpp\"\n+\n+#include \"Event_generator_MKL.hpp\"\n+\n+using namespace aff3ct;\n+using namespace aff3ct::tools;\n+\n+template <typename R>\n+Event_generator_MKL<R>\n+::Event_generator_MKL(const int seed)\n+: Event_generator<R>(), stream_state(nullptr), is_stream_alloc(false)\n+{\n+ this->set_seed(seed);\n+}\n+\n+template <typename R>\n+Event_generator_MKL<R>\n+::~Event_generator_MKL()\n+{\n+ if (is_stream_alloc)\n+ vslDeleteStream(&stream_state);\n+}\n+\n+template <typename R>\n+void Event_generator_MKL<R>\n+::set_seed(const int seed)\n+{\n+ if (is_stream_alloc) vslDeleteStream(&stream_state);\n+\n+ //vslNewStream(&stream_state, VSL_BRNG_MT2203, seed);\n+ vslNewStream(&stream_state, VSL_BRNG_SFMT19937, seed);\n+\n+ is_stream_alloc = true;\n+}\n+\n+template <typename R>\n+void Event_generator_MKL<R>\n+::generate(event_type *draw, const unsigned length, const R event_probability)\n+{\n+ viRngBernoulli(VSL_RNG_METHOD_BERNOULLI_ICDF, stream_state, length, draw, event_probability);\n+}\n+\n+\n+// ==================================================================================== explicit template instantiation\n+#include \"Tools/types.h\"\n+#ifdef MULTI_PREC\n+template class aff3ct::tools::Event_generator_MKL<R_32>;\n+template class aff3ct::tools::Event_generator_MKL<R_64>;\n+#else\n+template class aff3ct::tools::Event_generator_MKL<R>;\n+#endif\n+// ==================================================================================== explicit template instantiation\n+\n+#endif // MKL\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Algo/Draw_generator/Event_generator/MKL/Event_generator_MKL.hpp",
"diff": "+#ifdef CHANNEL_MKL\n+\n+#ifndef EVENT_GENERATOR_MKL_HPP\n+#define EVENT_GENERATOR_MKL_HPP\n+\n+#include <mkl_vsl.h>\n+\n+#include \"../Event_generator.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+\n+template <typename R = float>\n+class Event_generator_MKL : public Event_generator<R>\n+{\n+private:\n+ VSLStreamStatePtr stream_state;\n+ bool is_stream_alloc;\n+\n+public:\n+ explicit Event_generator_MKL(const int seed = 0);\n+\n+ virtual ~Event_generator_MKL();\n+\n+ virtual void set_seed(const int seed);\n+\n+ virtual void generate(event_type *draw, const unsigned length, const R event_probability);\n+};\n+\n+}\n+}\n+\n+#endif //EVENT_GENERATOR_MKL_HPP\n+\n+#endif // MKL\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Draw_generator/Event_generator/Standard/Event_generator_std.cpp",
"new_path": "src/Tools/Algo/Draw_generator/Event_generator/Standard/Event_generator_std.cpp",
"diff": "@@ -7,7 +7,7 @@ using namespace aff3ct::tools;\ntemplate <typename R>\nEvent_generator_std<R>\n::Event_generator_std(const int seed)\n-: Event_generator<R>(), uni_dist((R)0, (R)1)\n+: Event_generator<R>()\n{\nthis->set_seed(seed);\n}\n@@ -21,10 +21,12 @@ void Event_generator_std<R>\ntemplate <typename R>\nvoid Event_generator_std<R>\n-::generate(R *draw, const unsigned length, const R event_probability)\n+::generate(event_type *draw, const unsigned length, const R event_probability)\n{\n+ std::bernoulli_distribution bern_dist(event_probability);\n+\nfor (unsigned i = 0; i < length; i++)\n- draw[i] = this->uni_dist(this->rd_engine) <= event_probability;\n+ draw[i] = (event_type)bern_dist(this->rd_engine);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Draw_generator/Event_generator/Standard/Event_generator_std.hpp",
"new_path": "src/Tools/Algo/Draw_generator/Event_generator/Standard/Event_generator_std.hpp",
"diff": "@@ -15,7 +15,6 @@ class Event_generator_std : public Event_generator<R>\n{\nprotected:\nstd::mt19937 rd_engine; // Mersenne Twister 19937\n- std::uniform_real_distribution<R> uni_dist;\npublic:\nexplicit Event_generator_std(const int seed = 0);\n@@ -24,7 +23,7 @@ public:\nvirtual void set_seed(const int seed);\n- virtual void generate(R *draw, const unsigned length, const R event_probability);\n+ virtual void generate(event_type *draw, const unsigned length, const R event_probability);\n};\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a event generator using MKL and GSL
|
8,483 |
09.05.2018 17:57:26
| -7,200 |
87e6fc819e1e5f95f88d1426393a9a6242d3f535
|
Fix the Encoder_LDPC_from_QC
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/From_QC/Encoder_LDPC_from_QC.cpp",
"new_path": "src/Module/Encoder/LDPC/From_QC/Encoder_LDPC_from_QC.cpp",
"diff": "@@ -15,11 +15,15 @@ using namespace aff3ct::module;\ntemplate <typename B>\nEncoder_LDPC_from_QC<B>\n::Encoder_LDPC_from_QC(const int K, const int N, const tools::Sparse_matrix &_H, const int n_frames)\n-: Encoder_LDPC<B>(K, N, tools::Sparse_matrix(), _H, n_frames),\n+: Encoder_LDPC<B>(K, N, n_frames),\ninvH2(tools::LDPC_matrix_handler::invert_H2(_H))\n{\nconst std::string name = \"Encoder_LDPC_from_QC\";\nthis->set_name(name);\n+\n+ this->H = _H;\n+\n+ this->check_H_dimensions();\n}\ntemplate <typename B>\n@@ -70,13 +74,13 @@ template <typename B>\nvoid Encoder_LDPC_from_QC<B>\n::_check_H_dimensions()\n{\n- Encoder_LDPC<B>::check_H_dimensions();\n+ Encoder_LDPC<B>::_check_H_dimensions();\n- if ((this->N-this->K) != (int)this->H.get_n_rows())\n+ if ((this->N-this->K) != (int)this->H.get_n_cols())\n{\nstd::stringstream message;\nmessage << \"The built H matrix has a dimension '(N-K)' different than the given one ('(N-K)' = \" << (this->N-this->K)\n- << \", 'H.get_n_rows()' = \" << this->H.get_n_rows() << \").\";\n+ << \", 'H.get_n_cols()' = \" << this->H.get_n_cols() << \").\";\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix the Encoder_LDPC_from_QC
|
8,483 |
09.05.2018 18:26:09
| -7,200 |
ff8eed3e5025d37847bbe5d7fc78b1227b069e6a
|
Force min_value as a Q type; Set correctly the const pointer return type of Distributions::get_distribution
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/OOK/Modem_OOK_optical.cpp",
"new_path": "src/Module/Modem/OOK/Modem_OOK_optical.cpp",
"diff": "@@ -82,7 +82,7 @@ void Modem_OOK_optical<B,R,Q>\nconst auto& pdf_y0 = this->current_dist->get_pdf_y()[0];\nconst auto& pdf_y1 = this->current_dist->get_pdf_y()[1];\n- const Q min_value = 1e-10; // when prob_1 ou prob_0 = 0;\n+ const Q min_value = (Q)1e-10; // when prob_1 ou prob_0 = 0;\nfor (auto i = 0; i < this->N_fil; i++)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/Distribution/Distributions.cpp",
"new_path": "src/Tools/Math/Distribution/Distributions.cpp",
"diff": "@@ -113,7 +113,7 @@ has_distribution(R noise) const\n}\ntemplate<typename R>\n-const Distribution<R>* const Distributions<R>::\n+const Distribution<R> const* Distributions<R>::\nget_distribution(R noise) const\n{\nauto it = this->distributions.find(calibrated_noise(noise));\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/Distribution/Distributions.hpp",
"new_path": "src/Tools/Math/Distribution/Distributions.hpp",
"diff": "@@ -43,7 +43,7 @@ public:\nvirtual ~Distributions();\nbool has_distribution(R noise) const;\n- const Distribution<R>* const get_distribution(R noise) const;\n+ const Distribution<R> const* get_distribution(R noise) const;\nvoid read_distribution(R noise);\nstd::vector<R> get_noise_range() const;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Force min_value as a Q type; Set correctly the const pointer return type of Distributions::get_distribution
|
8,483 |
11.05.2018 11:41:19
| -7,200 |
b6d7f159883a772f278838e263e708a5ead3973b
|
Modify Distributions::get_distribution to return a reference or throw an exception instead of returning a nullptr.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Draw_generator/User_pdf_noise_generator/Standard/User_pdf_noise_generator_std.cpp",
"new_path": "src/Tools/Algo/Draw_generator/User_pdf_noise_generator/Standard/User_pdf_noise_generator_std.cpp",
"diff": "@@ -38,17 +38,10 @@ void User_pdf_noise_generator_std<R>\n{\nauto dis = this->distributions.get_distribution(noise_power);\n- if (dis == nullptr)\n- {\n- std::stringstream message;\n- message << \"Undefined noise power 'noise_power' in the given distributions ('noise_power' = \" << noise_power << \").\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\nfor (unsigned i = 0; i < length; i++)\n{\n- const auto& cdf_y = signal[i] ? dis->get_cdf_y()[1] : dis->get_cdf_y()[0];\n- const auto& cdf_x = signal[i] ? dis->get_cdf_x()[1] : dis->get_cdf_x()[0];\n+ const auto& cdf_y = signal[i] ? dis.get_cdf_y()[1] : dis.get_cdf_y()[0];\n+ const auto& cdf_x = signal[i] ? dis.get_cdf_x()[1] : dis.get_cdf_x()[0];\ndraw[i] = interp_function(cdf_y.data(), cdf_x.data(), cdf_x.size(), this->uniform_dist(this->rd_engine));\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Draw_generator/User_pdf_noise_generator/User_pdf_noise_generator.hpp",
"new_path": "src/Tools/Algo/Draw_generator/User_pdf_noise_generator/User_pdf_noise_generator.hpp",
"diff": "@@ -26,7 +26,7 @@ public:\nvirtual ~User_pdf_noise_generator() = default;\n- const Distributions<R>& get_distributions()\n+ const Distributions<R>& get_distributions() const\n{\nreturn distributions;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/Distribution/Distributions.cpp",
"new_path": "src/Tools/Math/Distribution/Distributions.cpp",
"diff": "@@ -113,29 +113,50 @@ has_distribution(R noise) const\n}\ntemplate<typename R>\n-const Distribution<R> const* Distributions<R>::\n+const Distribution<R>& Distributions<R>::\nget_distribution(R noise) const\n{\nauto it = this->distributions.find(calibrated_noise(noise));\nif (it == this->distributions.end())\n- return nullptr;\n+ {\n+ std::stringstream message;\n+ message << \"Undefined noise 'noise' in the distributions ('noise' = \" << noise << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (it->second == nullptr)\n+ {\n+ std::stringstream message;\n+ message << \"Defined noise but no associated distribution ('noise' = \" << noise << \").\";\n+ throw runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n- return it->second;\n+ return *it->second;\n}\ntemplate<typename R>\nvoid Distributions<R>::\nadd_distribution(R noise, Distribution<R>* new_distribution)\n{\n- if (get_distribution(noise))\n+ if (new_distribution == nullptr)\n{\nstd::stringstream message;\n- message << \"A distribution already exist for the given noise power 'noise_power' ('noise' = \" << noise << \").\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ message << \"The given 'new_distribution' is a null pointer.\";\n+ throw runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n+ try\n+ {\n+ get_distribution(noise);\n+ std::stringstream message;\n+ message << \"A distribution already exists for the given noise 'noise' ('noise' = \" << noise << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ catch (const tools::invalid_argument&)\n+ {\nthis->distributions[calibrated_noise(noise)] = new_distribution;\n}\n+}\ntemplate<typename R>\nvoid Distributions<R>::\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/Distribution/Distributions.hpp",
"new_path": "src/Tools/Math/Distribution/Distributions.hpp",
"diff": "@@ -43,7 +43,7 @@ public:\nvirtual ~Distributions();\nbool has_distribution(R noise) const;\n- const Distribution<R> const* get_distribution(R noise) const;\n+ const Distribution<R>& get_distribution(R noise) const;\nvoid read_distribution(R noise);\nstd::vector<R> get_noise_range() const;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Modify Distributions::get_distribution to return a reference or throw an exception instead of returning a nullptr.
|
8,483 |
11.05.2018 12:22:39
| -7,200 |
ecec9273dc30e47858532de83245944cb3c0d7aa
|
Modify Modem_OOK_optical.cpp to handle the returned references of get_distribution
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/OOK/Modem_OOK_optical.cpp",
"new_path": "src/Module/Modem/OOK/Modem_OOK_optical.cpp",
"diff": "@@ -45,7 +45,7 @@ void Modem_OOK_optical<B,R,Q>\n{\nModem_OOK<B,R,Q>::set_noise(noise);\n- this->current_dist = dist.get_distribution(this->n->get_noise());\n+ this->current_dist = &dist.get_distribution(this->n->get_noise());\nif (this->current_dist == nullptr)\n{\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Modify Modem_OOK_optical.cpp to handle the returned references of get_distribution
|
8,483 |
11.05.2018 14:44:44
| -7,200 |
798a57aa6f46bc3c5689744cad19708a7252f526
|
Rename channel BEC and BSC to their full name bianry erasure and binary symmetric
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Channel/Channel.cpp",
"new_path": "src/Factory/Module/Channel/Channel.cpp",
"diff": "#include \"Module/Channel/Rayleigh/Channel_Rayleigh_LLR.hpp\"\n#include \"Module/Channel/Rayleigh/Channel_Rayleigh_LLR_user.hpp\"\n#include \"Module/Channel/Optical/Channel_optical.hpp\"\n-#include \"Module/Channel/BEC/Channel_BEC.hpp\"\n-#include \"Module/Channel/BSC/Channel_BSC.hpp\"\n+#include \"Module/Channel/Binary_erasure/Channel_binary_erasure.hpp\"\n+#include \"Module/Channel/Binary_symmetric/Channel_binary_symmetric.hpp\"\n#include \"Tools/Algo/Draw_generator/Gaussian_noise_generator/Standard/Gaussian_noise_generator_std.hpp\"\n#include \"Tools/Algo/Draw_generator/Gaussian_noise_generator/Fast/Gaussian_noise_generator_fast.hpp\"\n@@ -184,8 +184,8 @@ module::Channel<R>* Channel::parameters\nelse\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n- if (type == \"BEC\" ) return new module::Channel_BEC <R>(N, n, tools::Event_probability<R>((R)noise), n_frames);\n- else if (type == \"BSC\" ) return new module::Channel_BSC <R>(N, n, tools::Event_probability<R>((R)noise), n_frames);\n+ if (type == \"BEC\" ) return new module::Channel_binary_erasure <R>(N, n, tools::Event_probability<R>((R)noise), n_frames);\n+ else if (type == \"BSC\" ) return new module::Channel_binary_symmetric<R>(N, n, tools::Event_probability<R>((R)noise), n_frames);\ndelete n;\n"
},
{
"change_type": "RENAME",
"old_path": "src/Module/Channel/BEC/Channel_BEC.cpp",
"new_path": "src/Module/Channel/Binary_erasure/Channel_binary_erasure.cpp",
"diff": "#include <type_traits>\n-#include \"Channel_BEC.hpp\"\n+#include \"Channel_binary_erasure.hpp\"\nusing namespace aff3ct;\nusing namespace aff3ct::module;\ntemplate <typename R>\n-Channel_BEC<R>\n-::Channel_BEC(const int N, const int seed, const tools::Event_probability<R>& noise, const int n_frames)\n-: Channel_BEC<R>(N, new tools::Event_generator_std<R>(seed), noise, n_frames)\n+Channel_binary_erasure<R>\n+::Channel_binary_erasure(const int N, const int seed, const tools::Event_probability<R>& noise, const int n_frames)\n+: Channel_binary_erasure<R>(N, new tools::Event_generator_std<R>(seed), noise, n_frames)\n{\n}\ntemplate<typename R>\n-Channel_BEC<R>::Channel_BEC(const int N, tools::Event_generator<R> *event_generator,\n+Channel_binary_erasure<R>\n+::Channel_binary_erasure(const int N, tools::Event_generator<R> *event_generator,\nconst tools::Event_probability<R> &noise, const int n_frames)\n: Channel<R>(N, noise, n_frames), event_generator(event_generator), event_draw(this->N)\n{\n- const std::string name = \"Channel_BEC\";\n+ const std::string name = \"Channel_binary_erasure\";\nthis->set_name(name);\n}\ntemplate <typename R>\n-void Channel_BEC<R>\n+void Channel_binary_erasure<R>\n::_add_noise(const R *X_N, R *Y_N, const int frame_id)\n{\nthis->check_noise();\n@@ -50,7 +51,7 @@ void Channel_BEC<R>\n}\ntemplate<typename R>\n-void Channel_BEC<R>::check_noise()\n+void Channel_binary_erasure<R>::check_noise()\n{\nChannel<R>::check_noise();\n@@ -60,9 +61,9 @@ void Channel_BEC<R>::check_noise()\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n-template class aff3ct::module::Channel_BEC<R_32>;\n-template class aff3ct::module::Channel_BEC<R_64>;\n+template class aff3ct::module::Channel_binary_erasure<R_32>;\n+template class aff3ct::module::Channel_binary_erasure<R_64>;\n#else\n-template class aff3ct::module::Channel_BEC<R>;\n+template class aff3ct::module::Channel_binary_erasure<R>;\n#endif\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "RENAME",
"old_path": "src/Module/Channel/BEC/Channel_BEC.hpp",
"new_path": "src/Module/Channel/Binary_erasure/Channel_binary_erasure.hpp",
"diff": "@@ -16,22 +16,22 @@ namespace aff3ct\nnamespace module\n{\ntemplate <typename R = float>\n-class Channel_BEC : public Channel<R>\n+class Channel_binary_erasure : public Channel<R>\n{\nprotected:\ntools::Event_generator<R> *event_generator;\nstd::vector<tools::event_type> event_draw;\npublic:\n- Channel_BEC(const int N, tools::Event_generator<R> *event_generator = new tools::Event_generator_std<R>(),\n+ Channel_binary_erasure(const int N, tools::Event_generator<R> *event_generator = new tools::Event_generator_std<R>(),\nconst tools::Event_probability<R>& noise = tools::Event_probability<R>(),\nconst int n_frames = 1);\n- Channel_BEC(const int N, const int seed,\n+ Channel_binary_erasure(const int N, const int seed,\nconst tools::Event_probability<R>& noise = tools::Event_probability<R>(),\nconst int n_frames = 1);\n- virtual ~Channel_BEC() = default;\n+ virtual ~Channel_binary_erasure() = default;\nprotected:\nvoid _add_noise(const R *X_N, R *Y_N, const int frame_id = -1);\n"
},
{
"change_type": "RENAME",
"old_path": "src/Module/Channel/BSC/Channel_BSC.cpp",
"new_path": "src/Module/Channel/Binary_symmetric/Channel_binary_symmetric.cpp",
"diff": "#include <type_traits>\n-#include \"Channel_BSC.hpp\"\n-\n-using namespace aff3ct;\n-using namespace aff3ct::module;\n-\n-#include <type_traits>\n-#include \"Channel_BSC.hpp\"\n+#include \"Channel_binary_symmetric.hpp\"\nusing namespace aff3ct;\nusing namespace aff3ct::module;\ntemplate <typename R>\n-Channel_BSC<R>\n-::Channel_BSC(const int N, const int seed, const tools::Event_probability<R>& noise, const int n_frames)\n-: Channel_BSC<R>(N, new tools::Event_generator_std<R>(seed), noise, n_frames)\n+Channel_binary_symmetric<R>\n+::Channel_binary_symmetric(const int N, const int seed, const tools::Event_probability<R>& noise, const int n_frames)\n+: Channel_binary_symmetric<R>(N, new tools::Event_generator_std<R>(seed), noise, n_frames)\n{\n}\ntemplate<typename R>\n-Channel_BSC<R>\n-::Channel_BSC(const int N, tools::Event_generator<R> *event_generator,\n+Channel_binary_symmetric<R>\n+::Channel_binary_symmetric(const int N, tools::Event_generator<R> *event_generator,\nconst tools::Event_probability<R> &noise, const int n_frames)\n: Channel<R>(N, noise, n_frames), event_generator(event_generator), event_draw(this->N)\n{\n- const std::string name = \"Channel_BSC\";\n+ const std::string name = \"Channel_binary_symmetric\";\nthis->set_name(name);\n}\ntemplate <typename R>\n-void Channel_BSC<R>\n+void Channel_binary_symmetric<R>\n::_add_noise(const R *X_N, R *Y_N, const int frame_id)\n{\nthis->check_noise();\n@@ -62,7 +56,7 @@ void Channel_BSC<R>\n}\ntemplate<typename R>\n-void Channel_BSC<R>::check_noise()\n+void Channel_binary_symmetric<R>::check_noise()\n{\nChannel<R>::check_noise();\n@@ -72,9 +66,9 @@ void Channel_BSC<R>::check_noise()\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n-template class aff3ct::module::Channel_BSC<R_32>;\n-template class aff3ct::module::Channel_BSC<R_64>;\n+template class aff3ct::module::Channel_binary_symmetric<R_32>;\n+template class aff3ct::module::Channel_binary_symmetric<R_64>;\n#else\n-template class aff3ct::module::Channel_BSC<R>;\n+template class aff3ct::module::Channel_binary_symmetric<R>;\n#endif\n// ==================================================================================== explicit template instantiation\n\\ No newline at end of file\n"
},
{
"change_type": "RENAME",
"old_path": "src/Module/Channel/BSC/Channel_BSC.hpp",
"new_path": "src/Module/Channel/Binary_symmetric/Channel_binary_symmetric.hpp",
"diff": "@@ -16,22 +16,22 @@ namespace aff3ct\nnamespace module\n{\ntemplate <typename R = float>\n-class Channel_BSC : public Channel<R>\n+class Channel_binary_symmetric : public Channel<R>\n{\nprotected:\ntools::Event_generator<R> *event_generator;\nstd::vector<tools::event_type> event_draw;\npublic:\n- Channel_BSC(const int N, tools::Event_generator<R> *event_generator = new tools::Event_generator_std<R>(),\n+ Channel_binary_symmetric(const int N, tools::Event_generator<R> *event_generator = new tools::Event_generator_std<R>(),\nconst tools::Event_probability<R>& noise = tools::Event_probability<R>(),\nconst int n_frames = 1);\n- Channel_BSC(const int N, const int seed,\n+ Channel_binary_symmetric(const int N, const int seed,\nconst tools::Event_probability<R>& noise = tools::Event_probability<R>(),\nconst int n_frames = 1);\n- virtual ~Channel_BSC() = default;\n+ virtual ~Channel_binary_symmetric() = default;\nprotected:\nvoid _add_noise(const R *X_N, R *Y_N, const int frame_id = -1);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Rename channel BEC and BSC to their full name bianry erasure and binary symmetric
|
8,483 |
11.05.2018 15:31:18
| -7,200 |
73e3fb83fb1d0e98733bba5310da27a488925641
|
Add user_pdf noise generator MKL, GSL and MIPP versions
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Channel/Channel.cpp",
"new_path": "src/Factory/Module/Channel/Channel.cpp",
"diff": "#include \"Tools/Algo/Draw_generator/Gaussian_noise_generator/Fast/Gaussian_noise_generator_fast.hpp\"\n#include \"Tools/Algo/Draw_generator/Event_generator/Standard/Event_generator_std.hpp\"\n#include \"Tools/Algo/Draw_generator/Event_generator/Fast/Event_generator_fast.hpp\"\n+#include \"Tools/Algo/Draw_generator/User_pdf_noise_generator/Standard/User_pdf_noise_generator_std.hpp\"\n+#include \"Tools/Algo/Draw_generator/User_pdf_noise_generator/Fast/User_pdf_noise_generator_fast.hpp\"\n#ifdef CHANNEL_MKL\n#include \"Tools/Algo/Draw_generator/Event_generator/MKL/Event_generator_MKL.hpp\"\n#include \"Tools/Algo/Draw_generator/Gaussian_noise_generator/MKL/Gaussian_noise_generator_MKL.hpp\"\n+#include \"Tools/Algo/Draw_generator/User_pdf_noise_generator/MKL/User_pdf_noise_generator_MKL.hpp\"\n#endif\n#ifdef CHANNEL_GSL\n#include \"Tools/Algo/Draw_generator/Event_generator/GSL/Event_generator_GSL.hpp\"\n#include \"Tools/Algo/Draw_generator/Gaussian_noise_generator/GSL/Gaussian_noise_generator_GSL.hpp\"\n+#include \"Tools/Algo/Draw_generator/User_pdf_noise_generator/GSL/User_pdf_noise_generator_GSL.hpp\"\n#endif\n-#include \"Tools/Algo/Draw_generator/User_pdf_noise_generator/Standard/User_pdf_noise_generator_std.hpp\"\n#include \"Channel.hpp\"\n@@ -217,6 +220,32 @@ module::Channel<R>* Channel::parameters\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n+template <typename R>\n+module::Channel<R>* Channel::parameters\n+::build_userpdf(const tools::Distributions<R>* dist) const\n+{\n+ if (dist == nullptr)\n+ throw tools::cannot_allocate(__FILE__, __LINE__, __func__);\n+\n+ tools::User_pdf_noise_generator<R>* n = nullptr;\n+ if (implem == \"STD\" ) n = new tools::User_pdf_noise_generator_std <R>(*dist, seed);\n+ else if (implem == \"FAST\") n = new tools::User_pdf_noise_generator_fast<R>(*dist, seed);\n+#ifdef CHANNEL_MKL\n+ else if (implem == \"MKL\" ) n = new tools::User_pdf_noise_generator_MKL <R>(*dist, seed);\n+#endif\n+#ifdef CHANNEL_GSL\n+ else if (implem == \"GSL\" ) n = new tools::User_pdf_noise_generator_GSL <R>(*dist, seed);\n+#endif\n+ else\n+ throw tools::cannot_allocate(__FILE__, __LINE__, __func__);\n+\n+ if (type == \"OPTICAL\") return new module::Channel_optical<R>(N, n, tools::Received_optical_power<R>((R) this->noise), n_frames);\n+\n+ delete n;\n+\n+ throw tools::cannot_allocate(__FILE__, __LINE__, __func__);\n+}\n+\ntemplate <typename R>\nmodule::Channel<R>* Channel::parameters\n::build(const tools::Distributions<R>* dist) const\n@@ -229,11 +258,10 @@ module::Channel<R>* Channel::parameters\nreturn build_event<R>();\n} catch (tools::cannot_allocate&) {}\n- if (type == \"OPTICAL\" && dist != nullptr)\n- {\n- auto n = new tools::User_pdf_noise_generator_std<R>(*dist, seed);\n- return new module::Channel_optical<R>(N, n, tools::Received_optical_power<R>((R) this->noise), n_frames);\n- }\n+ try {\n+ return build_userpdf<R>(dist);\n+ } catch (tools::cannot_allocate&) {}\n+\nif (type == \"USER\" ) return new module::Channel_user<R>(N, path, add_users, false, n_frames);\nif (type == \"USER_ADD\") return new module::Channel_user<R>(N, path, add_users, true, n_frames);\nif (type == \"NO\" ) return new module::Channel_NO <R>(N, add_users, n_frames);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Channel/Channel.hpp",
"new_path": "src/Factory/Module/Channel/Channel.hpp",
"diff": "@@ -51,6 +51,8 @@ struct Channel : public Factory\ntemplate <typename R = float>\nmodule::Channel<R>* build_event() const;\ntemplate <typename R = float>\n+ module::Channel<R>* build_userpdf(const tools::Distributions<R>* dist) const;\n+ template <typename R = float>\nmodule::Channel<R>* build(const tools::Distributions<R>* dist = nullptr) const;\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Draw_generator/Event_generator/Fast/Event_generator_fast.hpp",
"new_path": "src/Tools/Algo/Draw_generator/Event_generator/Fast/Event_generator_fast.hpp",
"diff": "#ifndef EVENT_GENERATOR_FAST_HPP\n#define EVENT_GENERATOR_FAST_HPP\n-#include <random>\n-\n#include \"Tools/Algo/PRNG/PRNG_MT19937.hpp\"\n#include \"Tools/Algo/PRNG/PRNG_MT19937_simd.hpp\"\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Algo/Draw_generator/User_pdf_noise_generator/Fast/User_pdf_noise_generator_fast.cpp",
"diff": "+#include <sstream>\n+\n+#include \"Tools/Exception/exception.hpp\"\n+#include \"User_pdf_noise_generator_fast.hpp\"\n+\n+using namespace aff3ct;\n+using namespace aff3ct::tools;\n+\n+template <typename R>\n+User_pdf_noise_generator_fast<R>\n+::User_pdf_noise_generator_fast(const tools::Distributions<R>& dists, const int seed, Interpolation_type inter_type)\n+: User_pdf_noise_generator<R>(dists), interp_function(nullptr)\n+{\n+ this->set_seed(seed);\n+\n+ switch (inter_type)\n+ {\n+ case Interpolation_type::LINEAR:\n+ interp_function = tools::linear_interpolation<R>;\n+ break;\n+\n+ case Interpolation_type::NEAREST:\n+ interp_function = tools::nearest_interpolation<R>;\n+ break;\n+ }\n+}\n+\n+template <typename R>\n+void User_pdf_noise_generator_fast<R>\n+::set_seed(const int seed)\n+{\n+ mt19937.seed(seed);\n+\n+ mipp::vector<int> seeds(mipp::nElReg<int>());\n+ for (auto i = 0; i < mipp::nElReg<int>(); i++)\n+ seeds[i] = mt19937.rand();\n+ mt19937_simd.seed(seeds.data());\n+}\n+\n+template <typename R>\n+mipp::Reg<R> User_pdf_noise_generator_fast<R>\n+::get_random_simd()\n+{\n+ throw runtime_error(__FILE__, __LINE__, __func__, \"The MT19937 random generator does not support this type.\");\n+}\n+\n+template <typename R>\n+R User_pdf_noise_generator_fast<R>\n+::get_random()\n+{\n+ throw runtime_error(__FILE__, __LINE__, __func__, \"The MT19937 random generator does not support this type.\");\n+}\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+template <>\n+mipp::Reg<float> User_pdf_noise_generator_fast<float>\n+::get_random_simd()\n+{\n+ // return a vector of numbers between [0,1]\n+ return mt19937_simd.randf_cc();\n+}\n+}\n+}\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+template <>\n+float User_pdf_noise_generator_fast<float>\n+::get_random()\n+{\n+ // return a number between [0,1]\n+ return mt19937.randf_cc();\n+}\n+}\n+}\n+\n+template <typename R>\n+void User_pdf_noise_generator_fast<R>\n+::generate(const R* signal, R *draw, const unsigned length, const R noise_power)\n+{\n+ throw runtime_error(__FILE__, __LINE__, __func__, \"The MT19937 random generator does not support this type.\");\n+}\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+template <>\n+void User_pdf_noise_generator_fast<float>\n+::generate(const float* signal, float *draw, const unsigned length, const float noise_power)\n+{\n+ auto dis = this->distributions.get_distribution(noise_power);\n+\n+\n+\n+ const unsigned vec_loop_size = (length / mipp::N<float>()) * mipp::N<float>();\n+\n+ for (unsigned i = 0; i < vec_loop_size; i += mipp::N<float>())\n+ {\n+ const auto r_draw = get_random_simd();\n+ r_draw.store(draw + i);\n+ }\n+\n+ for (auto i = vec_loop_size; i < length; i++)\n+ draw[i] = get_random();\n+\n+\n+ for (unsigned i = 0; i < length; i++)\n+ {\n+ const auto& cdf_y = signal[i] ? dis.get_cdf_y()[1] : dis.get_cdf_y()[0];\n+ const auto& cdf_x = signal[i] ? dis.get_cdf_x()[1] : dis.get_cdf_x()[0];\n+ draw[i] = interp_function(cdf_y.data(), cdf_x.data(), cdf_x.size(), draw[i]);\n+ }\n+}\n+}\n+}\n+\n+template <typename R>\n+void User_pdf_noise_generator_fast<R>\n+::generate(R *draw, const unsigned length, const R noise_power)\n+{\n+ throw unimplemented_error(__FILE__, __LINE__, __func__);\n+}\n+\n+// ==================================================================================== explicit template instantiation\n+#include \"Tools/types.h\"\n+#ifdef MULTI_PREC\n+template class aff3ct::tools::User_pdf_noise_generator_fast<R_32>;\n+template class aff3ct::tools::User_pdf_noise_generator_fast<R_64>;\n+#else\n+template class aff3ct::tools::User_pdf_noise_generator_fast<R>;\n+#endif\n+// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Algo/Draw_generator/User_pdf_noise_generator/Fast/User_pdf_noise_generator_fast.hpp",
"diff": "+#ifndef User_pdf_noise_generator_fast_HPP_\n+#define User_pdf_noise_generator_fast_HPP_\n+\n+#include \"Tools/Algo/PRNG/PRNG_MT19937.hpp\"\n+#include \"Tools/Algo/PRNG/PRNG_MT19937_simd.hpp\"\n+#include \"Tools/Math/interpolation.h\"\n+\n+#include \"../User_pdf_noise_generator.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+\n+template <typename R = float>\n+class User_pdf_noise_generator_fast : public User_pdf_noise_generator<R>\n+{\n+private:\n+ tools::PRNG_MT19937 mt19937; // Mersenne Twister 19937 (scalar)\n+ tools::PRNG_MT19937_simd mt19937_simd; // Mersenne Twister 19937 (SIMD)\n+\n+ R (*interp_function)(const R*, const R*, const unsigned, const R);\n+\n+public:\n+ explicit User_pdf_noise_generator_fast(const tools::Distributions<R>& dists, const int seed = 0, Interpolation_type inter_type = Interpolation_type::NEAREST);\n+ virtual ~User_pdf_noise_generator_fast() = default;\n+\n+ virtual void set_seed(const int seed);\n+\n+ virtual void generate( R *draw, const unsigned length, const R noise_power);\n+ virtual void generate(const R* signal, R *draw, const unsigned length, const R noise_power);\n+\n+private:\n+ inline mipp::Reg<R> get_random_simd();\n+ inline R get_random ();\n+};\n+\n+template <typename R = float>\n+using User_pdf_gen_fast = User_pdf_noise_generator_fast<R>;\n+}\n+}\n+\n+#endif /* User_pdf_noise_generator_fast_HPP_ */\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Algo/Draw_generator/User_pdf_noise_generator/GSL/User_pdf_noise_generator_GSL.cpp",
"diff": "+#ifdef CHANNEL_GSL\n+\n+#include <sstream>\n+\n+#include \"Tools/Exception/exception.hpp\"\n+#include \"User_pdf_noise_generator_GSL.hpp\"\n+\n+using namespace aff3ct;\n+using namespace aff3ct::tools;\n+\n+template <typename R>\n+User_pdf_noise_generator_GSL<R>\n+::User_pdf_noise_generator_GSL(const tools::Distributions<R>& dists, const int seed, Interpolation_type inter_type)\n+: User_pdf_noise_generator<R>(dists), rng(gsl_rng_alloc(gsl_rng_mt19937)), interp_function(nullptr)\n+{\n+ this->set_seed(seed);\n+\n+ switch (inter_type)\n+ {\n+ case Interpolation_type::LINEAR:\n+ interp_function = tools::linear_interpolation<R>;\n+ break;\n+\n+ case Interpolation_type::NEAREST:\n+ interp_function = tools::nearest_interpolation<R>;\n+ break;\n+ }\n+}\n+\n+template <typename R>\n+User_pdf_noise_generator_GSL<R>\n+::~User_pdf_noise_generator_GSL()\n+{\n+ gsl_rng_free(rng);\n+}\n+\n+template <typename R>\n+void User_pdf_noise_generator_GSL<R>\n+::set_seed(const int seed)\n+{\n+ gsl_rng_set(rng, seed);\n+}\n+\n+template <typename R>\n+void User_pdf_noise_generator_GSL<R>\n+::generate(const R* signal, R *draw, const unsigned length, const R noise_power)\n+{\n+ auto dis = this->distributions.get_distribution(noise_power);\n+\n+ for (unsigned i = 0; i < length; i++)\n+ {\n+ const auto& cdf_y = signal[i] ? dis.get_cdf_y()[1] : dis.get_cdf_y()[0];\n+ const auto& cdf_x = signal[i] ? dis.get_cdf_x()[1] : dis.get_cdf_x()[0];\n+ const auto uni_draw = gsl_ran_flat(rng, (R)0, (R)1);\n+ draw[i] = interp_function(cdf_y.data(), cdf_x.data(), cdf_x.size(), uni_draw);\n+ }\n+}\n+\n+template <typename R>\n+void User_pdf_noise_generator_GSL<R>\n+::generate(R *draw, const unsigned length, const R noise_power)\n+{\n+ throw unimplemented_error(__FILE__, __LINE__, __func__);\n+}\n+\n+// ==================================================================================== explicit template instantiation\n+#include \"Tools/types.h\"\n+#ifdef MULTI_PREC\n+template class aff3ct::tools::User_pdf_noise_generator_GSL<R_32>;\n+template class aff3ct::tools::User_pdf_noise_generator_GSL<R_64>;\n+#else\n+template class aff3ct::tools::User_pdf_noise_generator_GSL<R>;\n+#endif\n+// ==================================================================================== explicit template instantiation\n+\n+\n+#endif // GSL\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Algo/Draw_generator/User_pdf_noise_generator/GSL/User_pdf_noise_generator_GSL.hpp",
"diff": "+#ifdef CHANNEL_GSL\n+\n+#ifndef User_pdf_noise_generator_GSL_HPP_\n+#define User_pdf_noise_generator_GSL_HPP_\n+\n+#include <gsl/gsl_randist.h>\n+#include <gsl/gsl_rng.h>\n+\n+#include \"Tools/Math/interpolation.h\"\n+\n+#include \"../User_pdf_noise_generator.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+\n+template <typename R = float>\n+class User_pdf_noise_generator_GSL : public User_pdf_noise_generator<R>\n+{\n+private:\n+ gsl_rng *rng;\n+\n+ R (*interp_function)(const R*, const R*, const unsigned, const R);\n+\n+public:\n+ explicit User_pdf_noise_generator_GSL(const tools::Distributions<R>& dists, const int seed = 0, Interpolation_type inter_type = Interpolation_type::NEAREST);\n+ virtual ~User_pdf_noise_generator_GSL();\n+\n+ virtual void set_seed(const int seed);\n+\n+ virtual void generate( R *draw, const unsigned length, const R noise_power);\n+ virtual void generate(const R* signal, R *draw, const unsigned length, const R noise_power);\n+};\n+\n+template <typename R = float>\n+using User_pdf_gen_GSL = User_pdf_noise_generator_GSL<R>;\n+}\n+}\n+\n+#endif /* User_pdf_noise_generator_GSL_HPP_ */\n+\n+\n+#endif // GSL\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Algo/Draw_generator/User_pdf_noise_generator/MKL/User_pdf_noise_generator_MKL.cpp",
"diff": "+#ifdef CHANNEL_MKL\n+\n+#include <sstream>\n+\n+#include \"Tools/Exception/exception.hpp\"\n+#include \"User_pdf_noise_generator_MKL.hpp\"\n+\n+using namespace aff3ct;\n+using namespace aff3ct::tools;\n+\n+template <typename R>\n+User_pdf_noise_generator_MKL<R>\n+::User_pdf_noise_generator_MKL(const tools::Distributions<R>& dists, const int seed, Interpolation_type inter_type)\n+: User_pdf_noise_generator<R>(dists), stream_state(nullptr), is_stream_alloc(false), interp_function(nullptr)\n+{\n+ this->set_seed(seed);\n+\n+ switch (inter_type)\n+ {\n+ case Interpolation_type::LINEAR:\n+ interp_function = tools::linear_interpolation<R>;\n+ break;\n+\n+ case Interpolation_type::NEAREST:\n+ interp_function = tools::nearest_interpolation<R>;\n+ break;\n+ }\n+}\n+\n+template <typename R>\n+void User_pdf_noise_generator_MKL<R>\n+::set_seed(const int seed)\n+{\n+ if (is_stream_alloc) vslDeleteStream(&stream_state);\n+\n+ //vslNewStream(&stream_state, VSL_BRNG_MT2203, seed);\n+ vslNewStream(&stream_state, VSL_BRNG_SFMT19937, seed);\n+\n+ is_stream_alloc = true;\n+}\n+\n+template <typename R>\n+void User_pdf_noise_generator_MKL<R>\n+::generate(const R* signal, R *draw, const unsigned length, const R noise_power)\n+{\n+ auto dis = this->distributions.get_distribution(noise_power);\n+\n+ vsRngUniform(VSL_RNG_METHOD_UNIFORM_STD, stream_state, length, draw, (R)0, (R)1);\n+\n+\n+ for (unsigned i = 0; i < length; i++)\n+ {\n+ const auto& cdf_y = signal[i] ? dis.get_cdf_y()[1] : dis.get_cdf_y()[0];\n+ const auto& cdf_x = signal[i] ? dis.get_cdf_x()[1] : dis.get_cdf_x()[0];\n+ draw[i] = interp_function(cdf_y.data(), cdf_x.data(), cdf_x.size(), draw[i]);\n+ }\n+}\n+\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+\n+template <>\n+void User_pdf_noise_generator_MKL<double>\n+::generate(const double* signal, double *draw, const unsigned length, const double noise_power)\n+{\n+ auto dis = this->distributions.get_distribution(noise_power);\n+\n+ vdRngUniform(VSL_RNG_METHOD_UNIFORM_STD, stream_state, length, draw, (double)0, (double)1);\n+\n+\n+ for (unsigned i = 0; i < length; i++)\n+ {\n+ const auto& cdf_y = signal[i] ? dis.get_cdf_y()[1] : dis.get_cdf_y()[0];\n+ const auto& cdf_x = signal[i] ? dis.get_cdf_x()[1] : dis.get_cdf_x()[0];\n+ draw[i] = interp_function(cdf_y.data(), cdf_x.data(), cdf_x.size(), draw[i]);\n+ }\n+}\n+}\n+}\n+\n+template <typename R>\n+void User_pdf_noise_generator_MKL<R>\n+::generate(R *draw, const unsigned length, const R noise_power)\n+{\n+ throw unimplemented_error(__FILE__, __LINE__, __func__);\n+}\n+\n+// ==================================================================================== explicit template instantiation\n+#include \"Tools/types.h\"\n+#ifdef MULTI_PREC\n+template class aff3ct::tools::User_pdf_noise_generator_MKL<R_32>;\n+template class aff3ct::tools::User_pdf_noise_generator_MKL<R_64>;\n+#else\n+template class aff3ct::tools::User_pdf_noise_generator_MKL<R>;\n+#endif\n+// ==================================================================================== explicit template instantiation\n+\n+#endif // MKL\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Algo/Draw_generator/User_pdf_noise_generator/MKL/User_pdf_noise_generator_MKL.hpp",
"diff": "+#ifdef CHANNEL_MKL\n+\n+#ifndef User_pdf_noise_generator_MKL_HPP_\n+#define User_pdf_noise_generator_MKL_HPP_\n+\n+#include <mkl_vsl.h>\n+\n+#include \"Tools/Math/interpolation.h\"\n+\n+#include \"../User_pdf_noise_generator.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+\n+template <typename R = float>\n+class User_pdf_noise_generator_MKL : public User_pdf_noise_generator<R>\n+{\n+private:\n+ VSLStreamStatePtr stream_state;\n+ bool is_stream_alloc;\n+\n+ R (*interp_function)(const R*, const R*, const unsigned, const R);\n+\n+public:\n+ explicit User_pdf_noise_generator_MKL(const tools::Distributions<R>& dists, const int seed = 0, Interpolation_type inter_type = Interpolation_type::NEAREST);\n+ virtual ~User_pdf_noise_generator_MKL() = default;\n+\n+ virtual void set_seed(const int seed);\n+\n+ virtual void generate( R *draw, const unsigned length, const R noise_power);\n+ virtual void generate(const R* signal, R *draw, const unsigned length, const R noise_power);\n+};\n+\n+template <typename R = float>\n+using User_pdf_gen_MKL = User_pdf_noise_generator_MKL<R>;\n+}\n+}\n+\n+#endif /* User_pdf_noise_generator_MKL_HPP_ */\n+\n+#endif // MKL\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add user_pdf noise generator MKL, GSL and MIPP versions
|
8,483 |
14.05.2018 08:31:24
| -7,200 |
d2ad1729fa810263d3d945e74884fcab99312532
|
Clear the main.cpp and remove unused files
|
[
{
"change_type": "DELETE",
"old_path": "src/Tools/Perf/common.cpp",
"new_path": null,
"diff": "-#include <limits>\n-#include <algorithm>\n-#include <mipp.h>\n-\n-#include \"common.h\"\n-\n-//********************************************************************************************************** hard_decide\n-\n-template <typename B, typename Q>\n-void aff3ct::tools::hard_decide(const Q *in, B *out, const int size)\n-{\n- const auto vec_loop_size = (size / mipp::nElReg<Q>()) * mipp::nElReg<Q>();\n- if (mipp::isAligned(in) && mipp::isAligned(out))\n- {\n- for (auto i = 0; i < vec_loop_size; i += mipp::nElReg<Q>())\n- {\n- const auto q_in = mipp::Reg<Q>(&in[i]);\n- const auto q_out = mipp::cast<Q,B>(q_in) >> (sizeof(B) * 8 - 1);\n- q_out.store(&out[i]);\n- }\n- }\n- else\n- {\n- for (auto i = 0; i < vec_loop_size; i += mipp::nElReg<Q>())\n- {\n- mipp::Reg<Q> q_in;\n- q_in.loadu(&in[i]);\n- const auto q_out = mipp::cast<Q,B>(q_in) >> (sizeof(B) * 8 - 1);\n- q_out.storeu(&out[i]);\n- }\n- }\n- for (auto i = vec_loop_size; i < size; i++)\n- out[i] = in[i] < 0;\n-}\n-\n-\n-\n-//************************************************************************************************* hamming_distance_seq\n-\n-template <typename B>\n-inline size_t aff3ct::tools::hamming_distance_seq(const B *in1, const B *in2, const int size)\n-{\n- size_t ham_dist = 0;\n-\n- for (auto i = 0; i < size; i++)\n- ham_dist += (!in1[i] != !in2[i])? (size_t)1 : (size_t)0;\n-\n- return ham_dist;\n-}\n-\n-\n-\n-//***************************************************************************************************** hamming_distance\n-\n-#ifdef MIPP_AVX1\n-\n-template <typename B>\n-size_t aff3ct::tools::hamming_distance(const B *in1, const B *in2, const int size)\n-{\n- return hamming_distance_seq(in1, in2, size);\n-}\n-\n-#else\n-\n-template <typename B>\n-inline mipp::Reg<B> popcnt(const mipp::Reg<B>& q_in1, const mipp::Reg<B>& q_in2)\n-{\n- const mipp::Reg<B> zeros = (B)0, ones = (B)1;\n- const auto m_in1 = q_in1 != zeros;\n- const auto m_in2 = q_in2 != zeros;\n- return mipp::blend(ones, zeros, m_in1 ^ m_in2);\n-}\n-\n-template <typename B>\n-size_t aff3ct::tools::hamming_distance(const B *in1, const B *in2, const int size)\n-{\n- mipp::Reg<B> counter = (B)0;\n-\n- const auto vec_loop_size = (size / mipp::N<B>()) * mipp::N<B>();\n-\n- for (auto i = 0; i < vec_loop_size; i += mipp::N<B>())\n- counter += popcnt<B>(in1 + i, in2 + i);\n-\n- size_t ham_dist = mipp::hadd(counter);\n-\n- ham_dist += tools::hamming_distance_seq(in1 + vec_loop_size, in2 + vec_loop_size, size - vec_loop_size);\n-\n- return ham_dist;\n-}\n-\n-namespace aff3ct\n-{\n-namespace tools\n-{\n-template <>\n-size_t hamming_distance<int16_t>(const int16_t *in1, const int16_t *in2, const int size)\n-{\n-#ifdef MIPP_BW\n- mipp::Reg<int32_t> counter32 = (int32_t)0;\n-\n- const auto vec_loop_size = mipp::N<int16_t>() < 2 ? 0 : (size / mipp::N<int16_t>()) * mipp::N<int16_t>();\n- constexpr auto stride = std::numeric_limits<int16_t>::max() * mipp::N<int16_t>();\n- for (auto ii = 0; ii < vec_loop_size; ii += stride)\n- {\n- mipp::Reg<int16_t> counter16 = (int16_t)0;\n- const auto vec_loop_size2 = std::min(vec_loop_size, ii + stride);\n- for (auto i = ii; i < vec_loop_size2; i += mipp::N<int16_t>())\n- counter16 += popcnt<int16_t>(in1 + i, in2 + i);\n-\n- counter32 += mipp::cvt<int16_t,int32_t>(counter16.low ());\n- counter32 += mipp::cvt<int16_t,int32_t>(counter16.high());\n- }\n-\n- size_t ham_dist = (size_t)mipp::hadd(counter32);\n-#else\n- const auto vec_loop_size = 0;\n- size_t ham_dist = 0;\n-#endif\n-\n- ham_dist += tools::hamming_distance_seq<int16_t>(in1 + vec_loop_size, in2 + vec_loop_size, size - vec_loop_size);\n-\n- return ham_dist;\n-}\n-\n-template <>\n-size_t hamming_distance<int8_t>(const int8_t *in1, const int8_t *in2, const int size)\n-{\n-#ifdef MIPP_BW\n- const mipp::Reg<int8_t> zeros = (int8_t)0, ones = (int8_t)1;\n- mipp::Reg<int32_t> counter32 = (int32_t)0;\n-\n- const auto vec_loop_size = mipp::N<int8_t>() < 4 ? 0 : (size / mipp::N<int8_t>()) * mipp::N<int8_t>();\n- constexpr auto stride = std::numeric_limits<int8_t>::max() * mipp::N<int8_t>();\n- for (auto ii = 0; ii < vec_loop_size; ii += stride)\n- {\n- mipp::Reg<int8_t> counter8 = (int8_t)0;\n- const auto vec_loop_size2 = std::min(vec_loop_size, ii + stride);\n- for (auto i = ii; i < vec_loop_size2; i += mipp::N<int8_t>())\n- counter8 += popcnt<int8_t>(in1 + i, in2 + i);\n-\n- const auto low = mipp::cvt<int8_t,int16_t>(counter8.low());\n- counter32 += mipp::cvt<int16_t,int32_t>(low.low ());\n- counter32 += mipp::cvt<int16_t,int32_t>(low.high());\n-\n- const auto high = mipp::cvt<int8_t,int16_t>(counter8.high());\n- counter32 += mipp::cvt<int16_t,int32_t>(high.low ());\n- counter32 += mipp::cvt<int16_t,int32_t>(high.high());\n- }\n-\n- size_t ham_dist = (size_t)mipp::hadd(counter32);\n-\n-#else\n- const auto vec_loop_size = 0;\n- size_t ham_dist = 0;\n-#endif\n-\n- ham_dist += tools::hamming_distance_seq<int8_t>(in1 + vec_loop_size, in2 + vec_loop_size, size - vec_loop_size);\n-\n- return ham_dist;\n-}\n-}\n-}\n-\n-#endif // #ifdef MIPP_AVX\n-\n-// ==================================================================================== explicit template instantiation\n-#include \"Tools/types.h\"\n-#ifdef MULTI_PREC\n-template size_t aff3ct::tools::hamming_distance<B_8 >(const B_8*, const B_8*, const int);\n-template size_t aff3ct::tools::hamming_distance<B_16>(const B_16*, const B_16*, const int);\n-template size_t aff3ct::tools::hamming_distance<B_32>(const B_32*, const B_32*, const int);\n-template size_t aff3ct::tools::hamming_distance<B_64>(const B_64*, const B_64*, const int);\n-#else\n-template size_t aff3ct::tools::hamming_distance<B>(const B*, const B*, const int);\n-#endif\n-\n-#ifdef MULTI_PREC\n-template void aff3ct::tools::hard_decide<B_8, Q_8 >(const Q_8*, B_8*, const int);\n-template void aff3ct::tools::hard_decide<B_16, Q_16>(const Q_16*, B_16*, const int);\n-template void aff3ct::tools::hard_decide<B_32, Q_32>(const Q_32*, B_32*, const int);\n-template void aff3ct::tools::hard_decide<B_64, Q_64>(const Q_64*, B_64*, const int);\n-#else\n-template void aff3ct::tools::hard_decide<B, Q>(const Q*, B*, const int);\n-#endif\n-\n-#ifdef MULTI_PREC\n-template size_t aff3ct::tools::hamming_distance_seq<B_8 >(const B_8*, const B_8*, const int);\n-template size_t aff3ct::tools::hamming_distance_seq<B_16>(const B_16*, const B_16*, const int);\n-template size_t aff3ct::tools::hamming_distance_seq<B_32>(const B_32*, const B_32*, const int);\n-template size_t aff3ct::tools::hamming_distance_seq<B_64>(const B_64*, const B_64*, const int);\n-#else\n-template size_t aff3ct::tools::hamming_distance_seq<B>(const B*, const B*, const int);\n-#endif\n-\n-// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "DELETE",
"old_path": "src/Tools/Perf/common.h",
"new_path": null,
"diff": "-#ifndef COMMON_H_\n-#define COMMON_H_\n-\n-#include <cstdint>\n-#include <cstddef>\n-\n-namespace aff3ct\n-{\n-namespace tools\n-{\n-/*\n- * take the hard decision on the array 'in' and fill 'out', both of length 'size'\n- */\n-template <typename B = int, typename Q = float>\n-void hard_decide(const Q *in, B *out, const int size);\n-\n-/*\n- * compute the Hamming distance between the arrays 'in1' and 'in2' of length 'size'\n- */\n-template <typename B = int32_t>\n-size_t hamming_distance_seq(const B *in1, const B *in2, const int size);\n-\n-/*\n- * compute the Hamming distance between the arrays 'in1' and 'in2' of length 'size'\n- * Operations are optimized with MIPP except for AVX architecture that call hamming_distance_seq.\n- */\n-template <typename B = int32_t>\n-size_t hamming_distance(const B *in1, const B *in2, const int size);\n-}\n-}\n-\n-#endif /* COMMON_H_ */\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/aff3ct.hpp",
"new_path": "src/aff3ct.hpp",
"diff": "#include <Tools/Perf/common/hamming_distance.h>\n#include <Tools/Perf/common/hard_decide.h>\n#include <Tools/Perf/common/mutual_info.h>\n-#include <Tools/Perf/common.h>\n#include <Tools/Perf/Transpose/transpose_AVX.h>\n#include <Tools/Perf/Transpose/transpose_NEON.h>\n#include <Tools/Perf/Transpose/transpose_selector.h>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/main.cpp",
"new_path": "src/main.cpp",
"diff": "@@ -170,36 +170,3 @@ int sc_main(int argc, char **argv)\nreturn exit_code;\n}\n\\ No newline at end of file\n-\n-// #include <aff3ct.hpp>\n-// #include \"Tools/Algo/histogram.h\"\n-\n-// int main(int argc, char **argv)\n-// {\n-// using namespace aff3ct;\n-\n-// using T = float;\n-\n-// const R ROP = -35.2;\n-// std::vector<T> px = {-0.0191885880000000, -0.0146338349447236, -0.0100790818894472, -0.00552432883417085, -0.000969575778894474, 0.00358517727638191, 0.00813993033165830, 0.0126946833869347, 0.0172494364422111, 0.0218041894974874, 0.0263589425527638, 0.0309136956080402, 0.0354684486633166, 0.0400232017185930, 0.0445779547738694, 0.0491327078291457, 0.0536874608844221, 0.0582422139396985, 0.0627969669949749, 0.0673517200502513, 0.0719064731055276, 0.0764612261608040, 0.0810159792160804, 0.0855707322713568, 0.0901254853266332, 0.0946802383819096, 0.0992349914371860, 0.103789744492462, 0.108344497547739, 0.112899250603015, 0.117454003658291, 0.122008756713568, 0.126563509768844, 0.131118262824121, 0.135673015879397, 0.140227768934673, 0.144782521989950, 0.149337275045226, 0.153892028100503, 0.158446781155779, 0.163001534211055, 0.167556287266332, 0.172111040321608, 0.176665793376884, 0.181220546432161, 0.185775299487437, 0.190330052542714, 0.194884805597990, 0.199439558653266, 0.203994311708543, 0.208549064763819, 0.213103817819095, 0.217658570874372, 0.222213323929648, 0.226768076984925, 0.231322830040201, 0.235877583095477, 0.240432336150754, 0.244987089206030, 0.249541842261307, 0.254096595316583, 0.258651348371859, 0.263206101427136, 0.267760854482412, 0.272315607537688, 0.276870360592965, 0.281425113648241, 0.285979866703518, 0.290534619758794, 0.295089372814070, 0.299644125869347, 0.304198878924623, 0.308753631979899, 0.313308385035176, 0.317863138090452, 0.322417891145729, 0.326972644201005, 0.331527397256281, 0.336082150311558, 0.340636903366834, 0.345191656422111, 0.349746409477387, 0.354301162532663, 0.358855915587940, 0.363410668643216, 0.367965421698493, 0.372520174753769, 0.377074927809045, 0.381629680864322, 0.386184433919598, 0.390739186974874, 0.395293940030151, 0.399848693085427, 0.404403446140704, 0.408958199195980, 0.413512952251256, 0.418067705306533, 0.422622458361809, 0.427177211417085, 0.431731964472362, 0.436286717527638, 0.440841470582915, 0.445396223638191, 0.449950976693467, 0.454505729748744, 0.459060482804020, 0.463615235859297, 0.468169988914573, 0.472724741969849, 0.477279495025126, 0.481834248080402, 0.486389001135678, 0.490943754190955, 0.495498507246231, 0.500053260301508, 0.504608013356784, 0.509162766412060, 0.513717519467337, 0.518272272522613, 0.522827025577890, 0.527381778633166, 0.531936531688442, 0.536491284743719, 0.541046037798995, 0.545600790854271, 0.550155543909548, 0.554710296964824, 0.559265050020101, 0.563819803075377, 0.568374556130653, 0.572929309185930, 0.577484062241206, 0.582038815296482, 0.586593568351759, 0.591148321407035, 0.595703074462312, 0.600257827517588, 0.604812580572864, 0.609367333628141, 0.613922086683417, 0.618476839738694, 0.623031592793970, 0.627586345849246, 0.632141098904523, 0.636695851959799, 0.641250605015075, 0.645805358070352, 0.650360111125628, 0.654914864180905, 0.659469617236181, 0.664024370291457, 0.668579123346734, 0.673133876402010, 0.677688629457286, 0.682243382512563, 0.686798135567839, 0.691352888623116, 0.695907641678392, 0.700462394733668, 0.705017147788945, 0.709571900844221, 0.714126653899498, 0.718681406954774, 0.723236160010050, 0.727790913065327, 0.732345666120603, 0.736900419175879, 0.741455172231156, 0.746009925286432, 0.750564678341709, 0.755119431396985, 0.759674184452261, 0.764228937507538, 0.768783690562814, 0.773338443618091, 0.777893196673367, 0.782447949728643, 0.787002702783920, 0.791557455839196, 0.796112208894472, 0.800666961949749, 0.805221715005025, 0.809776468060302, 0.814331221115578, 0.818885974170854, 0.823440727226131, 0.827995480281407, 0.832550233336683, 0.837104986391960, 0.841659739447236, 0.846214492502513, 0.850769245557789, 0.855323998613065, 0.859878751668342, 0.864433504723618, 0.868988257778894, 0.873543010834171, 0.878097763889447, 0.882652516944724, 0.887207270000000};\n-// std::vector<T> p1 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.000505050505050505, 0.000505050505050505, 0, 0.00101010101010101, 0.000505050505050505, 0.00101010101010101, 0, 0.000505050505050505, 0.00101010101010101, 0, 0.000505050505050505, 0.00101010101010101, 0.00101010101010101, 0.00353535353535354, 0.00101010101010101, 0.00101010101010101, 0.00353535353535354, 0.00353535353535354, 0.00454545454545455, 0.00353535353535354, 0.00505050505050505, 0.00555555555555556, 0.00606060606060606, 0.00656565656565657, 0.00505050505050505, 0.00757575757575758, 0.00555555555555556, 0.0101010101010101, 0.00656565656565657, 0.0101010101010101, 0.00707070707070707, 0.0106060606060606, 0.0121212121212121, 0.0131313131313131, 0.0146464646464646, 0.0146464646464646, 0.0156565656565657, 0.0186868686868687, 0.0232323232323232, 0.0176767676767677, 0.0161616161616162, 0.0237373737373737, 0.0111111111111111, 0.0176767676767677, 0.0131313131313131, 0.0222222222222222, 0.0176767676767677, 0.0207070707070707, 0.0207070707070707, 0.0242424242424242, 0.0161616161616162, 0.0186868686868687, 0.0191919191919192, 0.0202020202020202, 0.0212121212121212, 0.0212121212121212, 0.0166666666666667, 0.0196969696969697, 0.0217171717171717, 0.0202020202020202, 0.0222222222222222, 0.0156565656565657, 0.0131313131313131, 0.0186868686868687, 0.0151515151515152, 0.0181818181818182, 0.0131313131313131, 0.0151515151515152, 0.0171717171717172, 0.0136363636363636, 0.0181818181818182, 0.0106060606060606, 0.0131313131313131, 0.0111111111111111, 0.0131313131313131, 0.00808080808080808, 0.00959595959595960, 0.00808080808080808, 0.0106060606060606, 0.0101010101010101, 0.00606060606060606, 0.00606060606060606, 0.00808080808080808, 0.00656565656565657, 0.00505050505050505, 0.00808080808080808, 0.00555555555555556, 0.00505050505050505, 0.00505050505050505, 0.00101010101010101, 0.00404040404040404, 0.00353535353535354, 0.00353535353535354, 0.00202020202020202, 0.00404040404040404, 0.00151515151515152, 0.00202020202020202, 0.00252525252525253, 0.00303030303030303, 0.00101010101010101, 0.000505050505050505, 0.000505050505050505, 0.00252525252525253, 0.00101010101010101, 0, 0.000505050505050505, 0.00151515151515152, 0.00151515151515152, 0.000505050505050505, 0.00151515151515152, 0.000505050505050505, 0.00202020202020202, 0.000505050505050505, 0, 0, 0, 0.000505050505050505, 0.000505050505050505, 0.000505050505050505, 0, 0, 0, 0, 0.000505050505050505, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};\n-// std::vector<T> p0 = {0, 0.00101214574898785, 0.00101214574898785, 0.00455465587044534, 0.0177125506072875, 0.0339068825910931, 0.0455465587044534, 0.0632591093117409, 0.0713562753036437, 0.0804655870445344, 0.0885627530364373, 0.0779352226720648, 0.0683198380566802, 0.0819838056680162, 0.0668016194331984, 0.0460526315789474, 0.0546558704453441, 0.0430161943319838, 0.0278340080971660, 0.0298582995951417, 0.0161943319838057, 0.0161943319838057, 0.0121457489878543, 0.0101214574898785, 0.0121457489878543, 0.00607287449392713, 0.00556680161943320, 0.00556680161943320, 0.00455465587044534, 0.00253036437246964, 0.00354251012145749, 0.000506072874493927, 0.00101214574898785, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};\n-\n-// unsigned noise_length = 1e6;\n-// std::vector<T> noise(noise_length);\n-\n-// tools::User_pdf_gen_std<T> noise_gene0;\n-// noise_gene0.add_distribution(ROP, new tools::Distribution<T>(px, p0));\n-// noise_gene0.generate(noise.data(), noise_length, ROP);\n-\n-// std::ofstream file0(\"aff3ct_noise0.csv\");\n-// histogram(file0, noise, noise_gene0.get_distribution(ROP)->get_min_x(), noise_gene0.get_distribution(ROP)->get_max_x());\n-\n-// tools::User_pdf_gen_std<T> noise_gene1;\n-// noise_gene1.add_distribution(ROP, new tools::Distribution<T>(px, p1));\n-// noise_gene1.generate(noise.data(), noise_length, ROP);\n-\n-// std::ofstream file1(\"aff3ct_noise1.csv\");\n-// histogram(file1, noise, noise_gene1.get_distribution(ROP)->get_min_x(), noise_gene1.get_distribution(ROP)->get_max_x());\n-\n-// }\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Clear the main.cpp and remove unused files
|
8,483 |
14.05.2018 09:21:11
| -7,200 |
5f703746e646d14a7b491c2febd1a9607243da21
|
Remove LLR histogram comments; Change Monitors from Q to R type for mutinfo at the output of the demodulator
|
[
{
"change_type": "MODIFY",
"old_path": "ci/test-regression.py",
"new_path": "ci/test-regression.py",
"diff": "@@ -545,14 +545,25 @@ for fn in fileNames:\nif errAndWarnMessages:\nprint(\"---- Error message(s):\", end=\"\\n\");\nprint(errAndWarnMessages)\n- nErrors = nErrors +1\n+ nErrors += 1\nfailIds.append(testId +1)\n- elif not simuCur.NoiseType == simuRef.NoiseType:\n- failIds.append(testId +1)\n+ for i in range(len(stdOutput)):\n+ fRes.write(stdOutput[i] + \"\\n\")\n+ for i in range(len(errAndWarnMessages)):\n+ fRes.write(errAndWarnMessages[i] + \"\\n\")\n+\n+ elif simuCur.NoiseType != simuRef.NoiseType:\nnErrors += 1\n+ failIds.append(testId +1)\n+\nprint(\" - NOISE TYPE MISMATCH: \" + simuRef.NoiseType + \" vs \" + simuCur.NoiseType + \".\", end=\"\\n\");\n+ for i in range(len(stdOutput)):\n+ fRes.write(stdOutput[i] + \"\\n\")\n+ for i in range(len(errAndWarnMessages)):\n+ fRes.write(errAndWarnMessages[i] + \"\\n\")\n+\nelse:\n# parse the results to validate (or not) the BER/FER/MI performance\ncomp = compStats(simuCur, simuRef, args.sensibility)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Monitor/BFER/Monitor_BFER.cpp",
"new_path": "src/Factory/Module/Monitor/BFER/Monitor_BFER.cpp",
"diff": "@@ -114,16 +114,16 @@ module::Monitor_BFER<B,R>* Monitor_BFER\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n-template aff3ct::module::Monitor_BFER<B_8 ,Q_8 >* aff3ct::factory::Monitor_BFER::parameters::build<B_8, Q_8 >() const;\n-template aff3ct::module::Monitor_BFER<B_16,Q_16>* aff3ct::factory::Monitor_BFER::parameters::build<B_16,Q_16>() const;\n-template aff3ct::module::Monitor_BFER<B_32,Q_32>* aff3ct::factory::Monitor_BFER::parameters::build<B_32,Q_32>() const;\n-template aff3ct::module::Monitor_BFER<B_64,Q_64>* aff3ct::factory::Monitor_BFER::parameters::build<B_64,Q_64>() const;\n-template aff3ct::module::Monitor_BFER<B_8 ,Q_8 >* aff3ct::factory::Monitor_BFER::build<B_8, Q_8 >(const aff3ct::factory::Monitor_BFER::parameters&);\n-template aff3ct::module::Monitor_BFER<B_16,Q_16>* aff3ct::factory::Monitor_BFER::build<B_16,Q_16>(const aff3ct::factory::Monitor_BFER::parameters&);\n-template aff3ct::module::Monitor_BFER<B_32,Q_32>* aff3ct::factory::Monitor_BFER::build<B_32,Q_32>(const aff3ct::factory::Monitor_BFER::parameters&);\n-template aff3ct::module::Monitor_BFER<B_64,Q_64>* aff3ct::factory::Monitor_BFER::build<B_64,Q_64>(const aff3ct::factory::Monitor_BFER::parameters&);\n+template aff3ct::module::Monitor_BFER<B_8 ,R_8 >* aff3ct::factory::Monitor_BFER::parameters::build<B_8, R_8 >() const;\n+template aff3ct::module::Monitor_BFER<B_16,R_16>* aff3ct::factory::Monitor_BFER::parameters::build<B_16,R_16>() const;\n+template aff3ct::module::Monitor_BFER<B_32,R_32>* aff3ct::factory::Monitor_BFER::parameters::build<B_32,R_32>() const;\n+template aff3ct::module::Monitor_BFER<B_64,R_64>* aff3ct::factory::Monitor_BFER::parameters::build<B_64,R_64>() const;\n+template aff3ct::module::Monitor_BFER<B_8 ,R_8 >* aff3ct::factory::Monitor_BFER::build<B_8, R_8 >(const aff3ct::factory::Monitor_BFER::parameters&);\n+template aff3ct::module::Monitor_BFER<B_16,R_16>* aff3ct::factory::Monitor_BFER::build<B_16,R_16>(const aff3ct::factory::Monitor_BFER::parameters&);\n+template aff3ct::module::Monitor_BFER<B_32,R_32>* aff3ct::factory::Monitor_BFER::build<B_32,R_32>(const aff3ct::factory::Monitor_BFER::parameters&);\n+template aff3ct::module::Monitor_BFER<B_64,R_64>* aff3ct::factory::Monitor_BFER::build<B_64,R_64>(const aff3ct::factory::Monitor_BFER::parameters&);\n#else\n-template aff3ct::module::Monitor_BFER<B,Q>* aff3ct::factory::Monitor_BFER::parameters::build<B,Q>() const;\n-template aff3ct::module::Monitor_BFER<B,Q>* aff3ct::factory::Monitor_BFER::build<B,Q>(const aff3ct::factory::Monitor_BFER::parameters&);\n+template aff3ct::module::Monitor_BFER<B,R>* aff3ct::factory::Monitor_BFER::parameters::build<B,R>() const;\n+template aff3ct::module::Monitor_BFER<B,R>* aff3ct::factory::Monitor_BFER::build<B,R>(const aff3ct::factory::Monitor_BFER::parameters&);\n#endif\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Tools/Display/Terminal/BFER/Terminal_BFER.cpp",
"new_path": "src/Factory/Tools/Display/Terminal/BFER/Terminal_BFER.cpp",
"diff": "@@ -75,15 +75,15 @@ tools::Terminal_BFER<B,R>* Terminal_BFER\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n-template aff3ct::tools::Terminal_BFER<B_8 ,Q_8 >* aff3ct::factory::Terminal_BFER::parameters::build<B_8 ,Q_8 >(const aff3ct::module::Monitor_BFER<B_8 ,Q_8 >&, const bool) const;\n-template aff3ct::tools::Terminal_BFER<B_16,Q_16>* aff3ct::factory::Terminal_BFER::parameters::build<B_16,Q_16>(const aff3ct::module::Monitor_BFER<B_16,Q_16>&, const bool) const;\n-template aff3ct::tools::Terminal_BFER<B_32,Q_32>* aff3ct::factory::Terminal_BFER::parameters::build<B_32,Q_32>(const aff3ct::module::Monitor_BFER<B_32,Q_32>&, const bool) const;\n-template aff3ct::tools::Terminal_BFER<B_64,Q_64>* aff3ct::factory::Terminal_BFER::parameters::build<B_64,Q_64>(const aff3ct::module::Monitor_BFER<B_64,Q_64>&, const bool) const;\n-template aff3ct::tools::Terminal_BFER<B_8 ,Q_8 >* aff3ct::factory::Terminal_BFER::build<B_8 ,Q_8 >(const aff3ct::factory::Terminal_BFER::parameters&, const aff3ct::module::Monitor_BFER<B_8 ,Q_8 >&, const bool);\n-template aff3ct::tools::Terminal_BFER<B_16,Q_16>* aff3ct::factory::Terminal_BFER::build<B_16,Q_16>(const aff3ct::factory::Terminal_BFER::parameters&, const aff3ct::module::Monitor_BFER<B_16,Q_16>&, const bool);\n-template aff3ct::tools::Terminal_BFER<B_32,Q_32>* aff3ct::factory::Terminal_BFER::build<B_32,Q_32>(const aff3ct::factory::Terminal_BFER::parameters&, const aff3ct::module::Monitor_BFER<B_32,Q_32>&, const bool);\n-template aff3ct::tools::Terminal_BFER<B_64,Q_64>* aff3ct::factory::Terminal_BFER::build<B_64,Q_64>(const aff3ct::factory::Terminal_BFER::parameters&, const aff3ct::module::Monitor_BFER<B_64,Q_64>&, const bool);\n+template aff3ct::tools::Terminal_BFER<B_8 ,R_8 >* aff3ct::factory::Terminal_BFER::parameters::build<B_8 ,R_8 >(const aff3ct::module::Monitor_BFER<B_8 ,R_8 >&, const bool) const;\n+template aff3ct::tools::Terminal_BFER<B_16,R_16>* aff3ct::factory::Terminal_BFER::parameters::build<B_16,R_16>(const aff3ct::module::Monitor_BFER<B_16,R_16>&, const bool) const;\n+template aff3ct::tools::Terminal_BFER<B_32,R_32>* aff3ct::factory::Terminal_BFER::parameters::build<B_32,R_32>(const aff3ct::module::Monitor_BFER<B_32,R_32>&, const bool) const;\n+template aff3ct::tools::Terminal_BFER<B_64,R_64>* aff3ct::factory::Terminal_BFER::parameters::build<B_64,R_64>(const aff3ct::module::Monitor_BFER<B_64,R_64>&, const bool) const;\n+template aff3ct::tools::Terminal_BFER<B_8 ,R_8 >* aff3ct::factory::Terminal_BFER::build<B_8 ,R_8 >(const aff3ct::factory::Terminal_BFER::parameters&, const aff3ct::module::Monitor_BFER<B_8 ,R_8 >&, const bool);\n+template aff3ct::tools::Terminal_BFER<B_16,R_16>* aff3ct::factory::Terminal_BFER::build<B_16,R_16>(const aff3ct::factory::Terminal_BFER::parameters&, const aff3ct::module::Monitor_BFER<B_16,R_16>&, const bool);\n+template aff3ct::tools::Terminal_BFER<B_32,R_32>* aff3ct::factory::Terminal_BFER::build<B_32,R_32>(const aff3ct::factory::Terminal_BFER::parameters&, const aff3ct::module::Monitor_BFER<B_32,R_32>&, const bool);\n+template aff3ct::tools::Terminal_BFER<B_64,R_64>* aff3ct::factory::Terminal_BFER::build<B_64,R_64>(const aff3ct::factory::Terminal_BFER::parameters&, const aff3ct::module::Monitor_BFER<B_64,R_64>&, const bool);\n#else\n-template aff3ct::tools::Terminal_BFER<B,Q>* aff3ct::factory::Terminal_BFER::parameters::build<B,Q>(const aff3ct::module::Monitor_BFER<B,Q>&, const bool) const;\n-template aff3ct::tools::Terminal_BFER<B,Q>* aff3ct::factory::Terminal_BFER::build<B,Q>(const aff3ct::factory::Terminal_BFER::parameters&, const aff3ct::module::Monitor_BFER<B,Q>&, const bool);\n+template aff3ct::tools::Terminal_BFER<B,R>* aff3ct::factory::Terminal_BFER::parameters::build<B,R>(const aff3ct::module::Monitor_BFER<B,R>&, const bool) const;\n+template aff3ct::tools::Terminal_BFER<B,R>* aff3ct::factory::Terminal_BFER::build<B,R>(const aff3ct::factory::Terminal_BFER::parameters&, const aff3ct::module::Monitor_BFER<B,R>&, const bool);\n#endif\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"diff": "@@ -72,13 +72,7 @@ R Monitor_BFER<B,R>\nY + f * this->N,\nf);\n-// for(auto i = 0; i < this->n_frames*this->N ; i++)\n-// if (X[i])\n-// this->llrs1.add_value(Y[i]);\n-// else\n-// this->llrs0.add_value(Y[i]);\n-\n- return MI_sum / (R)this->n_frames * 10000; // return the mut info %10000 instead of %100\n+ return MI_sum / (R)(f_stop - f_start) * 10000; // return the mut info %10000 instead of %100\n}\ntemplate <typename B, typename R>\n@@ -259,8 +253,6 @@ void Monitor_BFER<B,R>\nthis->n_frame_errors = 0;\nthis->n_analyzed_frames = 0;\nthis->MI_sum = 0;\n-// this->llrs0.reset();\n-// this->llrs1.reset();\nthis->err_hist.reset();\n}\n@@ -279,26 +271,14 @@ tools::Histogram<int> Monitor_BFER<B, R>::get_err_hist() const\nreturn err_hist;\n}\n-//template<typename B, typename R>\n-//const tools::Histogram<R>& Monitor_BFER<B, R>::get_llrs1()\n-//{\n-// return llrs1;\n-//}\n-//\n-//template<typename B, typename R>\n-//const tools::Histogram<R>& Monitor_BFER<B, R>::get_llrs0()\n-//{\n-// return llrs0;\n-//}\n-\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n-template class aff3ct::module::Monitor_BFER<B_8, Q_8>;\n-template class aff3ct::module::Monitor_BFER<B_16,Q_16>;\n-template class aff3ct::module::Monitor_BFER<B_32,Q_32>;\n-template class aff3ct::module::Monitor_BFER<B_64,Q_64>;\n+template class aff3ct::module::Monitor_BFER<B_8, R_8>;\n+template class aff3ct::module::Monitor_BFER<B_16,R_16>;\n+template class aff3ct::module::Monitor_BFER<B_32,R_32>;\n+template class aff3ct::module::Monitor_BFER<B_64,R_64>;\n#else\n-template class aff3ct::module::Monitor_BFER<B,Q>;\n+template class aff3ct::module::Monitor_BFER<B,R>;\n#endif\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER.hpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER.hpp",
"diff": "@@ -32,7 +32,6 @@ protected:\nstd::vector<std::function<void(unsigned, int )>> callbacks_fe;\nstd::vector<std::function<void( void)>> callbacks_check;\nstd::vector<std::function<void( void)>> callbacks_fe_limit_achieved;\n-// tools::Histogram<R> llrs0, llrs1;\ntools::Histogram<int> err_hist;\npublic:\n@@ -118,8 +117,6 @@ public:\nvirtual unsigned long long get_n_be () const;\nvirtual R get_MI () const;\nvirtual R get_MI_sum () const;\n-// virtual const tools::Histogram<R>& get_llrs0();\n-// virtual const tools::Histogram<R>& get_llrs1();\nvirtual tools::Histogram<int> get_err_hist() const;\nfloat get_fer () const;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER_reduction.cpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER_reduction.cpp",
"diff": "@@ -123,6 +123,9 @@ template <typename B, typename R>\nR Monitor_BFER_reduction<B,R>\n::get_MI() const\n{\n+ if (this->get_n_analyzed_fra() == 0)\n+ return 0;\n+\nreturn this->get_MI_sum() / (R)this->get_n_analyzed_fra();\n}\n@@ -137,24 +140,6 @@ R Monitor_BFER_reduction<B,R>\nreturn cur_mi;\n}\n-//template<typename B, typename R>\n-//const tools::Histogram<R> & Monitor_BFER_reduction<B, R>::get_llrs0()\n-//{\n-// for (unsigned i = 0; i < monitors.size(); i++)\n-// this->llrs0.add_values(monitors[i]->get_llrs0());\n-//\n-// return this->llrs0;\n-//}\n-//\n-//template<typename B, typename R>\n-//const tools::Histogram<R>& Monitor_BFER_reduction<B, R>::get_llrs1()\n-//{\n-// for (unsigned i = 0; i < monitors.size(); i++)\n-// this->llrs1.add_values(monitors[i]->get_llrs1());\n-//\n-// return this->llrs1;\n-//}\n-\ntemplate <typename B, typename R>\nvoid Monitor_BFER_reduction<B,R>\n::reset()\n@@ -187,11 +172,11 @@ tools::Histogram<int> Monitor_BFER_reduction<B, R>::get_err_hist() const\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n-template class aff3ct::module::Monitor_BFER_reduction<B_8, Q_8>;\n-template class aff3ct::module::Monitor_BFER_reduction<B_16,Q_16>;\n-template class aff3ct::module::Monitor_BFER_reduction<B_32,Q_32>;\n-template class aff3ct::module::Monitor_BFER_reduction<B_64,Q_64>;\n+template class aff3ct::module::Monitor_BFER_reduction<B_8, R_8>;\n+template class aff3ct::module::Monitor_BFER_reduction<B_16,R_16>;\n+template class aff3ct::module::Monitor_BFER_reduction<B_32,R_32>;\n+template class aff3ct::module::Monitor_BFER_reduction<B_64,R_64>;\n#else\n-template class aff3ct::module::Monitor_BFER_reduction<B,Q>;\n+template class aff3ct::module::Monitor_BFER_reduction<B,R>;\n#endif\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER_reduction.hpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER_reduction.hpp",
"diff": "@@ -25,8 +25,6 @@ public:\nunsigned long long get_n_analyzed_fra () const;\nunsigned long long get_n_fe () const;\nunsigned long long get_n_be () const;\n-// const tools::Histogram<R>& get_llrs0();\n-// const tools::Histogram<R>& get_llrs1();\nvirtual tools::Histogram<int> get_err_hist() const;\nR get_MI () const;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.cpp",
"new_path": "src/Simulation/BFER/BFER.cpp",
"diff": "@@ -77,7 +77,7 @@ BFER<B,R,Q>\nparams_BFER.mpi_comm_freq);\n#else\n// build a monitor to compute BER/FER (reduce the other monitors)\n- this->monitor_red = new module::Monitor_BFER_reduction<B,Q>(this->monitor);\n+ this->monitor_red = new module::Monitor_BFER_reduction<B,R>(this->monitor);\n#endif\nif (!params_BFER.pdf_path.empty())\n@@ -287,22 +287,6 @@ void BFER<B,R,Q>\n}\n}\n-// auto slash_pos = params_BFER.pdf_path.rfind('/')+1;\n-// auto dot_pos = params_BFER.pdf_path.find('.', slash_pos);\n-// std::string mission = params_BFER.pdf_path.substr(slash_pos, dot_pos - slash_pos);\n-\n-// auto llrs0 = monitor_red->get_llrs0();\n-// std::string filename0 = mission + \"/\" + mission + \"_pdf_\" + std::to_string(this->noise->get_noise()) + \"_0.txt\";\n-// std::ofstream pdf0(filename0);\n-// pdf0 << \"x; \\\"PDF of \" << mission << \" bit 0 (\" << this->noise->get_noise() << \"dB, on \" << llrs0.get_n_values() << \" values)\\\"\" << std::endl;\n-// llrs0.dump(pdf0, llrs0.get_hist_min(), llrs0.get_hist_max(), 100, true);\n-//\n-// auto llrs1 = monitor_red->get_llrs1();\n-// std::string filename1 = mission + \"/\" + mission + \"_pdf_\" + std::to_string(this->noise->get_noise()) + \"_1.txt\";\n-// std::ofstream pdf1(filename1);\n-// pdf1 << \"x; \\\"PDF of \" << mission << \" bit 1 (\" << this->noise->get_noise() << \"dB, on \" << llrs1.get_n_values() << \" values)\\\"\" << std::endl;\n-// llrs1.dump(pdf1, llrs1.get_hist_min(), llrs1.get_hist_max(), 100, true);\n-\nif (params_BFER.mnt->err_hist != -1)\n{\nauto err_hist = monitor_red->get_err_hist();\n@@ -374,17 +358,17 @@ void BFER<B,R,Q>\n}\ntemplate <typename B, typename R, typename Q>\n-module::Monitor_BFER<B,Q>* BFER<B,R,Q>\n+module::Monitor_BFER<B,R>* BFER<B,R,Q>\n::build_monitor(const int tid)\n{\n- return factory::Monitor_BFER::build<B,Q>(*params_BFER.mnt);\n+ return factory::Monitor_BFER::build<B,R>(*params_BFER.mnt);\n}\ntemplate <typename B, typename R, typename Q>\n-tools::Terminal_BFER<B,Q>* BFER<B,R,Q>\n+tools::Terminal_BFER<B,R>* BFER<B,R,Q>\n::build_terminal()\n{\n- return factory::Terminal_BFER::build<B,Q>(*params_BFER.ter, *this->monitor_red, params_BFER.mutinfo);\n+ return factory::Terminal_BFER::build<B,R>(*params_BFER.ter, *this->monitor_red, params_BFER.mutinfo);\n}\ntemplate <typename B, typename R, typename Q>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.hpp",
"new_path": "src/Simulation/BFER/BFER.hpp",
"diff": "@@ -45,15 +45,15 @@ protected:\ntools::Noise<R>* noise; // current noise simulated\n// the monitors of the the BFER simulation\n- std::vector<module::Monitor_BFER <B,Q>*> monitor;\n- module::Monitor_BFER_reduction<B,Q>* monitor_red;\n+ std::vector<module::Monitor_BFER <B,R>*> monitor;\n+ module::Monitor_BFER_reduction<B,R>* monitor_red;\n// dump frames into files\nstd::vector<tools::Dumper *> dumper;\ntools::Dumper_reduction* dumper_red;\n// terminal (for the output of the code)\n- tools::Terminal_BFER<B,Q> *terminal;\n+ tools::Terminal_BFER<B,R> *terminal;\n// noise distribution\ntools::Distributions<R> *distributions;\n@@ -69,8 +69,8 @@ protected:\nvirtual void release_objects();\nvirtual void _launch() = 0;\n- module::Monitor_BFER <B,Q>* build_monitor (const int tid = 0);\n- tools ::Terminal_BFER<B,Q>* build_terminal( );\n+ module::Monitor_BFER <B,R>* build_monitor (const int tid = 0);\n+ tools ::Terminal_BFER<B,R>* build_terminal( );\nprivate:\nstatic void start_thread_build_comm_chain(BFER<B,R,Q> *simu, const int tid);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/Standard/Threads/BFER_std_threads.cpp",
"new_path": "src/Simulation/BFER/Standard/Threads/BFER_std_threads.cpp",
"diff": "@@ -245,9 +245,8 @@ void BFER_std_threads<B,R,Q>\nif (this->params_BFER_std.mutinfo)\n{\nmnt[mnt::sck::get_mutual_info::X](enc[enc::sck::encode ::X_N ]);\n- mnt[mnt::sck::get_mutual_info::Y](qnt[qnt::sck::process::Y_N2]);\n+ mnt[mnt::sck::get_mutual_info::Y](mdm[mdm::sck::demodulate::Y_N2]);\n}\n-\n}\ntemplate <typename B, typename R, typename Q>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Draw_generator/User_pdf_noise_generator/MKL/User_pdf_noise_generator_MKL.cpp",
"new_path": "src/Tools/Algo/Draw_generator/User_pdf_noise_generator/MKL/User_pdf_noise_generator_MKL.cpp",
"diff": "@@ -56,6 +56,7 @@ void User_pdf_noise_generator_MKL<R>\n}\n}\n+#if defined(MULTI_PREC) | defined(PREC_64_BIT)\nnamespace aff3ct\n{\n@@ -81,6 +82,8 @@ void User_pdf_noise_generator_MKL<double>\n}\n}\n+#endif\n+\ntemplate <typename R>\nvoid User_pdf_noise_generator_MKL<R>\n::generate(R *draw, const unsigned length, const R noise_power)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/BFER/Terminal_BFER.cpp",
"new_path": "src/Tools/Display/Terminal/BFER/Terminal_BFER.cpp",
"diff": "@@ -257,11 +257,11 @@ void Terminal_BFER<B,R>\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n-template class aff3ct::tools::Terminal_BFER<B_8, Q_8>;\n-template class aff3ct::tools::Terminal_BFER<B_16,Q_16>;\n-template class aff3ct::tools::Terminal_BFER<B_32,Q_32>;\n-template class aff3ct::tools::Terminal_BFER<B_64,Q_64>;\n+template class aff3ct::tools::Terminal_BFER<B_8, R_8>;\n+template class aff3ct::tools::Terminal_BFER<B_16,R_16>;\n+template class aff3ct::tools::Terminal_BFER<B_32,R_32>;\n+template class aff3ct::tools::Terminal_BFER<B_64,R_64>;\n#else\n-template class aff3ct::tools::Terminal_BFER<B,Q>;\n+template class aff3ct::tools::Terminal_BFER<B,R>;\n#endif\n// ==================================================================================== explicit template instantiation\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Remove LLR histogram comments; Change Monitors from Q to R type for mutinfo at the output of the demodulator
|
8,483 |
14.05.2018 09:42:51
| -7,200 |
6b280f768b214e73ee7bebd6b26aefe982e87518
|
Move mutinfo param to the Monitor foactory
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Monitor/BFER/Monitor_BFER.cpp",
"new_path": "src/Factory/Module/Monitor/BFER/Monitor_BFER.cpp",
"diff": "@@ -65,6 +65,11 @@ void Monitor_BFER::parameters\n{p+\"-err-hist-path\"},\ntools::File(tools::openmode::write),\n\"path to the output histogram (default is './hist', add automatically the current noise value and the extension '.txt')\");\n+\n+ args.add(\n+ {p+\"-mutinfo\"},\n+ tools::None(),\n+ \"allow the computation of the mutual information.\");\n}\nvoid Monitor_BFER::parameters\n@@ -80,6 +85,7 @@ void Monitor_BFER::parameters\nif(vals.exist({p+\"-max-fe\", \"e\"})) this->n_frame_errors = vals.to_int({p+\"-max-fe\", \"e\"});\nif(vals.exist({p+\"-err-hist\" })) this->err_hist = vals.to_int({p+\"-err-hist\" });\nif(vals.exist({p+\"-err-hist-path\" })) this->err_hist_path = vals.at ({p+\"-err-hist-path\" });\n+ if(vals.exist({p+\"-mutinfo\" })) this->mutinfo = true;\n}\nvoid Monitor_BFER::parameters\n@@ -90,6 +96,7 @@ void Monitor_BFER::parameters\nauto p = this->get_prefix();\nheaders[p].push_back(std::make_pair(\"Frame error count (e)\", std::to_string(this->n_frame_errors)));\n+ headers[p].push_back(std::make_pair(\"Compute Mutual Info\", this->mutinfo ? \"yes\" : \"no\"));\nif (full) headers[p].push_back(std::make_pair(\"K\", std::to_string(this->K )));\nif (full) headers[p].push_back(std::make_pair(\"N\", std::to_string(this->N )));\nif (full) headers[p].push_back(std::make_pair(\"Inter frame level\", std::to_string(this->n_frames)));\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Monitor/BFER/Monitor_BFER.hpp",
"new_path": "src/Factory/Module/Monitor/BFER/Monitor_BFER.hpp",
"diff": "@@ -29,6 +29,7 @@ struct Monitor_BFER : public Factory\nint err_hist = -1;\nint n_frame_errors = 100;\nint n_frames = 1;\n+ bool mutinfo = false;\n// ---------------------------------------------------------------------------------------------------- METHODS\nexplicit parameters(const std::string &p = Monitor_BFER_prefix);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/BFER/BFER.cpp",
"new_path": "src/Factory/Simulation/BFER/BFER.cpp",
"diff": "@@ -136,11 +136,6 @@ void BFER::parameters\n{p+\"-coded\"},\ntools::None(),\n\"enable the coded monitoring (extends the monitored bits to the entire codeword).\");\n-\n- args.add(\n- {p+\"-mutinfo\"},\n- tools::None(),\n- \"allow the computation of the mutual information.\");\n}\nvoid BFER::parameters\n@@ -161,7 +156,6 @@ void BFER::parameters\nif(vals.exist({p+\"-err-trk\" })) this->err_track_enable = true;\nif(vals.exist({p+\"-coset\", \"c\"})) this->coset = true;\nif(vals.exist({p+\"-coded\", })) this->coded_monitoring = true;\n- if(vals.exist({p+\"-mutinfo\" })) this->mutinfo = true;\nif (this->err_track_revert)\n{\n@@ -180,8 +174,6 @@ void BFER::parameters\nheaders[p].push_back(std::make_pair(\"NOISE type (E)\", this->noise_type));\nheaders[p].push_back(std::make_pair(\"Coset approach (c)\", this->coset ? \"yes\" : \"no\"));\nheaders[p].push_back(std::make_pair(\"Coded monitoring\", this->coded_monitoring ? \"yes\" : \"no\"));\n- headers[p].push_back(std::make_pair(\"Compute Mutual Info\", this->mutinfo ? \"yes\" : \"no\"));\n-\nstd::string enable_track = (this->err_track_enable) ? \"on\" : \"off\";\nheaders[p].push_back(std::make_pair(\"Bad frames tracking\", enable_track));\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/BFER/BFER.hpp",
"new_path": "src/Factory/Simulation/BFER/BFER.hpp",
"diff": "@@ -34,7 +34,6 @@ struct BFER : Simulation\nbool err_track_enable = false;\nbool coset = false;\nbool coded_monitoring = false;\n- bool mutinfo = false;\n// module parameters\nSource ::parameters *src = nullptr;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.cpp",
"new_path": "src/Simulation/BFER/BFER.cpp",
"diff": "@@ -368,7 +368,7 @@ template <typename B, typename R, typename Q>\ntools::Terminal_BFER<B,R>* BFER<B,R,Q>\n::build_terminal()\n{\n- return factory::Terminal_BFER::build<B,R>(*params_BFER.ter, *this->monitor_red, params_BFER.mutinfo);\n+ return factory::Terminal_BFER::build<B,R>(*params_BFER.ter, *this->monitor_red, params_BFER.mnt->mutinfo);\n}\ntemplate <typename B, typename R, typename Q>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/Standard/Threads/BFER_std_threads.cpp",
"new_path": "src/Simulation/BFER/Standard/Threads/BFER_std_threads.cpp",
"diff": "@@ -242,7 +242,7 @@ void BFER_std_threads<B,R,Q>\nmnt[mnt::sck::check_errors::V](crc[crc::sck::extract ::V_K2]);\n}\n- if (this->params_BFER_std.mutinfo)\n+ if (this->params_BFER_std.mnt->mutinfo)\n{\nmnt[mnt::sck::get_mutual_info::X](enc[enc::sck::encode ::X_N ]);\nmnt[mnt::sck::get_mutual_info::Y](mdm[mdm::sck::demodulate::Y_N2]);\n@@ -357,7 +357,7 @@ void BFER_std_threads<B,R,Q>\nmonitor[mnt::tsk::check_errors].exec();\n- if (this->params_BFER_std.mutinfo)\n+ if (this->params_BFER_std.mnt->mutinfo)\nmonitor[mnt::tsk::get_mutual_info].exec();\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Move mutinfo param to the Monitor foactory
|
8,483 |
14.05.2018 10:13:40
| -7,200 |
1bae55c61b4fdaeb972a1ae1b05c16ed7b903100
|
Fix MPI compilation errors
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER_reduction_mpi.cpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER_reduction_mpi.cpp",
"diff": "@@ -96,7 +96,7 @@ bool Monitor_BFER_reduction_mpi<B,R>\nmonitor_vals mvals_send = { this->get_n_be() - this->n_bit_errors,\nthis->get_n_fe() - this->n_frame_errors,\nthis->get_n_analyzed_fra() - this->n_analyzed_frames,\n- this->get_MI_sum() - this->MI_sum };\n+ (float)(this->get_MI_sum() - this->MI_sum) };\nMPI_Allreduce(&mvals_send, &mvals_recv, 1, MPI_monitor_vals, MPI_SUM_monitor_vals, MPI_COMM_WORLD);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.cpp",
"new_path": "src/Simulation/BFER/BFER.cpp",
"diff": "@@ -72,7 +72,7 @@ BFER<B,R,Q>\n#ifdef ENABLE_MPI\n// build a monitor to compute BER/FER (reduce the other monitors)\n- this->monitor_red = new module::Monitor_BFER_reduction_mpi<B,Q>(this->monitor,\n+ this->monitor_red = new module::Monitor_BFER_reduction_mpi<B,R>(this->monitor,\nstd::this_thread::get_id(),\nparams_BFER.mpi_comm_freq);\n#else\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix MPI compilation errors
|
8,483 |
14.05.2018 15:22:04
| -7,200 |
b037a11113afbb873cdeaac41d6f5c7ef8ca4b45
|
Fix the Encoder LDPC from QC (H order wasn't good anymore)
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/From_QC/Encoder_LDPC_from_QC.cpp",
"new_path": "src/Module/Encoder/LDPC/From_QC/Encoder_LDPC_from_QC.cpp",
"diff": "@@ -30,29 +30,24 @@ template <typename B>\nvoid Encoder_LDPC_from_QC<B>\n::_encode(const B *U_K, B *X_N, const int frame_id)\n{\n- unsigned M = this->N - this->K;\n+ int M = this->N - this->K;\n//Systematic part\nstd::copy_n(U_K, this->K, X_N);\n//Calculate parity part\n- mipp::vector<int8_t> tableauCalcul(M, 0);\n- for (unsigned i = 0; i < M; i++)\n- {\n- auto& links = this->H.get_cols_from_row(i);\n- for (unsigned j = 0; j < links.size(); j++)\n- if (links[j] < (unsigned)this->K)\n- tableauCalcul[i] ^= U_K[ links[j] ];\n- else\n- break;\n- }\n+ mipp::vector<int8_t> parity(M, 0);\n+\n+ for (auto i = 0; i < M; i++)\n+ for (auto& l : this->H.get_rows_from_col(i))\n+ parity[i] ^= (l < (unsigned)this->K) ? U_K[l] : (B)0;\n- for (unsigned i = 0; i < M; i++)\n+ auto* X_N_ptr = X_N + this->K;\n+ for (auto i = 0; i < M; i++)\n{\n- X_N[this->K + i] = 0;\n- for (unsigned j = 0; j < M; j++)\n- X_N[this->K + i] += tableauCalcul[j] & invH2[i][j];\n- X_N[this->K + i] %= 2;\n+ X_N_ptr[i] = 0;\n+ for (auto j = 0; j < M; j++)\n+ X_N_ptr[i] ^= parity[j] & invH2[i][j];\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix the Encoder LDPC from QC (H order wasn't good anymore)
|
8,483 |
14.05.2018 16:33:12
| -7,200 |
b62443f190086d65df3a61e6250c7ffaa9944b92
|
Add an Encoder LDPC for SeIRA matrices
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Encoder/LDPC/Encoder_LDPC.cpp",
"new_path": "src/Factory/Module/Encoder/LDPC/Encoder_LDPC.cpp",
"diff": "#include \"Module/Encoder/LDPC/Encoder_LDPC.hpp\"\n#include \"Module/Encoder/LDPC/From_H/Encoder_LDPC_from_H.hpp\"\n#include \"Module/Encoder/LDPC/From_QC/Encoder_LDPC_from_QC.hpp\"\n+#include \"Module/Encoder/LDPC/From_SeIRA/Encoder_LDPC_from_SeIRA.hpp\"\n#include \"Module/Encoder/LDPC/DVBS2/Encoder_LDPC_DVBS2.hpp\"\n#include \"Encoder_LDPC.hpp\"\n@@ -39,7 +40,7 @@ void Encoder_LDPC::parameters\nauto p = this->get_prefix();\n- tools::add_options(args.at({p+\"-type\"}), 0, \"LDPC\", \"LDPC_H\", \"LDPC_DVBS2\", \"LDPC_QC\");\n+ tools::add_options(args.at({p+\"-type\"}), 0, \"LDPC\", \"LDPC_H\", \"LDPC_DVBS2\", \"LDPC_QC\", \"LDPC_SEIRA\");\nargs.add(\n{p+\"-h-path\"},\n@@ -112,6 +113,7 @@ module::Encoder_LDPC<B>* Encoder_LDPC::parameters\nif (this->type == \"LDPC\" ) return new module::Encoder_LDPC <B>(this->K, this->N_cw, G, this->n_frames);\nelse if (this->type == \"LDPC_H\" ) return new module::Encoder_LDPC_from_H <B>(this->K, this->N_cw, H, this->n_frames);\nelse if (this->type == \"LDPC_QC\" ) return new module::Encoder_LDPC_from_QC <B>(this->K, this->N_cw, H, this->n_frames);\n+ else if (this->type == \"LDPC_SEIRA\") return new module::Encoder_LDPC_from_SeIRA<B>(this->K, this->N_cw, H, this->n_frames);\nelse if (this->type == \"LDPC_DVBS2\" && dvbs2 != nullptr)\nreturn new module::Encoder_LDPC_DVBS2 <B>(*dvbs2, this->n_frames);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Encoder/LDPC/From_QC/Encoder_LDPC_from_QC.cpp",
"new_path": "src/Module/Encoder/LDPC/From_QC/Encoder_LDPC_from_QC.cpp",
"diff": "@@ -40,7 +40,8 @@ void Encoder_LDPC_from_QC<B>\nfor (auto i = 0; i < M; i++)\nfor (auto& l : this->H.get_rows_from_col(i))\n- parity[i] ^= (l < (unsigned)this->K) ? U_K[l] : (B)0;\n+ if (l < (unsigned)this->K)\n+ parity[i] ^= U_K[l];\nauto* X_N_ptr = X_N + this->K;\nfor (auto i = 0; i < M; i++)\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Encoder/LDPC/From_SeIRA/Encoder_LDPC_from_SeIRA.cpp",
"diff": "+#include <iostream>\n+#include <vector>\n+#include <numeric>\n+#include <functional>\n+#include <sstream>\n+\n+#include \"Tools/Exception/exception.hpp\"\n+#include \"Tools/Math/matrix.h\"\n+\n+#include \"Encoder_LDPC_from_SeIRA.hpp\"\n+\n+using namespace aff3ct;\n+using namespace aff3ct::module;\n+\n+template <typename B>\n+Encoder_LDPC_from_SeIRA<B>\n+::Encoder_LDPC_from_SeIRA(const int K, const int N, const tools::Sparse_matrix &_H, const int n_frames)\n+: Encoder_LDPC<B>(K, N, n_frames)\n+{\n+ const std::string name = \"Encoder_LDPC_from_SeIRA\";\n+ this->set_name(name);\n+\n+ this->H = _H;\n+\n+ this->check_H_dimensions();\n+}\n+\n+template <typename B>\n+void Encoder_LDPC_from_SeIRA<B>\n+::_encode(const B *U_K, B *X_N, const int frame_id)\n+{\n+ int M = this->N - this->K;\n+\n+ //Systematic part\n+ std::copy_n(U_K, this->K, X_N);\n+\n+ //init the parity part\n+ B* parity = X_N + this->K;\n+ std::fill_n(parity, M, 0);\n+\n+\n+ //Calculate parity part\n+ for (auto& l : this->H.get_rows_from_col(0))\n+ if (l < (unsigned)this->K)\n+ parity[0] ^= U_K[l];\n+\n+ for (auto i = 1; i < M; i++)\n+ {\n+ parity[i] = parity[i -1];\n+\n+ for (auto& l : this->H.get_rows_from_col(i))\n+ if (l < (unsigned)this->K)\n+ parity[i] ^= U_K[l];\n+ }\n+}\n+\n+template <typename B>\n+const std::vector<uint32_t>& Encoder_LDPC_from_SeIRA<B>\n+::get_info_bits_pos() const\n+{\n+ return Encoder<B>::get_info_bits_pos();\n+}\n+\n+template <typename B>\n+bool Encoder_LDPC_from_SeIRA<B>\n+::is_sys() const\n+{\n+ return Encoder<B>::is_sys();\n+}\n+\n+template <typename B>\n+void Encoder_LDPC_from_SeIRA<B>\n+::_check_H_dimensions()\n+{\n+ Encoder_LDPC<B>::_check_H_dimensions();\n+\n+ if ((this->N-this->K) != (int)this->H.get_n_cols())\n+ {\n+ std::stringstream message;\n+ message << \"The built H matrix has a dimension '(N-K)' different than the given one ('(N-K)' = \" << (this->N-this->K)\n+ << \", 'H.get_n_cols()' = \" << this->H.get_n_cols() << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+}\n+\n+// ==================================================================================== explicit template instantiation\n+#include \"Tools/types.h\"\n+#ifdef MULTI_PREC\n+template class aff3ct::module::Encoder_LDPC_from_SeIRA<B_8>;\n+template class aff3ct::module::Encoder_LDPC_from_SeIRA<B_16>;\n+template class aff3ct::module::Encoder_LDPC_from_SeIRA<B_32>;\n+template class aff3ct::module::Encoder_LDPC_from_SeIRA<B_64>;\n+#else\n+template class aff3ct::module::Encoder_LDPC_from_SeIRA<B>;\n+#endif\n+// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Encoder/LDPC/From_SeIRA/Encoder_LDPC_from_SeIRA.hpp",
"diff": "+#ifndef ENCODER_LDPC_FROM_SEIRA_HPP_\n+#define ENCODER_LDPC_FROM_SEIRA_HPP_\n+\n+#include <vector>\n+\n+#include \"../Encoder_LDPC.hpp\"\n+\n+#include \"Tools/Algo/Sparse_matrix/Sparse_matrix.hpp\"\n+#include \"Tools/Code/LDPC/Matrix_handler/LDPC_matrix_handler.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+\n+template <typename B = int>\n+class Encoder_LDPC_from_SeIRA : public Encoder_LDPC<B>\n+{\n+public:\n+ Encoder_LDPC_from_SeIRA(const int K, const int N, const tools::Sparse_matrix &H, const int n_frames = 1);\n+ virtual ~Encoder_LDPC_from_SeIRA() = default;\n+\n+ const std::vector<uint32_t>& get_info_bits_pos() const;\n+\n+ bool is_sys() const;\n+\n+protected:\n+ void _encode(const B *U_K, B *X_N, const int frame_id);\n+ void _check_H_dimensions();\n+};\n+\n+}\n+}\n+\n+#endif /* ENCODER_LDPC_FROM_SEIRA_HPP_ */\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add an Encoder LDPC for SeIRA matrices
|
8,483 |
14.05.2018 17:20:55
| -7,200 |
2aa17bd9c29461b9b87f4ccdcc57a62cf9896027
|
Fix the max frame stop criteria
|
[
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.cpp",
"new_path": "src/Simulation/BFER/BFER.cpp",
"diff": "@@ -333,8 +333,8 @@ void BFER<B,R,Q>\n}\nif (!params_BFER.crit_nostop && !params_BFER.err_track_revert && !module::Monitor::is_interrupt() &&\n- this->monitor_red->get_n_fe() < this->monitor_red->get_fe_limit() &&\n- (params_BFER.max_frame == 0 || this->monitor_red->get_n_fe() < params_BFER.max_frame))\n+ !this->monitor_red->fe_limit_achieved() &&\n+ (params_BFER.max_frame == 0 || this->monitor_red->get_n_analyzed_fra() >= params_BFER.max_frame))\nmodule::Monitor::stop();\nthis->monitor_red->reset();\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix the max frame stop criteria
|
8,488 |
15.05.2018 09:41:11
| -7,200 |
ed1f2db0d072bcfa73beaa20cbb2fc947117076a
|
Minor change in debug parser.
|
[
{
"change_type": "MODIFY",
"old_path": "scripts/debug_parser/aff3ct_debug_parser.py",
"new_path": "scripts/debug_parser/aff3ct_debug_parser.py",
"diff": "@@ -131,40 +131,28 @@ class OutputStructure:\nreturn c_type\ndef export_as_mat(self, path, frame_index=None):\n- myframes = []\n+ local_frames = []\nsck_name = os.path.basename(path)\n- if not self.hex_format:\n- if \"float\" in self.data_format:\nfor frame in self.frames:\n- myframe = []\n+ local_frame = []\nfor value in frame:\n- myframe.append(float(value))\n- myframes.append(myframe)\n+ if not self.hex_format:\n+ if \"float\" in self.data_format:\n+ value = float(value)\nelse:\n- for frame in self.frames:\n- myframe = []\n- for value in frame:\n- myframe.append(int(value))\n- myframes.append(myframe)\n+ value = int(value)\nelse:\nif \"float\" in self.data_format:\n- for frame in self.frames:\n- myframe = []\n- for value in frame:\n- myframe.append(float.fromhex(value))\n- myframes.append(myframe)\n+ value = float.fromhex(value)\nelse:\n- for frame in self.frames:\n- myframe = []\n- for value in frame:\nvalue = int(value, 16)\nif value > 0x7FFFFFFF:\nvalue -= 0x100000000\n- myframe.append(value)\n- myframes.append(myframe)\n+ local_frame.append(value)\n+ local_frames.append(local_frame)\n- mat4py.savemat(path + '.mat', dict({sck_name : myframes}));\n+ mat4py.savemat(path + '.mat', dict({sck_name : local_frames}));\ndef export_as_bin(self, path, frame_index=None):\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Minor change in debug parser.
|
8,483 |
15.05.2018 12:26:52
| -7,200 |
bcd234203bc3f96049d07ad1235eee4eb286bfb6
|
In event_generator, remove fixed event_type=int32_t to a templated event type changing with the real data type
|
[
{
"change_type": "MODIFY",
"old_path": "refs",
"new_path": "refs",
"diff": "-Subproject commit 625617fc6df974afc83f53d2cf5d21b229ae4a8b\n+Subproject commit 39f26d2d698c8d463dc77595327aa88ab1ac80b2\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/Binary_erasure/Channel_binary_erasure.cpp",
"new_path": "src/Module/Channel/Binary_erasure/Channel_binary_erasure.cpp",
"diff": "@@ -30,24 +30,21 @@ void Channel_binary_erasure<R>\nconst auto event_probability = this->n->get_noise();\nevent_generator->generate(this->event_draw.data(), (unsigned)this->N, event_probability);\n- for (auto i = 0; i < this->N; i++)\n- Y_N[i] = event_draw[i] ? tools::erased_symbol_val<R>() : X_N[i];\n-//\n-// const mipp::Reg<R> r_erased = tools::erased_symbol_val<R>();\n-// const mipp::Reg<R> r_zero = (R)false;\n-//\n-// const auto vec_loop_size = (this->N / mipp::nElReg<R>()) * mipp::nElReg<R>();\n-//\n-// for (auto i = 0; i < vec_loop_size; i += mipp::nElReg<R>())\n-// {\n-// const auto r_in = mipp::Reg<R>(X_N + i);\n-// const auto r_event = mipp::Reg<R>(&this->noise[i]);\n-// const auto r_out = mipp::blend(r_in, r_erased, r_event == r_zero);\n-// r_out.store(Y_N + i);\n-// }\n-//\n-// for (auto i = vec_loop_size; i < this->N; i++)\n-// Y_N[i] = this->noise[i] ? tools::erased_symbol_val<R>() : X_N[i];\n+ const mipp::Reg<R> r_erased = tools::erased_symbol_val<R>();\n+ const mipp::Reg<E> r_false = (E)false;\n+\n+ const auto vec_loop_size = (this->N / mipp::nElReg<R>()) * mipp::nElReg<R>();\n+\n+ for (auto i = 0; i < vec_loop_size; i += mipp::nElReg<R>())\n+ {\n+ const mipp::Reg<R> r_in = X_N + i;\n+ const mipp::Reg<E> r_event = &this->event_draw[i];\n+ const auto r_out = mipp::blend(r_in, r_erased, r_event == r_false);\n+ r_out.store(Y_N + i);\n+ }\n+\n+ for (auto i = vec_loop_size; i < this->N; i++)\n+ Y_N[i] = this->event_draw[i] ? tools::erased_symbol_val<R>() : X_N[i];\n}\ntemplate<typename R>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/Binary_erasure/Channel_binary_erasure.hpp",
"new_path": "src/Module/Channel/Binary_erasure/Channel_binary_erasure.hpp",
"diff": "#include <random>\n+#include \"Tools/types.h\"\n#include \"Tools/Algo/Draw_generator/Event_generator/Event_generator.hpp\"\n#include \"Tools/Algo/Draw_generator/Event_generator/Standard/Event_generator_std.hpp\"\n@@ -20,7 +21,9 @@ class Channel_binary_erasure : public Channel<R>\n{\nprotected:\ntools::Event_generator<R> *event_generator;\n- std::vector<tools::event_type> event_draw;\n+\n+ using E = typename tools::matching_types<R>::B;\n+ std::vector<E> event_draw;\npublic:\nChannel_binary_erasure(const int N, tools::Event_generator<R> *event_generator = new tools::Event_generator_std<R>(),\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/Binary_symmetric/Channel_binary_symmetric.cpp",
"new_path": "src/Module/Channel/Binary_symmetric/Channel_binary_symmetric.cpp",
"diff": "@@ -30,29 +30,26 @@ void Channel_binary_symmetric<R>\nconst auto event_probability = this->n->get_noise();\nevent_generator->generate(this->event_draw.data(), (unsigned)this->N, event_probability);\n- for (auto i = 0; i < this->N; i++)\n- Y_N[i] = event_draw[i] != (X_N[i] == (R)0.0) ? (R)0.0 : (R)1.0;\n+ const mipp::Reg<E> r_false = (E)false;\n+ const mipp::Reg<R> r_0 = (R)0.0;\n+ const mipp::Reg<R> r_1 = (R)1.0;\n-// const mipp::Reg<R> r_zero = (R)false;\n-// const mipp::Reg<R> r_0 = (R)0.0;\n-// const mipp::Reg<R> r_1 = (R)1.0;\n-//\n-// const auto vec_loop_size = (this->N / mipp::nElReg<R>()) * mipp::nElReg<R>();\n-//\n-// for (auto i = 0; i < vec_loop_size; i += mipp::nElReg<R>())\n-// {\n-// const auto r_in = mipp::Reg<R>(X_N + i);\n-// const auto r_event = mipp::Reg<R>(&this->noise[i]);\n-//\n-// const auto m_zero = r_in == r_0;\n-// const auto m_event = r_event == r_zero;\n-//\n-// const auto r_out = mipp::blend(r_0, r_1, m_event ^ m_zero);\n-// r_out.store(Y_N + i);\n-// }\n-//\n-// for (auto i = vec_loop_size; i < this->N; i++)\n-// Y_N[i] = this->noise[i] != (X_N[i] == (R)0.0) ? (R)0.0 : (R)1.0;\n+ const auto vec_loop_size = (this->N / mipp::nElReg<R>()) * mipp::nElReg<R>();\n+\n+ for (auto i = 0; i < vec_loop_size; i += mipp::nElReg<R>())\n+ {\n+ const mipp::Reg<R> r_in = X_N + i;\n+ const mipp::Reg<E> r_event = &this->event_draw[i];\n+\n+ const auto m_zero = r_in == r_0;\n+ const auto m_event = r_event != r_false;\n+\n+ const auto r_out = mipp::blend(r_0, r_1, m_event ^ m_zero);\n+ r_out.store(Y_N + i);\n+ }\n+\n+ for (auto i = vec_loop_size; i < this->N; i++)\n+ Y_N[i] = this->noise[i] != (X_N[i] == (R)0.0) ? (R)0.0 : (R)1.0;\n}\ntemplate<typename R>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/Binary_symmetric/Channel_binary_symmetric.hpp",
"new_path": "src/Module/Channel/Binary_symmetric/Channel_binary_symmetric.hpp",
"diff": "@@ -20,7 +20,9 @@ class Channel_binary_symmetric : public Channel<R>\n{\nprotected:\ntools::Event_generator<R> *event_generator;\n- std::vector<tools::event_type> event_draw;\n+\n+ using E = typename tools::matching_types<R>::B;\n+ std::vector<E> event_draw;\npublic:\nChannel_binary_symmetric(const int N, tools::Event_generator<R> *event_generator = new tools::Event_generator_std<R>(),\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Draw_generator/Event_generator/Event_generator.hpp",
"new_path": "src/Tools/Algo/Draw_generator/Event_generator/Event_generator.hpp",
"diff": "#include <cstdint>\n#include <vector>\n+\n+#include \"Tools/types.h\"\n#include \"../Draw_generator.hpp\"\nnamespace aff3ct\n@@ -10,9 +12,7 @@ namespace aff3ct\nnamespace tools\n{\n-using event_type = int32_t;\n-\n-template <typename R = float>\n+template <typename R = float, typename E = typename tools::matching_types<R>::B>\nclass Event_generator : public Draw_generator<R>\n{\npublic:\n@@ -20,13 +20,13 @@ public:\nvirtual ~Event_generator() = default;\n- template <class A = std::allocator<event_type>>\n- void generate(std::vector<event_type,A> &draw, const R event_probability)\n+ template <class A = std::allocator<E>>\n+ void generate(std::vector<E,A> &draw, const R event_probability)\n{\nthis->generate(draw.data(), (unsigned)draw.size(), event_probability);\n}\n- virtual void generate(event_type *draw, const unsigned length, const R event_probability) = 0;\n+ virtual void generate(E *draw, const unsigned length, const R event_probability) = 0;\n};\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Draw_generator/Event_generator/Fast/Event_generator_fast.cpp",
"new_path": "src/Tools/Algo/Draw_generator/Event_generator/Fast/Event_generator_fast.cpp",
"diff": "using namespace aff3ct;\nusing namespace aff3ct::tools;\n-template <typename R>\n-Event_generator_fast<R>\n+template <typename R, typename E>\n+Event_generator_fast<R,E>\n::Event_generator_fast(const int seed)\n-: Event_generator<R>()\n+: Event_generator<R,E>()\n{\nthis->set_seed(seed);\n}\n-template <typename R>\n-void Event_generator_fast<R>\n+template <typename R, typename E>\n+void Event_generator_fast<R,E>\n::set_seed(const int seed)\n{\nmt19937.seed(seed);\n@@ -28,79 +28,72 @@ void Event_generator_fast<R>\nmt19937_simd.seed(seeds.data());\n}\n-template <typename R>\n-mipp::Reg<R> Event_generator_fast<R>\n-::get_random_simd()\n+template <typename R, typename E>\n+void Event_generator_fast<R,E>\n+::generate(E *draw, const unsigned length, const R event_probability)\n{\nthrow runtime_error(__FILE__, __LINE__, __func__, \"The MT19937 random generator does not support this type.\");\n}\n-template <typename R>\n-R Event_generator_fast<R>\n-::get_random()\n-{\n- throw runtime_error(__FILE__, __LINE__, __func__, \"The MT19937 random generator does not support this type.\");\n-}\n+#include \"Tools/types.h\"\nnamespace aff3ct\n{\nnamespace tools\n{\ntemplate <>\n-mipp::Reg<float> Event_generator_fast<float>\n-::get_random_simd()\n+void Event_generator_fast<R_32,B_32>\n+::generate(B_32 *draw, const unsigned length, const R_32 event_probability)\n{\n- // return a vector of numbers between [0,1]\n- return mt19937_simd.randf_cc();\n-}\n-}\n-}\n+ const mipp::Reg<R_32> r_ep = event_probability;\n+ const mipp::Reg<B_32> r_one = (B_32)true;\n+ const mipp::Reg<B_32> r_zero = (B_32)false;\n-namespace aff3ct\n-{\n-namespace tools\n-{\n-template <>\n-float Event_generator_fast<float>\n-::get_random()\n+ const unsigned vec_loop_size = (length / mipp::N<R_32>()) * mipp::N<R_32>();\n+\n+ for (unsigned i = 0; i < vec_loop_size; i += mipp::N<R_32>())\n{\n- // return a number between [0,1]\n- return mt19937.randf_cc();\n-}\n-}\n+ const auto r_draw = mt19937_simd.randf_cc();\n+ const auto r_out = mipp::blend(r_one, r_zero, r_draw <= r_ep);\n+ r_out.store(draw + i);\n}\n-template <typename R>\n-void Event_generator_fast<R>\n-::generate(event_type *draw, const unsigned length, const R event_probability)\n-{\n- throw runtime_error(__FILE__, __LINE__, __func__, \"The MT19937 random generator does not support this type.\");\n+ for (auto i = vec_loop_size; i < length; i++)\n+ draw[i] = mt19937.randf_cc() <= event_probability;\n}\n+}\n+}\nnamespace aff3ct\n{\nnamespace tools\n{\ntemplate <>\n-void Event_generator_fast<float>\n-::generate(int32_t *draw, const unsigned length, const float event_probability)\n+void Event_generator_fast<R_64,B_64>\n+::generate(B_64 *draw, const unsigned length, const R_64 event_probability)\n{\n- const mipp::Reg<float > r_ep = event_probability;\n- const mipp::Reg<int32_t> r_one = true;\n- const mipp::Reg<int32_t> r_zero = false;\n+ const mipp::Reg<R_64> r_ep = event_probability;\n+ const mipp::Reg<B_64> r_one = (B_64)true;\n+ const mipp::Reg<B_64> r_zero = (B_64)false;\n- const unsigned vec_loop_size = (length / mipp::N<float>()) * mipp::N<float>();\n+ const unsigned vec_loop_size = (length / (2*mipp::N<R_64>())) * (2*mipp::N<R_64>());\n- for (unsigned i = 0; i < vec_loop_size; i += mipp::N<float>())\n+ for (unsigned i = 0; i < vec_loop_size; i += 2*mipp::N<R_64>())\n{\n- const auto r_draw = get_random_simd();\n- const auto r_out = mipp::blend(r_one, r_zero, r_draw <= r_ep);\n- r_out.store(draw + i);\n+ const auto r_draw = mt19937_simd.randf_cc(); // on simple floats\n+\n+ const auto draw_low = mipp::cvt<float,R_64>(r_draw.low ());\n+ const auto draw_high = mipp::cvt<float,R_64>(r_draw.high());\n+\n+ const auto r_out_low = mipp::blend(r_one, r_zero, draw_low <= r_ep);\n+ const auto r_out_high = mipp::blend(r_one, r_zero, draw_high <= r_ep);\n+ r_out_low .store(draw + i);\n+ r_out_high.store(draw + i + mipp::N<R_64>());\n}\nfor (auto i = vec_loop_size; i < length; i++)\n- draw[i] = get_random() <= event_probability;\n+ draw[i] = (R_64)mt19937.randf_cc() <= event_probability;\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Draw_generator/Event_generator/Fast/Event_generator_fast.hpp",
"new_path": "src/Tools/Algo/Draw_generator/Event_generator/Fast/Event_generator_fast.hpp",
"diff": "@@ -11,9 +11,11 @@ namespace aff3ct\nnamespace tools\n{\n-template <typename R = float>\n-class Event_generator_fast : public Event_generator<R>\n+template <typename R = float, typename E = typename tools::matching_types<R>::B>\n+class Event_generator_fast : public Event_generator<R,E>\n{\n+ static_assert(sizeof(R) == sizeof(E), \"R and E have to represent the same number of bits.\");\n+\nprivate:\ntools::PRNG_MT19937 mt19937; // Mersenne Twister 19937 (scalar)\ntools::PRNG_MT19937_simd mt19937_simd; // Mersenne Twister 19937 (SIMD)\n@@ -25,11 +27,7 @@ public:\nvirtual void set_seed(const int seed);\n- virtual void generate(event_type *draw, const unsigned length, const R event_probability);\n-\n-private:\n- inline mipp::Reg<R> get_random_simd();\n- inline R get_random ();\n+ virtual void generate(E *draw, const unsigned length, const R event_probability);\n};\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Draw_generator/Event_generator/GSL/Event_generator_GSL.cpp",
"new_path": "src/Tools/Algo/Draw_generator/Event_generator/GSL/Event_generator_GSL.cpp",
"diff": "using namespace aff3ct;\nusing namespace aff3ct::tools;\n-template <typename R>\n-Event_generator_GSL<R>\n+template <typename R, typename E>\n+Event_generator_GSL<R,E>\n::Event_generator_GSL(const int seed)\n-: Event_generator<R>(), rng(gsl_rng_alloc(gsl_rng_mt19937))\n+: Event_generator<R,E>(), rng(gsl_rng_alloc(gsl_rng_mt19937))\n{\nthis->set_seed(seed);\n}\n-template <typename R>\n-Event_generator_GSL<R>\n+template <typename R, typename E>\n+Event_generator_GSL<R,E>\n::~Event_generator_GSL()\n{\ngsl_rng_free(rng);\n}\n-template <typename R>\n-void Event_generator_GSL<R>\n+template <typename R, typename E>\n+void Event_generator_GSL<R,E>\n::set_seed(const int seed)\n{\ngsl_rng_set(rng, seed);\n}\n-template <typename R>\n-void Event_generator_GSL<R>\n-::generate(event_type *draw, const unsigned length, const R event_probability)\n+template <typename R, typename E>\n+void Event_generator_GSL<R,E>\n+::generate(E *draw, const unsigned length, const R event_probability)\n{\nfor (unsigned i = 0; i < length; i++)\n- draw[i] = (event_type)gsl_ran_bernoulli(rng, event_probability);\n+ draw[i] = (E)gsl_ran_bernoulli(rng, (double)event_probability);\n}\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Draw_generator/Event_generator/GSL/Event_generator_GSL.hpp",
"new_path": "src/Tools/Algo/Draw_generator/Event_generator/GSL/Event_generator_GSL.hpp",
"diff": "@@ -13,8 +13,8 @@ namespace aff3ct\nnamespace tools\n{\n-template <typename R = float>\n-class Event_generator_GSL : public Event_generator<R>\n+template <typename R = float, typename E = typename tools::matching_types<R>::B>\n+class Event_generator_GSL : public Event_generator<R,E>\n{\nprivate:\ngsl_rng *rng;\n@@ -26,7 +26,7 @@ public:\nvirtual void set_seed(const int seed);\n- virtual void generate(event_type *draw, const unsigned length, const R event_probability);\n+ virtual void generate(E *draw, const unsigned length, const R event_probability);\n};\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Draw_generator/Event_generator/MKL/Event_generator_MKL.cpp",
"new_path": "src/Tools/Algo/Draw_generator/Event_generator/MKL/Event_generator_MKL.cpp",
"diff": "using namespace aff3ct;\nusing namespace aff3ct::tools;\n-template <typename R>\n-Event_generator_MKL<R>\n+template <typename R, typename E>\n+Event_generator_MKL<R,E>\n::Event_generator_MKL(const int seed)\n-: Event_generator<R>(), stream_state(nullptr), is_stream_alloc(false)\n+: Event_generator<R,E>(), stream_state(nullptr), is_stream_alloc(false)\n{\nthis->set_seed(seed);\n}\n-template <typename R>\n-Event_generator_MKL<R>\n+template <typename R, typename E>\n+Event_generator_MKL<R,E>\n::~Event_generator_MKL()\n{\nif (is_stream_alloc)\nvslDeleteStream(&stream_state);\n}\n-template <typename R>\n-void Event_generator_MKL<R>\n+template <typename R, typename E>\n+void Event_generator_MKL<R,E>\n::set_seed(const int seed)\n{\nif (is_stream_alloc) vslDeleteStream(&stream_state);\n@@ -35,13 +35,36 @@ void Event_generator_MKL<R>\nis_stream_alloc = true;\n}\n-template <typename R>\n-void Event_generator_MKL<R>\n-::generate(event_type *draw, const unsigned length, const R event_probability)\n+template <typename R, typename E>\n+void Event_generator_MKL<R,E>\n+::generate(E *draw, const unsigned length, const R event_probability)\n+{\n+ throw runtime_error(__FILE__, __LINE__, __func__, \"The MKL viRngBernoulli random generator does not support this type.\");\n+}\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+template <>\n+void Event_generator_MKL<R_32,B_32>\n+::generate(B_32 *draw, const unsigned length, const R_32 event_probability)\n{\nviRngBernoulli(VSL_RNG_METHOD_BERNOULLI_ICDF, stream_state, length, draw, event_probability);\n}\n+template <>\n+void Event_generator_MKL<R_64,B_64>\n+::generate(B_64 *draw, const unsigned length, const R_64 event_probability)\n+{\n+ std::vector<int> draw_i(length);\n+ viRngBernoulli(VSL_RNG_METHOD_BERNOULLI_ICDF, stream_state, length, draw_i.data(), event_probability);\n+\n+ std::copy(draw_i.begin(), draw_i.end(), draw);\n+}\n+}\n+}\n+\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Draw_generator/Event_generator/MKL/Event_generator_MKL.hpp",
"new_path": "src/Tools/Algo/Draw_generator/Event_generator/MKL/Event_generator_MKL.hpp",
"diff": "@@ -12,8 +12,8 @@ namespace aff3ct\nnamespace tools\n{\n-template <typename R = float>\n-class Event_generator_MKL : public Event_generator<R>\n+template <typename R = float, typename E = typename tools::matching_types<R>::B>\n+class Event_generator_MKL : public Event_generator<R,E>\n{\nprivate:\nVSLStreamStatePtr stream_state;\n@@ -26,7 +26,7 @@ public:\nvirtual void set_seed(const int seed);\n- virtual void generate(event_type *draw, const unsigned length, const R event_probability);\n+ virtual void generate(E *draw, const unsigned length, const R event_probability);\n};\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Draw_generator/Event_generator/Standard/Event_generator_std.cpp",
"new_path": "src/Tools/Algo/Draw_generator/Event_generator/Standard/Event_generator_std.cpp",
"diff": "using namespace aff3ct;\nusing namespace aff3ct::tools;\n-template <typename R>\n-Event_generator_std<R>\n+template <typename R, typename E>\n+Event_generator_std<R,E>\n::Event_generator_std(const int seed)\n-: Event_generator<R>()\n+: Event_generator<R,E>()\n{\nthis->set_seed(seed);\n}\n-template <typename R>\n-void Event_generator_std<R>\n+template <typename R, typename E>\n+void Event_generator_std<R,E>\n::set_seed(const int seed)\n{\nrd_engine.seed(seed);\n}\n-template <typename R>\n-void Event_generator_std<R>\n-::generate(event_type *draw, const unsigned length, const R event_probability)\n+template <typename R, typename E>\n+void Event_generator_std<R,E>\n+::generate(E *draw, const unsigned length, const R event_probability)\n{\nstd::bernoulli_distribution bern_dist(event_probability);\nfor (unsigned i = 0; i < length; i++)\n- draw[i] = (event_type)bern_dist(this->rd_engine);\n+ draw[i] = (E)bern_dist(this->rd_engine);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Draw_generator/Event_generator/Standard/Event_generator_std.hpp",
"new_path": "src/Tools/Algo/Draw_generator/Event_generator/Standard/Event_generator_std.hpp",
"diff": "@@ -10,8 +10,8 @@ namespace aff3ct\nnamespace tools\n{\n-template <typename R = float>\n-class Event_generator_std : public Event_generator<R>\n+template <typename R = float, typename E = typename tools::matching_types<R>::B>\n+class Event_generator_std : public Event_generator<R,E>\n{\nprotected:\nstd::mt19937 rd_engine; // Mersenne Twister 19937\n@@ -23,7 +23,7 @@ public:\nvirtual void set_seed(const int seed);\n- virtual void generate(event_type *draw, const unsigned length, const R event_probability);\n+ virtual void generate(E *draw, const unsigned length, const R event_probability);\n};\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/types.h",
"new_path": "src/Tools/types.h",
"diff": "@@ -46,4 +46,54 @@ using Q_64 = double;\n#endif\n#endif\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+\n+template<size_t precision> // the wanted precision 8, 1-, 32, 64\n+struct types_from_prec\n+{\n+\n+};\n+\n+template<>\n+struct types_from_prec<8>\n+{\n+ using B = B_8;\n+ using R = R_8;\n+ using Q = Q_8;\n+};\n+\n+template<>\n+struct types_from_prec<16>\n+{\n+ using B = B_16;\n+ using R = R_16;\n+ using Q = Q_16;\n+};\n+\n+template<>\n+struct types_from_prec<32>\n+{\n+ using B = B_32;\n+ using R = R_32;\n+ using Q = Q_32;\n+};\n+\n+template<>\n+struct types_from_prec<64>\n+{\n+ using B = B_64;\n+ using R = R_64;\n+ using Q = Q_64;\n+};\n+\n+template<typename T> // give a type T and get the B R Q of the same size\n+struct matching_types : types_from_prec<sizeof(T) * 8>\n+{\n+};\n+}\n+}\n+\n#endif /* TYPES_H_ */\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
In event_generator, remove fixed event_type=int32_t to a templated event type changing with the real data type
|
8,483 |
16.05.2018 08:42:10
| -7,200 |
05bf7888c36878866f85fba02cfc794bac673bf3
|
Fix the peeling decoder with the new erased values syntax way
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Peeling/Decoder_LDPC_BP_peeling.cpp",
"new_path": "src/Module/Decoder/LDPC/BP/Peeling/Decoder_LDPC_BP_peeling.cpp",
"diff": "#include \"Decoder_LDPC_BP_peeling.hpp\"\n#include \"Tools/Perf/common/hard_decide.h\"\n-#include \"Tools/Noise/Erased_value.hpp\"\n+#include \"Tools/Noise/noise_utils.h\"\n#include \"Tools/Math/utils.h\"\nusing namespace aff3ct;\n@@ -29,8 +29,8 @@ void Decoder_LDPC_BP_peeling<B,R>\n{\ntools::hard_decide(Y_N, var_nodes[frame_id].data(), this->N);\nfor (auto i = 0; i < this->N; i++)\n- if (Y_N[i] <= tools::Erased_value<R>::llr && Y_N[i] >= -tools::Erased_value<R>::llr)\n- var_nodes[frame_id][i] = tools::Erased_value<B>::symbol;\n+ if (Y_N[i] <= tools::erased_llr_val<R>() && Y_N[i] >= -tools::erased_llr_val<R>())\n+ var_nodes[frame_id][i] = tools::erased_symbol_val<B>();\n}\ntemplate <typename B, typename R>\n@@ -57,7 +57,7 @@ void Decoder_LDPC_BP_peeling<B,R>\nfor (unsigned i = 0; i < links.get_n_rows(); i++)\n{\nauto cur_state = this->var_nodes[frame_id][i];\n- if (cur_state != tools::Erased_value<B>::symbol)\n+ if (cur_state != tools::erased_symbol_val<B>())\n{\nauto& cn_list = links.get_cols_from_row(i);\nwhile (cn_list.size())\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix the peeling decoder with the new erased values syntax way
|
8,483 |
16.05.2018 10:54:11
| -7,200 |
b59e7ac94cf8604f3df45d2d31cfb1ed540b9e9d
|
Remove channel pdf
|
[
{
"change_type": "DELETE",
"old_path": "src/Module/Channel/PDF/Channel_pdf.cpp",
"new_path": null,
"diff": "-#include <algorithm>\n-\n-#include \"Tools/Exception/exception.hpp\"\n-\n-#include \"Channel_pdf.hpp\"\n-\n-using namespace aff3ct;\n-using namespace aff3ct::module;\n-\n-template <typename R>\n-Channel_pdf<R>\n-::Channel_pdf(const int N, tools::User_pdf_noise_generator<R> *draw_generator, const bool add_users,\n- const tools::Noise<R>& noise, const int n_frames)\n-: Channel<R>(N, noise, n_frames),\n- add_users(add_users),\n- draw_generator(draw_generator)\n-{\n- const std::string name = \"Channel_pdf\";\n- this->set_name(name);\n-\n- if (draw_generator == nullptr)\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, \"'draw_generator' can't be NULL.\");\n-}\n-\n-template <typename R>\n-Channel_pdf<R>\n-::~Channel_pdf()\n-{\n- if (draw_generator != nullptr) delete draw_generator;\n-}\n-\n-template <typename R>\n-void Channel_pdf<R>\n-::_add_noise(const R *X_N, R *Y_N, const int frame_id)\n-{\n- if (add_users && this->n_frames > 1)\n- {\n- if (frame_id != -1)\n- {\n- std::stringstream message;\n- message << \"'frame_id' has to be equal to -1 ('frame_id' = \" << frame_id << \").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- draw_generator->generate(X_N, this->noise.data(), this->N, this->n->get_noise());\n-\n- std::fill(Y_N, Y_N + this->N, (R)0);\n- for (auto f = 0; f < this->n_frames; f++)\n- for (auto i = 0; i < this->N; i++)\n- Y_N[i] += X_N[f * this->N +i];\n-\n- for (auto i = 0; i < this->N; i++)\n- Y_N[i] += this->noise[i];\n- }\n- else\n- {\n- const auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\n- const auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\n-\n- if (frame_id < 0)\n- draw_generator->generate(this->noise, this->n->get_noise());\n- else\n- draw_generator->generate(X_N, this->noise.data() + f_start * this->N, this->N, this->n->get_noise());\n-\n- for (auto f = f_start; f < f_stop; f++)\n- for (auto n = 0; n < this->N; n++)\n- Y_N[f * this->N +n] = X_N[f * this->N +n] + this->noise[f * this->N +n];\n- }\n-}\n-\n-// ==================================================================================== explicit template instantiation\n-#include \"Tools/types.h\"\n-#ifdef MULTI_PREC\n-template class aff3ct::module::Channel_pdf<R_32>;\n-template class aff3ct::module::Channel_pdf<R_64>;\n-#else\n-template class aff3ct::module::Channel_pdf<R>;\n-#endif\n-// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "DELETE",
"old_path": "src/Module/Channel/PDF/Channel_pdf.hpp",
"new_path": null,
"diff": "-#ifndef CHANNEL_PDF_HPP_\n-#define CHANNEL_PDF_HPP_\n-\n-#include \"Tools/Algo/Draw_generator/User_pdf_noise_generator/User_pdf_noise_generator.hpp\"\n-\n-#include \"../Channel.hpp\"\n-\n-namespace aff3ct\n-{\n-namespace module\n-{\n-\n-/* PDF channel add noise on each symbol from a user defined probability density function.\n- * The sigma variable from the inherited class represents the noise power to select in the given noise PDF\n- */\n-\n-template <typename R = float>\n-class Channel_pdf : public Channel<R>\n-{\n- const bool add_users;\n-protected:\n- tools::User_pdf_noise_generator<R> *draw_generator;\n-\n-public:\n- Channel_pdf(const int N, tools::User_pdf_noise_generator<R> *draw_generator, const bool add_users = false,\n- const tools::Noise<R>& noise = tools::ROP<R>(), const int n_frames = 1);\n-\n- virtual ~Channel_pdf();\n-\n- void _add_noise(const R *X_N, R *Y_N, const int frame_id = -1);\n-};\n-}\n-}\n-\n-#endif /* CHANNEL_PDF_HPP_ */\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Remove channel pdf
|
8,483 |
16.05.2018 12:26:05
| -7,200 |
059cc8175c0ec46851b402b5f3f89f0595d31c1d
|
Fix the comment of the H dimensions meaning
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/LDPC/BP/Decoder_LDPC_BP.hpp",
"new_path": "src/Module/Decoder/LDPC/BP/Decoder_LDPC_BP.hpp",
"diff": "@@ -14,8 +14,8 @@ class Decoder_LDPC_BP : public Decoder_SISO_SIHO<B,R>\n{\nprotected:\nconst int n_ite;\n- const tools::Sparse_matrix H; // CN are along the columns -> _H.get_n_rows() == M (often M=N-K)\n- // VN are along the rows -> _H.get_n_cols() == N\n+ const tools::Sparse_matrix H; // CN are along the columns -> H.get_n_cols() == M (often M=N-K)\n+ // VN are along the rows -> H.get_n_rows() == N\n// automatically transpose in the constructor if needed\nconst bool enable_syndrome;\nconst int syndrome_depth;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix the comment of the H dimensions meaning
|
8,483 |
16.05.2018 13:01:31
| -7,200 |
80ed04e71f9cbf6f3568ef97e9bebaeb41a9d39f
|
Add check in ldpc codec on the K and N values; Add check in greatest_common_divisor
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Codec/LDPC/Codec_LDPC.cpp",
"new_path": "src/Factory/Module/Codec/LDPC/Codec_LDPC.cpp",
"diff": "+#include <sstream>\n#include \"Codec_LDPC.hpp\"\n+#include \"Tools/Exception/exception.hpp\"\n+\nusing namespace aff3ct;\nusing namespace aff3ct::factory;\n@@ -101,7 +104,17 @@ void Codec_LDPC::parameters\nif (this->enc->K != 0)\nthis->dec->K = this->enc->K; // then the encoder knows the K\nelse\n- this->enc->K = this->dec->K; // then the encoder knows the K\n+ this->enc->K = this->dec->K; // then the decoder knows the K\n+\n+ if (this->dec->K == 0 || this->dec->N_cw == 0 || this->enc->K == 0 || this->enc->N_cw == 0)\n+ {\n+ std::stringstream message;\n+ message << \"Error while initializing decoder and encoder dimensions ('this->dec->K' = \" << this->dec->K\n+ << \", 'this->dec->N_cw' = \" << this->dec->N_cw << \", 'this->enc->K' = \" << this->enc->K\n+ << \", 'this->enc->N_cw' = \" << this->enc->N_cw << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\nthis->dec->n_frames = this->enc->n_frames;\n@@ -139,8 +152,6 @@ module::Codec_LDPC<B,Q>* Codec_LDPC::parameters\n::build(module::CRC<B>* crc) const\n{\nreturn new module::Codec_LDPC<B,Q>(*enc, *dec, pct);\n-\n- throw tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\ntemplate <typename B, typename Q>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.cpp",
"new_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.cpp",
"diff": "@@ -120,9 +120,9 @@ void Decoder_LDPC::parameters\nif (!this->H_path.empty())\n{\n- int H;\n- tools::LDPC_matrix_handler::read_matrix_size(this->H_path, H, this->N_cw);\n- this->K = this->N_cw - H; // considered as regular so H = N - K\n+ int M;\n+ tools::LDPC_matrix_handler::read_matrix_size(this->H_path, M, this->N_cw);\n+ this->K = this->N_cw - M; // considered as regular so M = N - K\n}\nDecoder::parameters::store(vals);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Encoder/LDPC/Encoder_LDPC.cpp",
"new_path": "src/Factory/Module/Encoder/LDPC/Encoder_LDPC.cpp",
"diff": "@@ -81,9 +81,9 @@ void Encoder_LDPC::parameters\nelse if (!this->H_path.empty())\n{\n- int H;\n- tools::LDPC_matrix_handler::read_matrix_size(this->H_path, H, this->N_cw);\n- this->K = this->N_cw - H; // considered as regular so H = N - K\n+ int M;\n+ tools::LDPC_matrix_handler::read_matrix_size(this->H_path, M, this->N_cw);\n+ this->K = this->N_cw - M; // considered as regular so M = N - K\n}\nEncoder::parameters::store(vals);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/AList/AList.cpp",
"new_path": "src/Tools/Code/LDPC/AList/AList.cpp",
"diff": "@@ -112,8 +112,8 @@ void AList\nthrow runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\n- N = stoi(values[0]);\n- H = stoi(values[1]);\n+ N = std::stoi(values[0]);\n+ H = std::stoi(values[1]);\n}\nstd::vector<unsigned> AList\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/utils.h",
"new_path": "src/Tools/Math/utils.h",
"diff": "@@ -96,6 +96,9 @@ inline T next_power_of_2(T x)\ntemplate <typename T>\nT greatest_common_divisor(T a, T b)\n{\n+ if (b == (T)0)\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, \"b is null!\");\n+\nT r;\nwhile ((r = a % b))\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add check in ldpc codec on the K and N values; Add check in greatest_common_divisor
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.