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,486 |
12.03.2018 14:44:15
| -3,600 |
4c277485eebb4aaaf236d118b43ae295374a6d9b
|
Modification of the handling of the bits of the las symbol for PSK modulation.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/PSK/Modem_PSK.hpp",
"new_path": "src/Module/Modem/PSK/Modem_PSK.hpp",
"diff": "@@ -37,6 +37,7 @@ public:\n}\nprotected:\n+ void _tmodulate ( const Q *X_N1, R *X_N2, const int frame_id);\nvoid _modulate ( const B *X_N1, R *X_N2, const int frame_id);\nvoid _filter ( const R *Y_N1, R *Y_N2, const int frame_id);\nvoid _demodulate ( const Q *Y_N1, Q *Y_N2, const int frame_id);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/PSK/Modem_PSK.hxx",
"new_path": "src/Module/Modem/PSK/Modem_PSK.hxx",
"diff": "@@ -142,7 +142,7 @@ void Modem_PSK<B,R,Q,MAX>\nauto complex_Yk = std::complex<Q>(Y_N1[2*k], Y_N1[2*k+1]);\nfor (auto j = 0; j < this->nbr_symbols; j++)\n- if ((j & (1 << b)) == 0)\n+ if (((j>>b) & 1) == 0)\nL0 = MAX(L0, -std::norm(complex_Yk - std::complex<Q>((Q)this->constellation[j].real(),\n(Q)this->constellation[j].imag())) * inv_sigma2);\nelse\n@@ -180,7 +180,7 @@ void Modem_PSK<B,R,Q,MAX>\nauto complex_Hk = std::complex<Q>((Q)H_N [2*k], (Q)H_N [2*k+1]);\nfor (auto j = 0; j < this->nbr_symbols; j++)\n- if ((j & (1 << b)) == 0)\n+ if (((j>>b) & 1) == 0)\nL0 = MAX(L0, -std::norm(complex_Yk -\ncomplex_Hk * std::complex<Q>((Q)this->constellation[j].real(),\n(Q)this->constellation[j].imag())) * inv_sigma2);\n@@ -223,13 +223,23 @@ void Modem_PSK<B,R,Q,MAX>\nauto tempL = (Q)(std::norm(complex_Yk - std::complex<Q>((Q)this->constellation[j].real(),\n(Q)this->constellation[j].imag())) * inv_sigma2);\n- for (auto l = 0; l < b; l++)\n- tempL += (j & (1 << l)) * Y_N2[k * this->bits_per_symbol +l];\n+ for (auto l = 0; l < this->bits_per_symbol; l++)\n+ {\n+ if (l == b)\n+ continue;\n+\n+ if (((j>>l) & 1) == 1)\n+ {\n+ if (k * this->bits_per_symbol +l < size)\n+ tempL += Y_N2[k * this->bits_per_symbol +l];\n+ else\n+ tempL += std::numeric_limits<Q>::infinity();\n+ }\n- for (auto l = b +1; l < this->bits_per_symbol; l++)\n- tempL += (j & (1 << l)) * Y_N2[k * this->bits_per_symbol +l];\n+ }\n+ tempL = std::isnan((R)tempL) ? (Q)0.0 : tempL;\n- if ((j & (1 << b)) == 0)\n+ if (((j>>b) & 1) == 0)\nL0 = MAX(L0, -tempL);\nelse\nL1 = MAX(L1, -tempL);\n@@ -271,13 +281,22 @@ void Modem_PSK<B,R,Q,MAX>\ncomplex_Hk * std::complex<Q>((Q)this->constellation[j].real(),\n(Q)this->constellation[j].imag())) * inv_sigma2);\n- for (auto l = 0; l < b; l++)\n- tempL += (j & (1 << l)) * Y_N2[k * this->bits_per_symbol +l];\n+ for (auto l = 0; l < this->bits_per_symbol; l++)\n+ {\n+ if (l == b)\n+ continue;\n- for (auto l = b +1; l < this->bits_per_symbol; l++)\n- tempL += (j & (1 << l)) * Y_N2[k * this->bits_per_symbol +l];\n+ if (((j>>l) & 1) == 1)\n+ {\n+ if (k * this->bits_per_symbol +l < size)\n+ tempL += Y_N2[k * this->bits_per_symbol +l];\n+ else\n+ tempL += std::numeric_limits<Q>::infinity();\n+ }\n+ }\n+ tempL = std::isnan((R)tempL) ? (Q)0.0 : tempL;\n- if ((j & (1 << b)) == 0)\n+ if (((j>>b) & 1) == 0)\nL0 = MAX(L0, -tempL);\nelse\nL1 = MAX(L1, -tempL);\n@@ -286,5 +305,57 @@ void Modem_PSK<B,R,Q,MAX>\nY_N3[n] = (L0 - L1);\n}\n}\n+/*\n+* \\brief Soft Mapper\n+*/\n+template <typename B, typename R, typename Q, tools::proto_max<Q> MAX>\n+void Modem_PSK<B, R, Q, MAX>\n+::_tmodulate(const Q *X_N1, R *X_N2, const int frame_id)\n+{\n+ auto size_in = this->N;\n+ auto size_out = this->N_mod;\n+\n+ auto loop_size = size_in / this->bits_per_symbol;\n+\n+ for (auto i = 0; i < loop_size; i++)\n+ {\n+ X_N2[2*i+0] = (R)0.0;\n+ X_N2[2*i+1] = (R)0.0;\n+\n+ for (auto m = 0; m < this->nbr_symbols; m++)\n+ {\n+ std::complex<R> soft_symbol = this->constellation[m];\n+ auto p = (R)1.0;\n+ for (auto j = 0; j < this->bits_per_symbol; j++)\n+ {\n+ auto p0 = (R)1.0/((R)1.0 + std::exp(-(R)(X_N1[i*this->bits_per_symbol + j])));\n+ p *= ((m >> j) & 1) == 0 ? p0 : (R)1.0 - p0;\n+ }\n+ X_N2[2*i] += p * soft_symbol.real();\n+ X_N2[2*i+1] += p * soft_symbol.imag();\n+ }\n+ }\n+\n+ // last elements if \"size_in\" is not a multiple of the number of bits per symbol\n+ if (loop_size * this->bits_per_symbol < size_in)\n+ {\n+ auto r = size_in - (loop_size * this->bits_per_symbol);\n+ X_N2[size_out - 2] = (R)0.0;\n+ X_N2[size_out - 1] = (R)0.0;\n+\n+ for (auto m = 0; m < (1<<r); m++)\n+ {\n+ std::complex<R> soft_symbol = this->constellation[m];\n+ auto p = (R)1.0;\n+ for (auto j = 0; j < r; j++)\n+ {\n+ auto p0 = (R)1.0/((R)1.0 + std::exp(-(R)X_N1[loop_size*this->bits_per_symbol + j]));\n+ p *= ((m >> j) & 1) == 0 ? p0 : (R)1.0 - p0;\n+ }\n+ X_N2[size_out - 2] += p*soft_symbol.real();\n+ X_N2[size_out - 1] += p*soft_symbol.imag();\n+ }\n+ }\n+}\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Modification of the handling of the bits of the las symbol for PSK modulation.
|
8,486 |
12.03.2018 14:44:43
| -3,600 |
3a1d89547ffb9127c67734fd783f6353e2efef88
|
Modification of the handling of the bits of the las symbol for QAM modulation.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/QAM/Modem_QAM.hxx",
"new_path": "src/Module/Modem/QAM/Modem_QAM.hxx",
"diff": "@@ -353,7 +353,7 @@ void Modem_QAM<B, R, Q, MAX>\nfor (auto j = 0; j < r; j++)\n{\nauto p0 = (R)1.0/((R)1.0 + std::exp(-(R)X_N1[loop_size*this->bits_per_symbol + j]));\n- p *= ((m >> j) & 1) == 0 ? p0 : 1 - p0;\n+ p *= ((m >> j) & 1) == 0 ? p0 : (R)1.0 - p0;\n}\nX_N2[size_out - 2] += p*soft_symbol.real();\nX_N2[size_out - 1] += p*soft_symbol.imag();\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Modification of the handling of the bits of the las symbol for QAM modulation.
|
8,490 |
14.03.2018 14:19:32
| -3,600 |
cae9471c5f156b73f5c64ee7b55afc9653098ddb
|
Fix a bug when static frozen bits.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/Polar/Codec_polar.cpp",
"new_path": "src/Module/Codec/Polar/Codec_polar.cpp",
"diff": "@@ -127,6 +127,7 @@ Codec_polar<B,Q>\nfb_generator->generate(frozen_bits);\nif (this->N_cw != this->N)\npuncturer_wangliu->gen_frozen_bits(frozen_bits);\n+ this->notify_frozenbits_update();\n}\n}\nelse\n@@ -140,6 +141,7 @@ Codec_polar<B,Q>\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\nstd::copy(fb.begin(), fb.end(), frozen_bits.begin());\n+ this->notify_frozenbits_update();\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix a bug when static frozen bits.
|
8,490 |
14.03.2018 14:19:53
| -3,600 |
19ad3490e506030f0f16c2313908b1b99b10b3e1
|
Restore stream conf.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/BFER/Terminal_BFER.cpp",
"new_path": "src/Tools/Display/Terminal/BFER/Terminal_BFER.cpp",
"diff": "#include <iostream>\n#include <iomanip>\n#include <sstream>\n+#include <ios>\n#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/Display/bash_tools.h\"\n@@ -64,6 +65,8 @@ template <typename B>\nvoid Terminal_BFER<B>\n::legend(std::ostream &stream)\n{\n+ std::ios::fmtflags f(stream.flags());\n+\n#ifdef _WIN32\nstream << \"# \" << format(\"---------------------------------------------------------------------------||---------------------\", Style::BOLD) << std::endl;\nstream << \"# \" << format(\" Bit Error Rate (BER) and Frame Error Rate (FER) depending || Global throughput \", Style::BOLD) << std::endl;\n@@ -84,6 +87,8 @@ void Terminal_BFER<B>\nstream << \"# \" << format(\" (dB) | (dB) | | | | | || (Mb/s) | (hhmmss) \", Style::BOLD) << std::endl;\nstream << \"# \" << format(\"-------|-------|----------|----------|----------|----------|----------||----------|----------\", Style::BOLD) << std::endl;\n#endif\n+\n+ stream.flags(f);\n}\ntemplate <typename B>\n@@ -161,6 +166,8 @@ void Terminal_BFER<B>\n{\nusing namespace std::chrono;\n+ std::ios::fmtflags f(stream.flags());\n+\n_report(stream);\nauto et = duration_cast<milliseconds>(steady_clock::now() - t_snr).count() / 1000.f;\n@@ -182,6 +189,7 @@ void Terminal_BFER<B>\nstream << \"\\r\";\nstream.flush();\n+ stream.flags(f);\n}\ntemplate <typename B>\n@@ -190,6 +198,8 @@ void Terminal_BFER<B>\n{\nusing namespace std::chrono;\n+ std::ios::fmtflags f(stream.flags());\n+\nTerminal::final_report(stream);\nthis->_report(stream);\n@@ -203,6 +213,8 @@ void Terminal_BFER<B>\nelse stream << \" \" << std::endl;\nt_snr = std::chrono::steady_clock::now();\n+\n+ stream.flags(f);\n}\n// ==================================================================================== explicit template instantiation\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": "#include <iostream>\n#include <iomanip>\n#include <sstream>\n+#include <ios>\n#include \"Tools/Display/bash_tools.h\"\n@@ -67,6 +68,8 @@ template <typename B, typename R>\nvoid Terminal_EXIT<B,R>\n::legend(std::ostream &stream)\n{\n+ std::ios::fmtflags f(stream.flags());\n+\nstream << \"# \" << format(\"----------------------------------------------------------||---------------------\", Style::BOLD) << std::endl;\nstream << \"# \" << format(\" EXIT chart depending on the Signal Noise Ratio (SNR) || Global throughput \", Style::BOLD) << std::endl;\nstream << \"# \" << format(\" and the channel A noise || and elapsed time \", Style::BOLD) << std::endl;\n@@ -75,6 +78,8 @@ void Terminal_EXIT<B,R>\nstream << \"# \" << format(\" Es/N0 | Eb/N0 | SIG_A | FRA | A_PRIORI | EXTRINSIC || SIM_THR | ET/RT \", Style::BOLD) << std::endl;\nstream << \"# \" << format(\" (dB) | (dB) | (dB) | | (I_A) | (I_E) || (Mb/s) | (hhmmss) \", Style::BOLD) << std::endl;\nstream << \"# \" << format(\"-------|-------|-------|----------|-----------|-----------||----------|----------\", Style::BOLD) << std::endl;\n+\n+ stream.flags(f);\n}\ntemplate <typename B, typename R>\n@@ -110,6 +115,8 @@ void Terminal_EXIT<B,R>\n{\nusing namespace std::chrono;\n+ std::ios::fmtflags f(stream.flags());\n+\n_report(stream);\nconst auto n_trials = monitor.get_n_trials();\n@@ -134,6 +141,7 @@ void Terminal_EXIT<B,R>\nstream << \"\\r\";\nstream.flush();\n+ stream.flags(f);\n}\ntemplate <typename B, typename R>\n@@ -142,6 +150,8 @@ void Terminal_EXIT<B,R>\n{\nusing namespace std::chrono;\n+ std::ios::fmtflags f(stream.flags());\n+\nTerminal::final_report(stream);\nthis->_report(stream);\n@@ -153,6 +163,8 @@ void Terminal_EXIT<B,R>\n<< std::endl;\nt_snr = std::chrono::steady_clock::now();\n+\n+ stream.flags(f);\n}\n// ==================================================================================== explicit template instantiation\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Restore stream conf.
|
8,490 |
14.03.2018 14:22:57
| -3,600 |
bd95d1605a29e13070d8474cf3318468777e3252
|
Rm useless processing.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/Polar/Codec_polar.cpp",
"new_path": "src/Module/Codec/Polar/Codec_polar.cpp",
"diff": "@@ -125,8 +125,6 @@ Codec_polar<B,Q>\nif (!adaptive_fb)\n{\nfb_generator->generate(frozen_bits);\n- if (this->N_cw != this->N)\n- puncturer_wangliu->gen_frozen_bits(frozen_bits);\nthis->notify_frozenbits_update();\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Rm useless processing.
|
8,481 |
07.03.2018 11:37:23
| -3,600 |
ff6fd4b9fc924b98f4e760186b4c6971e33d2fdb
|
Add Layered LDPC Approximate Min-Star
|
[
{
"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/LSPA/Decoder_LDPC_BP_layered_log_sum_product.hpp\"\n#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 \"Decoder_LDPC.hpp\"\n@@ -168,6 +169,14 @@ module::Decoder_SISO_SIHO<B,Q>* Decoder_LDPC::parameters\nif (this->implem == \"ONMS\") return new module::Decoder_LDPC_BP_layered_ONMS <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);\nelse if (this->implem == \"SPA\" ) return new module::Decoder_LDPC_BP_layered_SPA <B,Q>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, this->enable_syndrome, this->syndrome_depth, this->n_frames);\nelse if (this->implem == \"LSPA\") return new module::Decoder_LDPC_BP_layered_LSPA <B,Q>(this->K, this->N_cw, this->n_ite, H, info_bits_pos, this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->implem == \"AMS\" ) {\n+ if (this->min == \"MIN\")\n+ return new module::Decoder_LDPC_BP_layered_AMS<B,Q,tools::min<Q>> (this->K, this->N_cw, this->n_ite, H, info_bits_pos, this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->min == \"MINL\")\n+ return new module::Decoder_LDPC_BP_layered_AMS<B,Q,tools::min_star_linear2<Q>> (this->K, this->N_cw, this->n_ite, H, info_bits_pos, this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ else if (this->min == \"MINS\")\n+ return new module::Decoder_LDPC_BP_layered_AMS<B,Q,tools::min_star<Q>> (this->K, this->N_cw, this->n_ite, H, info_bits_pos, this->enable_syndrome, this->syndrome_depth, this->n_frames);\n+ }\n}\nelse if (this->type == \"BP_LAYERED\" && this->simd_strategy == \"INTER\")\n{\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Decoder/LDPC/BP/Layered/AMS/Decoder_LDPC_BP_layered_approximate_min_star.hpp",
"diff": "+#ifndef DECODER_LDPC_BP_LAYERED_AMS_HPP_\n+#define DECODER_LDPC_BP_LAYERED_AMS_HPP_\n+\n+#include \"Tools/Math/max.h\"\n+\n+#include \"../Decoder_LDPC_BP_layered.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+template <typename B = int, typename R = float, tools::proto_min<R> MIN = tools::min_star_linear2>\n+class Decoder_LDPC_BP_layered_approximate_min_star : public Decoder_LDPC_BP_layered<B,R>\n+{\n+private:\n+ std::vector<R> contributions;\n+ std::vector<R> values;\n+\n+public:\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 std::vector<unsigned> &info_bits_pos,\n+ const bool enable_syndrome = true,\n+ const int syndrome_depth = 1,\n+ const int n_frames = 1);\n+ virtual ~Decoder_LDPC_BP_layered_approximate_min_star();\n+\n+protected:\n+ void BP_process(std::vector<R> &var_nodes, std::vector<R> &branches);\n+};\n+\n+template <typename B = int, typename R = float, tools::proto_min<R> MIN = tools::min_star_linear2>\n+using Decoder_LDPC_BP_layered_AMS = Decoder_LDPC_BP_layered_approximate_min_star<B,R,MIN>;\n+}\n+}\n+\n+#include \"Decoder_LDPC_BP_layered_approximate_min_star.hxx\"\n+\n+#endif /* DECODER_LDPC_BP_LAYERED_AMS_HPP_ */\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Decoder/LDPC/BP/Layered/AMS/Decoder_LDPC_BP_layered_approximate_min_star.hxx",
"diff": "+#include <Module/Decoder/LDPC/BP/Layered/AMS/Decoder_LDPC_BP_layered_approximate_min_star.hpp>\n+#include <typeinfo>\n+#include <limits>\n+#include <cmath>\n+\n+#include \"Tools/Exception/exception.hpp\"\n+#include \"Tools/Math/utils.h\"\n+\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+template <typename B, typename R, tools::proto_min<R> MIN>\n+Decoder_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 std::vector<unsigned> &info_bits_pos,\n+ const bool enable_syndrome,\n+ const int syndrome_depth,\n+ const 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+{\n+ const std::string name = \"Decoder_LDPC_BP_layered_approximate_min_star\";\n+ this->set_name(name);\n+\n+ if (typeid(R) != typeid(float) && typeid(R) != typeid(double))\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, \"This decoder only supports floating-point LLRs.\");\n+}\n+\n+template <typename B, typename R, tools::proto_min<R> MIN>\n+Decoder_LDPC_BP_layered_approximate_min_star<B,R,MIN>\n+::~Decoder_LDPC_BP_layered_approximate_min_star()\n+{\n+}\n+\n+// BP algorithm\n+template <typename B, typename R, tools::proto_min<R> MIN>\n+void Decoder_LDPC_BP_layered_approximate_min_star<B,R,MIN>\n+::BP_process(std::vector<R> &var_nodes, std::vector<R> &branches)\n+{\n+ auto kr = 0;\n+ auto kw = 0;\n+ for (auto i = 0; i < this->n_C_nodes; i++)\n+ {\n+ auto sign = 0;\n+ auto min = std::numeric_limits<R>::max();\n+ auto deltaMin = std::numeric_limits<R>::max();\n+\n+ const auto n_VN = (int)this->H[i].size();\n+ for (auto j = 0; j < n_VN; j++)\n+ {\n+ contributions[j] = var_nodes[this->H[i][j]] - branches[kr++];\n+ const auto v_abs = (R)std::abs(contributions[j]);\n+ const auto c_sign = std::signbit((float)contributions[j]) ? -1 : 0;\n+ const auto v_temp = min;\n+\n+ sign ^= c_sign;\n+ min = std::min(min, v_abs);\n+ deltaMin = MIN(deltaMin, (v_abs == min) ? v_temp : v_abs);\n+ }\n+\n+ auto delta = MIN (deltaMin, min );\n+ delta = std::max((R)0, delta );\n+ deltaMin = std::max((R)0, deltaMin);\n+\n+ for (auto j = 0; j < n_VN; j++)\n+ {\n+ const auto value = contributions[j];\n+ const auto v_abs = (R)std::abs(value);\n+ auto v_res = ((v_abs == min) ? deltaMin : delta); // cmov\n+ const auto v_sig = sign ^ (std::signbit((float)value) ? -1 : 0); // xor bit\n+ v_res = (R)std::copysign(v_res, v_sig); // magnitude of v_res, sign of v_sig\n+\n+ branches[kw++] = v_res;\n+ var_nodes[this->H[i][j]] = contributions[j] + v_res;\n+ }\n+ }\n+}\n+}\n+}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add Layered LDPC Approximate Min-Star
Signed-off-by: Adrien Cassagne <adrien.cassagne@inria.fr>
|
8,490 |
14.03.2018 16:36:06
| -3,600 |
8523341f2f9599e495751f6435de20c5735b0659
|
Fix bad style include.
|
[
{
"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": "-#include <Module/Decoder/LDPC/BP/Layered/AMS/Decoder_LDPC_BP_layered_approximate_min_star.hpp>\n#include <typeinfo>\n#include <limits>\n#include <cmath>\n#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/Math/utils.h\"\n+#include \"Decoder_LDPC_BP_layered_approximate_min_star.hpp\"\nnamespace aff3ct\n{\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix bad style include.
|
8,481 |
08.03.2018 14:03:26
| -3,600 |
cd000c9d3e76a8c422f6f9e645d1421f38ce27f1
|
Fix bug when using replay bad frames
Fix a bug when the simulation is stopped after the first point of SNR when replaying bad frames.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.cpp",
"new_path": "src/Simulation/BFER/BFER.cpp",
"diff": "@@ -258,7 +258,7 @@ void BFER<B,R,Q>\nthis->dumper_red->clear();\n}\n- if (!module::Monitor::is_interrupt() && this->monitor_red->get_n_fe() < this->monitor_red->get_fe_limit() &&\n+ if (!params_BFER.err_track_revert && !module::Monitor::is_interrupt() && this->monitor_red->get_n_fe() < this->monitor_red->get_fe_limit() &&\n(max_fra == 0 || this->monitor_red->get_n_fe() < max_fra))\nmodule::Monitor::stop();\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix bug when using replay bad frames
Fix a bug when the simulation is stopped after the first point of SNR when replaying bad frames.
Signed-off-by: Adrien Cassagne <adrien.cassagne@inria.fr>
|
8,483 |
16.03.2018 14:37:09
| -3,600 |
902af9100799e65d05d96777d733d25cc71b01a8
|
Change name tools/perf/hard_decision.h -> common.h; Add a MIPP optimized hamming_distance calculation function
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/Generic/Chase/Decoder_chase_std.cpp",
"new_path": "src/Module/Decoder/Generic/Chase/Decoder_chase_std.cpp",
"diff": "#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/Algo/Bit_packer.hpp\"\n-#include \"Tools/Perf/hard_decision.h\"\n+#include \"Tools/Perf/common.h\"\n#include \"Decoder_chase_std.hpp\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/Generic/ML/Decoder_maximum_likelihood.hxx",
"new_path": "src/Module/Decoder/Generic/ML/Decoder_maximum_likelihood.hxx",
"diff": "#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/Algo/Bit_packer.hpp\"\n-#include \"Tools/Perf/hard_decision.h\"\n+#include \"Tools/Perf/common.h\"\n#include \"Decoder_maximum_likelihood.hpp\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/Generic/ML/Decoder_maximum_likelihood_naive.cpp",
"new_path": "src/Module/Decoder/Generic/ML/Decoder_maximum_likelihood_naive.cpp",
"diff": "#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/Algo/Bit_packer.hpp\"\n-#include \"Tools/Perf/hard_decision.h\"\n+#include \"Tools/Perf/common.h\"\n#include \"Decoder_maximum_likelihood_naive.hpp\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/Generic/ML/Decoder_maximum_likelihood_std.cpp",
"new_path": "src/Module/Decoder/Generic/ML/Decoder_maximum_likelihood_std.cpp",
"diff": "#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/Algo/Bit_packer.hpp\"\n-#include \"Tools/Perf/hard_decision.h\"\n+#include \"Tools/Perf/common.h\"\n#include \"Decoder_maximum_likelihood_std.hpp\"\n"
},
{
"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 <cmath>\n#include <stdexcept>\n-#include \"Tools/Perf/hard_decision.h\"\n+#include \"Tools/Perf/common.h\"\n#include \"Tools/Math/utils.h\"\n#include \"Decoder_LDPC_BP.hpp\"\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": "#include <limits>\n#include <sstream>\n-#include \"Tools/Perf/hard_decision.h\"\n+#include \"Tools/Perf/common.h\"\n#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/Math/utils.h\"\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": "#include <cmath>\n#include <stdexcept>\n-#include \"Tools/Perf/hard_decision.h\"\n+#include \"Tools/Perf/common.h\"\n#include \"Tools/Math/utils.h\"\n#include \"Decoder_LDPC_BP_layered.hpp\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/NO/Decoder_NO.cpp",
"new_path": "src/Module/Decoder/NO/Decoder_NO.cpp",
"diff": "#include <chrono>\n-#include \"Tools/Perf/hard_decision.h\"\n+#include \"Tools/Perf/common.h\"\n#include \"Decoder_NO.hpp\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/RA/Decoder_RA.cpp",
"new_path": "src/Module/Decoder/RA/Decoder_RA.cpp",
"diff": "#include <algorithm>\n#include <cmath>\n-#include \"Tools/Perf/hard_decision.h\"\n+#include \"Tools/Perf/common.h\"\n#include \"Tools/Exception/exception.hpp\"\n#include \"Decoder_RA.hpp\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/Repetition/Decoder_repetition.cpp",
"new_path": "src/Module/Decoder/Repetition/Decoder_repetition.cpp",
"diff": "#include <sstream>\n#include <algorithm>\n-#include \"Tools/Perf/hard_decision.h\"\n+#include \"Tools/Perf/common.h\"\n#include \"Tools/Exception/exception.hpp\"\n#include \"Decoder_repetition.hpp\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/Turbo/Decoder_turbo_fast.cpp",
"new_path": "src/Module/Decoder/Turbo/Decoder_turbo_fast.cpp",
"diff": "#include <iostream>\n#include <algorithm>\n-#include \"Tools/Perf/hard_decision.h\"\n+#include \"Tools/Perf/common.h\"\n#include \"Tools/Perf/Reorderer/Reorderer.hpp\"\n#include \"Decoder_turbo_fast.hpp\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/Turbo/Decoder_turbo_std.cpp",
"new_path": "src/Module/Decoder/Turbo/Decoder_turbo_std.cpp",
"diff": "#include <iostream>\n#include <algorithm>\n-#include \"Tools/Perf/hard_decision.h\"\n+#include \"Tools/Perf/common.h\"\n#include \"Decoder_turbo_std.hpp\"\n"
},
{
"change_type": "RENAME",
"old_path": "src/Tools/Perf/hard_decision.h",
"new_path": "src/Tools/Perf/common.h",
"diff": "-#ifndef HARD_DECISION_H_\n-#define HARD_DECISION_H_\n+#ifndef COMMON_H_\n+#define COMMON_H_\n#include <mipp.h>\n@@ -33,7 +33,33 @@ inline void hard_decide(const R *in, B *out, const int size)\nfor (auto i = vec_loop_size; i < size; i++)\nout[i] = in[i] < 0;\n}\n+\n+template <typename B = int>\n+inline size_t hamming_distance(const B *in1, const B *in2, const int size)\n+{\n+ const mipp::Reg<B> zeros = (B)0, ones = (B)1;\n+ mipp::Reg<B> counter = (B)0;\n+\n+ const auto vec_loop_size = (size / mipp::nElReg<B>()) * mipp::nElReg<B>();\n+\n+ for (auto i = 0; i < vec_loop_size; i += mipp::nElReg<B>())\n+ {\n+ const auto r_in1 = mipp::Reg<B>(&in1[i]);\n+ const auto r_in2 = mipp::Reg<B>(&in2[i]);\n+ const auto m_in1 = r_in1 != zeros;\n+ const auto m_in2 = r_in2 != zeros;\n+ counter += mipp::blend(ones, zeros, m_in1 ^ m_in2);\n+ }\n+\n+ size_t ham_dist = mipp::hadd(counter);\n+\n+ for (auto i = vec_loop_size; i < size; i++)\n+ ham_dist += (!in1[i] != !in2[i])? 1 : 0;\n+\n+ return ham_dist;\n+}\n+\n}\n}\n-#endif /* HARD_DECISION_H_ */\n+#endif /* COMMON_H_ */\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Change name tools/perf/hard_decision.h -> common.h; Add a MIPP optimized hamming_distance calculation function
|
8,483 |
16.03.2018 14:54:10
| -3,600 |
7305fb72df4dca93ca146fcba59390dd20ac8178
|
Refacto the BCH decoders
Move the original BCH decoder into a sub type Standard; Create then a BCH decoder mother class.
Create a BCH decoder genius fast: MIPP optimized.
Modify consequently the BCH codec and the factory decoder BCH
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Decoder/BCH/Decoder_BCH.cpp",
"new_path": "src/Factory/Module/Decoder/BCH/Decoder_BCH.cpp",
"diff": "#include <sstream>\n-#include \"Module/Decoder/BCH/Decoder_BCH.hpp\"\n+#include \"Module/Decoder/BCH/Standard/Decoder_BCH_std.hpp\"\n+#include \"Module/Decoder/BCH/Genius/Decoder_BCH_genius.hpp\"\n+#include \"Module/Decoder/BCH/Genius/Decoder_BCH_genius_fast.hpp\"\n#include \"Tools/Exception/exception.hpp\"\n@@ -43,7 +45,8 @@ void Decoder_BCH::parameters\ntools::Integer(tools::Positive(), tools::Non_zero()),\n\"correction power of the BCH code.\");\n- tools::add_options(args.at({p+\"-type\", \"D\"}), 0, \"ALGEBRAIC\");\n+ tools::add_options(args.at({p+\"-type\", \"D\"}), 0, \"ALGEBRAIC\", \"GENIUS\");\n+ tools::add_options(args.at({p+\"-implem\" }), 0, \"FAST\");\n}\nvoid Decoder_BCH::parameters\n@@ -110,7 +113,14 @@ module::Decoder_SIHO_HIHO<B,Q>* Decoder_BCH::parameters\n{\nif (this->type == \"ALGEBRAIC\")\n{\n- if (this->implem == \"STD\") return new module::Decoder_BCH<B,Q>(this->K, this->N_cw, GF, this->n_frames);\n+ if (this->implem == \"STD\") return new module::Decoder_BCH_std<B,Q>(this->K, this->N_cw, GF, this->n_frames);\n+ }\n+\n+ if (encoder)\n+ {\n+ if (this->type == \"GENIUS\")\n+ if (this->implem == \"STD\" ) return new module::Decoder_BCH_genius <B,Q>(this->K, this->N_cw, this->t, *encoder, this->n_frames);\n+ if (this->implem == \"FAST\") return new module::Decoder_BCH_genius_fast<B,Q>(this->K, this->N_cw, this->t, *encoder, this->n_frames);\n}\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/BCH/Codec_BCH.cpp",
"new_path": "src/Module/Codec/BCH/Codec_BCH.cpp",
"diff": "@@ -55,15 +55,21 @@ Codec_BCH<B,Q>\nthis->set_puncturer(factory::Puncturer::build<B,Q>(pct_params));\n+ Encoder<B>* encoder;\ntry\n{\n- this->set_encoder(factory::Encoder_BCH::build<B>(enc_params, GF_poly));\n+ encoder = factory::Encoder_BCH::build<B>(enc_params, GF_poly);\n}\ncatch (tools::cannot_allocate const&)\n{\n- this->set_encoder(factory::Encoder::build<B>(enc_params));\n+ encoder = factory::Encoder::build<B>(enc_params);\n}\n+ if (dec_params.type == \"GENIUS\")\n+ encoder->set_memorizing(true);\n+\n+ this->set_encoder(encoder);\n+\nauto decoder_hiho_siho = factory::Decoder_BCH::build_hiho<B,Q>(dec_params, GF_poly, this->get_encoder());\nthis->set_decoder_siho(decoder_hiho_siho);\nthis->set_decoder_hiho(decoder_hiho_siho);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/Codec.hpp",
"new_path": "src/Module/Codec/Codec.hpp",
"diff": "#include <sstream>\n#include \"Tools/Exception/exception.hpp\"\n-#include \"Tools/Perf/hard_decision.h\"\n+#include \"Tools/Perf/common.h\"\n#include \"Tools/Interleaver/Interleaver_core.hpp\"\n#include \"Factory/Module/Interleaver/Interleaver.hpp\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/BCH/Decoder_BCH.cpp",
"new_path": "src/Module/Decoder/BCH/Decoder_BCH.cpp",
"diff": "#include <chrono>\n#include <sstream>\n-#include \"Tools/Perf/hard_decision.h\"\n+#include \"Tools/Perf/common.h\"\n#include \"Tools/Exception/exception.hpp\"\n#include \"Decoder_BCH.hpp\"\n@@ -11,12 +11,10 @@ using namespace aff3ct::module;\ntemplate <typename B, typename R>\nDecoder_BCH<B, R>\n-::Decoder_BCH(const int& K, const int& N, const tools::BCH_polynomial_generator &GF_poly, const int n_frames)\n+::Decoder_BCH(const int K, const int N, const int t, const int n_frames)\n: Decoder (K, N, n_frames, 1),\nDecoder_SIHO_HIHO<B,R>(K, N, n_frames, 1),\n- elp(N+2, std::vector<int>(N)), discrepancy(N+2), l(N+2), u_lu(N+2), s(N+1), loc(200), reg(201),\n- m(GF_poly.get_m()), t(GF_poly.get_t()), d(GF_poly.get_d()), alpha_to(GF_poly.get_alpha_to()), index_of(GF_poly.get_index_of()),\n- YH_N(N)\n+ t(t), YH_N(N)\n{\nconst std::string name = \"Decoder_BCH\";\nthis->set_name(name);\n@@ -35,170 +33,6 @@ Decoder_BCH<B, R>\n{\n}\n-template <typename B, typename R>\n-void Decoder_BCH<B, R>\n-::_decode(B *Y_N, const int frame_id)\n-{\n- int i, j, t2, syn_error = 0;\n-\n- t2 = 2 * t;\n-\n- /* first form the syndromes */\n- for (i = 1; i <= t2; i++)\n- {\n- s[i] = 0;\n- for (j = 0; j < this->N; j++)\n- if (Y_N[j] != 0)\n- s[i] ^= alpha_to[(i * j) % this->N];\n- if (s[i] != 0)\n- syn_error = 1; /* set error flag if non-zero syndrome */\n- /*\n- * Note: If the code is used only for ERROR DETECTION, then\n- * exit program here indicating the presence of errors.\n- */\n- /* convert syndrome from polynomial form to index form */\n- s[i] = index_of[s[i]];\n- }\n-\n- if (syn_error)\n- { /* if there are errors, try to correct them */\n- /*\n- * Compute the error location polynomial via the Berlekamp\n- * iterative algorithm. Following the terminology of Lin and\n- * Costello's book : d[u] is the 'mu'th discrepancy, where\n- * u='mu'+1 and 'mu' (the Greek letter!) is the step number\n- * ranging from -1 to 2*t (see L&C), l[u] is the degree of\n- * the elp at that step, and u_l[u] is the difference between\n- * the step number and the degree of the elp.\n- */\n- /* initialise table entries */\n- discrepancy[0] = 0; /* index form */\n- discrepancy[1] = s[1]; /* index form */\n- elp[0][0] = 0; /* index form */\n- elp[1][0] = 1; /* polynomial form */\n- for (i = 1; i < t2; i++)\n- {\n- elp[0][i] = -1; /* index form */\n- elp[1][i] = 0; /* polynomial form */\n- }\n- l[0] = 0;\n- l[1] = 0;\n- u_lu[0] = -1;\n- u_lu[1] = 0;\n-\n- int q, u = 0;\n- do\n- {\n- u++;\n- if (discrepancy[u] == -1)\n- {\n- l[u + 1] = l[u];\n- for (i = 0; i <= l[u]; i++)\n- {\n- elp[u + 1][i] = elp[u][i];\n- elp[u][i] = index_of[elp[u][i]];\n- }\n- }\n- else\n- /*\n- * search for words with greatest u_lu[q] for\n- * which d[q]!=0\n- */\n- {\n- q = u - 1;\n- while ((discrepancy[q] == -1) && (q > 0))\n- q--;\n- /* have found first non-zero d[q] */\n- if (q > 0)\n- {\n- j = q;\n- do\n- {\n- j--;\n- if ((discrepancy[j] != -1) && (u_lu[q] < u_lu[j]))\n- q = j;\n- }\n- while (j > 0);\n- }\n-\n- /*\n- * have now found q such that d[u]!=0 and\n- * u_lu[q] is maximum\n- */\n- /* store degree of new elp polynomial */\n- if (l[u] > l[q] + u - q)\n- l[u + 1] = l[u];\n- else\n- l[u + 1] = l[q] + u - q;\n-\n- /* form new elp(x) */\n- for (i = 0; i < t2; i++)\n- elp[u + 1][i] = 0;\n- for (i = 0; i <= l[q]; i++)\n- if (elp[q][i] != -1)\n- elp[u + 1][i + u - q] =\n- alpha_to[(discrepancy[u] + this->N - discrepancy[q] + elp[q][i]) % this->N];\n- for (i = 0; i <= l[u]; i++)\n- {\n- elp[u + 1][i] ^= elp[u][i];\n- elp[u][i] = index_of[elp[u][i]];\n- }\n- }\n- u_lu[u + 1] = u - l[u + 1];\n-\n- /* form (u+1)th discrepancy */\n- if (u < t2)\n- {\n- /* no discrepancy computed on last iteration */\n- if (s[u + 1] != -1)\n- discrepancy[u + 1] = alpha_to[s[u + 1]];\n- else\n- discrepancy[u + 1] = 0;\n- for (i = 1; i <= l[u + 1]; i++)\n- if ((s[u + 1 - i] != -1) && (elp[u + 1][i] != 0))\n- discrepancy[u + 1] ^= alpha_to[(s[u + 1 - i] + index_of[elp[u + 1][i]]) % this->N];\n- /* put d[u+1] into index form */\n- discrepancy[u + 1] = index_of[discrepancy[u + 1]];\n- }\n- }\n- while ((u < t2) && (l[u + 1] <= t));\n-\n- u++;\n- if (l[u] <= t)\n- {/* Can correct errors */\n- /* put elp into index form */\n- for (i = 0; i <= l[u]; i++)\n- elp[u][i] = index_of[elp[u][i]];\n-\n- /* Chien search: find roots of the error location polynomial */\n- for (i = 1; i <= l[u]; i++)\n- reg[i] = elp[u][i];\n- int count = 0;\n- for (i = 1; i <= this->N; i++)\n- {\n- q = 1;\n- for (j = 1; j <= l[u]; j++)\n- if (reg[j] != -1)\n- {\n- reg[j] = (reg[j] + j) % this->N;\n- q ^= alpha_to[reg[j]];\n- }\n- if (!q)\n- { /* store root and error\n- * location number indices */\n- loc[count] = this->N - i;\n- count++;\n- }\n- }\n-\n- if (count == l[u])\n- /* no. roots = degree of elp hence <= t errors */\n- for (i = 0; i < l[u]; i++)\n- Y_N[loc[i]] ^= 1;\n- }\n- }\n-}\n-\ntemplate <typename B, typename R>\nvoid Decoder_BCH<B, R>\n::_decode_hiho(const B *Y_N, B *V_K, const int frame_id)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/BCH/Decoder_BCH.hpp",
"new_path": "src/Module/Decoder/BCH/Decoder_BCH.hpp",
"diff": "@@ -14,35 +14,20 @@ namespace module\ntemplate <typename B = int, typename R = float>\nclass Decoder_BCH : public Decoder_SIHO_HIHO<B,R>\n{\n-private:\n- std::vector<std::vector<int>> elp;\n- std::vector<int> discrepancy;\n- std::vector<int> l;\n- std::vector<int> u_lu;\n- std::vector<int> s;\n- std::vector<int> loc;\n- std::vector<int> reg;\n-\nprotected:\n- const int m; // order of the Galois Field\nconst int t; // correction power\n- const int d; // minimum distance of the code (d=2t+1))\n-\n- const std::vector<int>& alpha_to; // log table of GF(2**m)\n- const std::vector<int>& index_of; // antilog table of GF(2**m)\n-\nstd::vector<B> YH_N; // hard decision input vector\npublic:\n- Decoder_BCH(const int& K, const int& N, const tools::BCH_polynomial_generator &GF, const int n_frames = 1);\n+ Decoder_BCH(const int K, const int N, const int t, const int n_frames = 1);\nvirtual ~Decoder_BCH();\nprotected:\n- virtual void _decode( B *Y_N, const int frame_id);\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 ( B *Y_N, const int frame_id) = 0;\n+ virtual void _decode_hiho (const B *Y_N, B *V_K, const int frame_id);\n+ virtual void _decode_hiho_cw(const B *Y_N, B *V_N, const int frame_id);\n+ virtual void _decode_siho (const R *Y_N, B *V_K, const int frame_id);\n+ virtual void _decode_siho_cw(const R *Y_N, B *V_N, const int frame_id);\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/BCH/Genius/Decoder_BCH_genius.cpp",
"new_path": "src/Module/Decoder/BCH/Genius/Decoder_BCH_genius.cpp",
"diff": "#include <chrono>\n#include <sstream>\n-#include \"Tools/Perf/hard_decision.h\"\n+#include \"Tools/Perf/common.h\"\n#include \"Tools/Exception/exception.hpp\"\n#include \"Decoder_BCH_genius.hpp\"\n@@ -11,14 +11,21 @@ using namespace aff3ct::module;\ntemplate <typename B, typename R>\nDecoder_BCH_genius<B, R>\n-::Decoder_BCH_genius(const int& K, const int& N, const tools::BCH_polynomial_generator &GF_poly, Encoder<B> &encoder, const int n_frames)\n+::Decoder_BCH_genius(const int K, const int N, const int t, Encoder<B> &encoder, const int n_frames)\n: Decoder (K, N, n_frames, 1),\n- Decoder_BCH<B,R>(K, N, GF_poly, n_frames),\n+ Decoder_BCH<B,R>(K, N, t, n_frames),\nencoder(encoder),\n- error_pos(this->t)\n+ error_pos(this->t + 1)\n{\nconst std::string name = \"Decoder_BCH_genius\";\nthis->set_name(name);\n+\n+ if (!encoder.is_memorizing())\n+ {\n+ std::stringstream message;\n+ message << \"The given 'encoder' has to be memorizing its generated code words.\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n}\ntemplate <typename B, typename R>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/BCH/Genius/Decoder_BCH_genius.hpp",
"new_path": "src/Module/Decoder/BCH/Genius/Decoder_BCH_genius.hpp",
"diff": "@@ -19,7 +19,7 @@ protected:\nstd::vector<unsigned> error_pos;\npublic:\n- Decoder_BCH_genius(const int& K, const int& N, const tools::BCH_polynomial_generator &GF, Encoder<B> &encoder, const int n_frames = 1);\n+ Decoder_BCH_genius(const int K, const int N, const int t, Encoder<B> &encoder, const int n_frames = 1);\nvirtual ~Decoder_BCH_genius();\nprotected:\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Decoder/BCH/Genius/Decoder_BCH_genius_fast.cpp",
"diff": "+#include <chrono>\n+#include <sstream>\n+\n+#include \"Tools/Perf/common.h\"\n+#include \"Tools/Exception/exception.hpp\"\n+\n+#include \"Decoder_BCH_genius_fast.hpp\"\n+\n+using namespace aff3ct;\n+using namespace aff3ct::module;\n+\n+template <typename B, typename R>\n+Decoder_BCH_genius_fast<B, R>\n+::Decoder_BCH_genius_fast(const int K, const int N, const int t, Encoder<B> &encoder, const int n_frames)\n+: Decoder (K, N, n_frames, 1),\n+ Decoder_BCH<B,R>(K, N, t, n_frames),\n+ encoder(encoder)\n+{\n+ const std::string name = \"Decoder_BCH_genius_fast\";\n+ this->set_name(name);\n+\n+ if (!encoder.is_memorizing())\n+ {\n+ std::stringstream message;\n+ message << \"The given 'encoder' has to be memorizing its generated code words.\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+}\n+\n+template <typename B, typename R>\n+Decoder_BCH_genius_fast<B, R>\n+::~Decoder_BCH_genius_fast()\n+{\n+}\n+\n+template <typename B, typename R>\n+void Decoder_BCH_genius_fast<B, R>\n+::_decode(B *Y_N, const int frame_id)\n+{\n+ throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n+}\n+\n+template <typename B, typename R>\n+void Decoder_BCH_genius_fast<B, R>\n+::_decode_hiho(const B *Y_N, B *V_K, const int frame_id)\n+{\n+ auto& X_N = encoder.get_X_N(frame_id);\n+\n+ int n_error = tools::hamming_distance(X_N.data(), Y_N, this->N);\n+\n+ if (n_error <= this->t) // then copy X_N from the encoder that is Y_N corrected\n+ std::copy(X_N.data() + this->N - this->K, X_N.data() + this->N, V_K);\n+ else // then copy Y_N uncorrected\n+ std::copy(Y_N + this->N - this->K, Y_N + this->N, V_K);\n+}\n+\n+template <typename B, typename R>\n+void Decoder_BCH_genius_fast<B, R>\n+::_decode_hiho_cw(const B *Y_N, B *V_N, const int frame_id)\n+{\n+ auto& X_N = encoder.get_X_N(frame_id);\n+\n+ int n_error = tools::hamming_distance(X_N.data(), Y_N, this->N);\n+\n+ if (n_error <= this->t) // then copy X_N from the encoder that is Y_N corrected\n+ std::copy(X_N.data(), X_N.data() + this->N, V_N);\n+ else // then copy Y_N uncorrected\n+ std::copy(Y_N, Y_N + this->N, V_N);\n+}\n+\n+template <typename B, typename R>\n+void Decoder_BCH_genius_fast<B, R>\n+::_decode_siho(const R *Y_N, B *V_K, const int frame_id)\n+{\n+ tools::hard_decide(Y_N, this->YH_N.data(), this->N);\n+\n+ this->_decode_hiho(this->YH_N.data(), V_K, frame_id);\n+}\n+\n+template <typename B, typename R>\n+void Decoder_BCH_genius_fast<B, R>\n+::_decode_siho_cw(const R *Y_N, B *V_N, const int frame_id)\n+{\n+ tools::hard_decide(Y_N, this->YH_N.data(), this->N);\n+\n+ this->_decode_hiho_cw(this->YH_N.data(), V_N, frame_id);\n+}\n+\n+// ==================================================================================== explicit template instantiation\n+#include \"Tools/types.h\"\n+#ifdef MULTI_PREC\n+template class aff3ct::module::Decoder_BCH_genius_fast<B_8,Q_8>;\n+template class aff3ct::module::Decoder_BCH_genius_fast<B_16,Q_16>;\n+template class aff3ct::module::Decoder_BCH_genius_fast<B_32,Q_32>;\n+template class aff3ct::module::Decoder_BCH_genius_fast<B_64,Q_64>;\n+#else\n+template class aff3ct::module::Decoder_BCH_genius_fast<B,Q>;\n+#endif\n+// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Decoder/BCH/Genius/Decoder_BCH_genius_fast.hpp",
"diff": "+#ifndef DECODER_BCH_GENIUS_FAST\n+#define DECODER_BCH_GENIUS_FAST\n+\n+#include <vector>\n+\n+#include \"Module/Encoder/Encoder.hpp\"\n+#include \"../Decoder_BCH.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+template <typename B = int, typename R = float>\n+class Decoder_BCH_genius_fast : public Decoder_BCH<B,R>\n+{\n+protected:\n+ Encoder<B> &encoder;\n+\n+public:\n+ Decoder_BCH_genius_fast(const int K, const int N, const int t, Encoder<B> &encoder, const int n_frames = 1);\n+ virtual ~Decoder_BCH_genius_fast();\n+\n+protected:\n+ virtual void _decode ( B *Y_N, const int frame_id);\n+ virtual void _decode_hiho (const B *Y_N, B *V_K, const int frame_id);\n+ virtual void _decode_hiho_cw(const B *Y_N, B *V_N, const int frame_id);\n+ virtual void _decode_siho (const R *Y_N, B *V_K, const int frame_id);\n+ virtual void _decode_siho_cw(const R *Y_N, B *V_N, const int frame_id);\n+};\n+}\n+}\n+\n+#endif /* DECODER_BCH_GENIUS_FAST */\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Decoder/BCH/Standard/Decoder_BCH_std.cpp",
"diff": "+#include <chrono>\n+#include <sstream>\n+\n+#include \"Tools/Perf/common.h\"\n+#include \"Tools/Exception/exception.hpp\"\n+\n+#include \"Decoder_BCH_std.hpp\"\n+\n+using namespace aff3ct;\n+using namespace aff3ct::module;\n+\n+template <typename B, typename R>\n+Decoder_BCH_std<B, R>\n+::Decoder_BCH_std(const int& K, const int& N, const tools::BCH_polynomial_generator &GF_poly, const int n_frames)\n+: Decoder (K, N, n_frames, 1),\n+ Decoder_BCH<B,R>(K, N, GF_poly.get_t(), n_frames),\n+ elp(N+2, std::vector<int>(N)), discrepancy(N+2), l(N+2), u_lu(N+2), s(N+1), loc(200), reg(201),\n+ m(GF_poly.get_m()), d(GF_poly.get_d()), alpha_to(GF_poly.get_alpha_to()), index_of(GF_poly.get_index_of()),\n+ t2(2 * this->t)\n+{\n+ const std::string name = \"Decoder_BCH_std\";\n+ this->set_name(name);\n+}\n+\n+template <typename B, typename R>\n+Decoder_BCH_std<B, R>\n+::~Decoder_BCH_std()\n+{\n+}\n+\n+template <typename B, typename R>\n+void Decoder_BCH_std<B, R>\n+::_decode(B *Y_N, const int frame_id)\n+{\n+ int i, j, syn_error = 0;\n+\n+ /* first form the syndromes */\n+ for (i = 1; i <= t2; i++)\n+ {\n+ s[i] = 0;\n+ for (j = 0; j < this->N; j++)\n+ if (Y_N[j] != 0)\n+ s[i] ^= alpha_to[(i * j) % this->N];\n+ if (s[i] != 0)\n+ syn_error = 1; /* set error flag if non-zero syndrome */\n+ /*\n+ * Note: If the code is used only for ERROR DETECTION, then\n+ * exit program here indicating the presence of errors.\n+ */\n+ /* convert syndrome from polynomial form to index form */\n+ s[i] = index_of[s[i]];\n+ }\n+\n+ if (syn_error)\n+ { /* if there are errors, try to correct them */\n+ /*\n+ * Compute the error location polynomial via the Berlekamp\n+ * iterative algorithm. Following the terminology of Lin and\n+ * Costello's book : d[u] is the 'mu'th discrepancy, where\n+ * u='mu'+1 and 'mu' (the Greek letter!) is the step number\n+ * ranging from -1 to 2*this->t (see L&C), l[u] is the degree of\n+ * the elp at that step, and u_l[u] is the difference between\n+ * the step number and the degree of the elp.\n+ */\n+ /* initialise table entries */\n+ discrepancy[0] = 0; /* index form */\n+ discrepancy[1] = s[1]; /* index form */\n+ elp[0][0] = 0; /* index form */\n+ elp[1][0] = 1; /* polynomial form */\n+ for (i = 1; i < t2; i++)\n+ {\n+ elp[0][i] = -1; /* index form */\n+ elp[1][i] = 0; /* polynomial form */\n+ }\n+ l[0] = 0;\n+ l[1] = 0;\n+ u_lu[0] = -1;\n+ u_lu[1] = 0;\n+\n+ int q, u = 0;\n+ do\n+ {\n+ u++;\n+ if (discrepancy[u] == -1)\n+ {\n+ l[u + 1] = l[u];\n+ for (i = 0; i <= l[u]; i++)\n+ {\n+ elp[u + 1][i] = elp[u][i];\n+ elp[u][i] = index_of[elp[u][i]];\n+ }\n+ }\n+ else\n+ /*\n+ * search for words with greatest u_lu[q] for\n+ * which d[q]!=0\n+ */\n+ {\n+ q = u - 1;\n+ while ((discrepancy[q] == -1) && (q > 0))\n+ q--;\n+ /* have found first non-zero d[q] */\n+ if (q > 0)\n+ {\n+ j = q;\n+ do\n+ {\n+ j--;\n+ if ((discrepancy[j] != -1) && (u_lu[q] < u_lu[j]))\n+ q = j;\n+ }\n+ while (j > 0);\n+ }\n+\n+ /*\n+ * have now found q such that d[u]!=0 and\n+ * u_lu[q] is maximum\n+ */\n+ /* store degree of new elp polynomial */\n+ if (l[u] > l[q] + u - q)\n+ l[u + 1] = l[u];\n+ else\n+ l[u + 1] = l[q] + u - q;\n+\n+ /* form new elp(x) */\n+ for (i = 0; i < t2; i++)\n+ elp[u + 1][i] = 0;\n+ for (i = 0; i <= l[q]; i++)\n+ if (elp[q][i] != -1)\n+ elp[u + 1][i + u - q] =\n+ alpha_to[(discrepancy[u] + this->N - discrepancy[q] + elp[q][i]) % this->N];\n+ for (i = 0; i <= l[u]; i++)\n+ {\n+ elp[u + 1][i] ^= elp[u][i];\n+ elp[u][i] = index_of[elp[u][i]];\n+ }\n+ }\n+ u_lu[u + 1] = u - l[u + 1];\n+\n+ /* form (u+1)th discrepancy */\n+ if (u < t2)\n+ {\n+ /* no discrepancy computed on last iteration */\n+ if (s[u + 1] != -1)\n+ discrepancy[u + 1] = alpha_to[s[u + 1]];\n+ else\n+ discrepancy[u + 1] = 0;\n+ for (i = 1; i <= l[u + 1]; i++)\n+ if ((s[u + 1 - i] != -1) && (elp[u + 1][i] != 0))\n+ discrepancy[u + 1] ^= alpha_to[(s[u + 1 - i] + index_of[elp[u + 1][i]]) % this->N];\n+ /* put d[u+1] into index form */\n+ discrepancy[u + 1] = index_of[discrepancy[u + 1]];\n+ }\n+ }\n+ while ((u < t2) && (l[u + 1] <= this->t));\n+\n+ u++;\n+ if (l[u] <= this->t)\n+ {/* Can correct errors */\n+ /* put elp into index form */\n+ for (i = 0; i <= l[u]; i++)\n+ elp[u][i] = index_of[elp[u][i]];\n+\n+ /* Chien search: find roots of the error location polynomial */\n+ for (i = 1; i <= l[u]; i++)\n+ reg[i] = elp[u][i];\n+ int count = 0;\n+ for (i = 1; i <= this->N; i++)\n+ {\n+ q = 1;\n+ for (j = 1; j <= l[u]; j++)\n+ if (reg[j] != -1)\n+ {\n+ reg[j] = (reg[j] + j) % this->N;\n+ q ^= alpha_to[reg[j]];\n+ }\n+ if (!q)\n+ { /* store root and error\n+ * location number indices */\n+ loc[count] = this->N - i;\n+ count++;\n+ }\n+ }\n+\n+ if (count == l[u])\n+ /* no. roots = degree of elp hence <= this->t errors */\n+ for (i = 0; i < l[u]; i++)\n+ Y_N[loc[i]] ^= 1;\n+ }\n+ }\n+}\n+\n+// ==================================================================================== explicit template instantiation\n+#include \"Tools/types.h\"\n+#ifdef MULTI_PREC\n+template class aff3ct::module::Decoder_BCH_std<B_8,Q_8>;\n+template class aff3ct::module::Decoder_BCH_std<B_16,Q_16>;\n+template class aff3ct::module::Decoder_BCH_std<B_32,Q_32>;\n+template class aff3ct::module::Decoder_BCH_std<B_64,Q_64>;\n+#else\n+template class aff3ct::module::Decoder_BCH_std<B,Q>;\n+#endif\n+// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Decoder/BCH/Standard/Decoder_BCH_std.hpp",
"diff": "+#ifndef DECODER_BCH_STD\n+#define DECODER_BCH_STD\n+\n+#include <vector>\n+\n+#include \"Tools/Code/BCH/BCH_polynomial_generator.hpp\"\n+\n+#include \"../Decoder_BCH.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+template <typename B = int, typename R = float>\n+class Decoder_BCH_std : public Decoder_BCH<B,R>\n+{\n+protected:\n+ std::vector<std::vector<int>> elp;\n+ std::vector<int> discrepancy;\n+ std::vector<int> l;\n+ std::vector<int> u_lu;\n+ std::vector<int> s;\n+ std::vector<int> loc;\n+ std::vector<int> reg;\n+\n+ const int m; // order of the Galois Field\n+ const int d; // minimum distance of the code (d=2t+1))\n+\n+ const std::vector<int>& alpha_to; // log table of GF(2**m)\n+ const std::vector<int>& index_of; // antilog table of GF(2**m)\n+\n+private :\n+ const int t2;\n+\n+public:\n+ Decoder_BCH_std(const int& K, const int& N, const tools::BCH_polynomial_generator &GF, const int n_frames = 1);\n+ virtual ~Decoder_BCH_std();\n+\n+protected:\n+ virtual void _decode(B *Y_N, const int frame_id);\n+};\n+}\n+}\n+\n+#endif /* DECODER_BCH_STD */\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Refacto the BCH decoders
Move the original BCH decoder into a sub type Standard; Create then a BCH decoder mother class.
Create a BCH decoder genius fast: MIPP optimized.
Modify consequently the BCH codec and the factory decoder BCH
|
8,483 |
16.03.2018 18:15:04
| -3,600 |
beb72e60e7864403280d64cbdccfa3316f2cdcef
|
Keep only the BCH decoder genius fast
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Decoder/BCH/Decoder_BCH.cpp",
"new_path": "src/Factory/Module/Decoder/BCH/Decoder_BCH.cpp",
"diff": "#include \"Module/Decoder/BCH/Standard/Decoder_BCH_std.hpp\"\n#include \"Module/Decoder/BCH/Genius/Decoder_BCH_genius.hpp\"\n-#include \"Module/Decoder/BCH/Genius/Decoder_BCH_genius_fast.hpp\"\n#include \"Tools/Exception/exception.hpp\"\n@@ -45,8 +44,8 @@ void Decoder_BCH::parameters\ntools::Integer(tools::Positive(), tools::Non_zero()),\n\"correction power of the BCH code.\");\n- tools::add_options(args.at({p+\"-type\", \"D\"}), 0, \"ALGEBRAIC\", \"GENIUS\");\n- tools::add_options(args.at({p+\"-implem\" }), 0, \"FAST\");\n+ tools::add_options(args.at({p+\"-type\", \"D\"}), 0, \"ALGEBRAIC\");\n+ tools::add_options(args.at({p+\"-implem\" }), 0, \"GENIUS\");\n}\nvoid Decoder_BCH::parameters\n@@ -114,15 +113,14 @@ module::Decoder_SIHO_HIHO<B,Q>* Decoder_BCH::parameters\nif (this->type == \"ALGEBRAIC\")\n{\nif (this->implem == \"STD\") return new module::Decoder_BCH_std<B,Q>(this->K, this->N_cw, GF, this->n_frames);\n- }\nif (encoder)\n{\n- if (this->type == \"GENIUS\")\n- if (this->implem == \"STD\" ) return new module::Decoder_BCH_genius <B,Q>(this->K, this->N_cw, this->t, *encoder, this->n_frames);\n- if (this->implem == \"FAST\") return new module::Decoder_BCH_genius_fast<B,Q>(this->K, this->N_cw, this->t, *encoder, this->n_frames);\n+ if (this->implem == \"GENIUS\") return new module::Decoder_BCH_genius<B,Q>(this->K, this->N_cw, this->t, *encoder, this->n_frames);\n+ }\n}\n+\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/BCH/Codec_BCH.cpp",
"new_path": "src/Module/Codec/BCH/Codec_BCH.cpp",
"diff": "@@ -65,7 +65,7 @@ Codec_BCH<B,Q>\nencoder = factory::Encoder::build<B>(enc_params);\n}\n- if (dec_params.type == \"GENIUS\")\n+ if (dec_params.implem == \"GENIUS\")\nencoder->set_memorizing(true);\nthis->set_encoder(encoder);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/BCH/Genius/Decoder_BCH_genius.cpp",
"new_path": "src/Module/Decoder/BCH/Genius/Decoder_BCH_genius.cpp",
"diff": "@@ -14,8 +14,7 @@ Decoder_BCH_genius<B, R>\n::Decoder_BCH_genius(const int K, const int N, const int t, Encoder<B> &encoder, const int n_frames)\n: Decoder (K, N, n_frames, 1),\nDecoder_BCH<B,R>(K, N, t, n_frames),\n- encoder(encoder),\n- error_pos(this->t + 1)\n+ encoder(encoder)\n{\nconst std::string name = \"Decoder_BCH_genius\";\nthis->set_name(name);\n@@ -38,26 +37,53 @@ template <typename B, typename R>\nvoid Decoder_BCH_genius<B, R>\n::_decode(B *Y_N, const int frame_id)\n{\n- auto& X_N = encoder.get_X_N(frame_id);\n+ throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n+}\n- int n_error = 0;\n- for(int i = 0; i < this->N; i++)\n- {\n- if (X_N[i] != Y_N[i])\n+template <typename B, typename R>\n+void Decoder_BCH_genius<B, R>\n+::_decode_hiho(const B *Y_N, B *V_K, const int frame_id)\n{\n- error_pos[n_error] = i;\n- n_error ++;\n+ auto& X_N = encoder.get_X_N(frame_id);\n+\n+ int n_error = tools::hamming_distance(X_N.data(), Y_N, this->N);\n+\n+ if (n_error <= this->t) // then copy X_N from the encoder that is Y_N corrected\n+ std::copy(X_N.data() + this->N - this->K, X_N.data() + this->N, V_K);\n+ else // then copy Y_N uncorrected\n+ std::copy(Y_N + this->N - this->K, Y_N + this->N, V_K);\n}\n- if (n_error > this->t)\n- break;\n+template <typename B, typename R>\n+void Decoder_BCH_genius<B, R>\n+::_decode_hiho_cw(const B *Y_N, B *V_N, const int frame_id)\n+{\n+ auto& X_N = encoder.get_X_N(frame_id);\n+\n+ int n_error = tools::hamming_distance(X_N.data(), Y_N, this->N);\n+\n+ if (n_error <= this->t) // then copy X_N from the encoder that is Y_N corrected\n+ std::copy(X_N.data(), X_N.data() + this->N, V_N);\n+ else // then copy Y_N uncorrected\n+ std::copy(Y_N, Y_N + this->N, V_N);\n}\n- if (n_error <= this->t)\n+template <typename B, typename R>\n+void Decoder_BCH_genius<B, R>\n+::_decode_siho(const R *Y_N, B *V_K, const int frame_id)\n{\n- for(int i = 0; i < n_error; i++)\n- Y_N[error_pos[i]] = !Y_N[error_pos[i]];\n+ tools::hard_decide(Y_N, this->YH_N.data(), this->N);\n+\n+ this->_decode_hiho(this->YH_N.data(), V_K, frame_id);\n}\n+\n+template <typename B, typename R>\n+void Decoder_BCH_genius<B, R>\n+::_decode_siho_cw(const R *Y_N, B *V_N, const int frame_id)\n+{\n+ tools::hard_decide(Y_N, this->YH_N.data(), this->N);\n+\n+ this->_decode_hiho_cw(this->YH_N.data(), V_N, frame_id);\n}\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Decoder/BCH/Genius/Decoder_BCH_genius.hpp",
"new_path": "src/Module/Decoder/BCH/Genius/Decoder_BCH_genius.hpp",
"diff": "@@ -16,14 +16,16 @@ class Decoder_BCH_genius : public Decoder_BCH<B,R>\nprotected:\nEncoder<B> &encoder;\n- std::vector<unsigned> error_pos;\n-\npublic:\nDecoder_BCH_genius(const int K, const int N, const int t, Encoder<B> &encoder, const int n_frames = 1);\nvirtual ~Decoder_BCH_genius();\nprotected:\nvirtual void _decode ( B *Y_N, const int frame_id);\n+ virtual void _decode_hiho (const B *Y_N, B *V_K, const int frame_id);\n+ virtual void _decode_hiho_cw(const B *Y_N, B *V_N, const int frame_id);\n+ virtual void _decode_siho (const R *Y_N, B *V_K, const int frame_id);\n+ virtual void _decode_siho_cw(const R *Y_N, B *V_N, const int frame_id);\n};\n}\n}\n"
},
{
"change_type": "DELETE",
"old_path": "src/Module/Decoder/BCH/Genius/Decoder_BCH_genius_fast.cpp",
"new_path": null,
"diff": "-#include <chrono>\n-#include <sstream>\n-\n-#include \"Tools/Perf/common.h\"\n-#include \"Tools/Exception/exception.hpp\"\n-\n-#include \"Decoder_BCH_genius_fast.hpp\"\n-\n-using namespace aff3ct;\n-using namespace aff3ct::module;\n-\n-template <typename B, typename R>\n-Decoder_BCH_genius_fast<B, R>\n-::Decoder_BCH_genius_fast(const int K, const int N, const int t, Encoder<B> &encoder, const int n_frames)\n-: Decoder (K, N, n_frames, 1),\n- Decoder_BCH<B,R>(K, N, t, n_frames),\n- encoder(encoder)\n-{\n- const std::string name = \"Decoder_BCH_genius_fast\";\n- this->set_name(name);\n-\n- if (!encoder.is_memorizing())\n- {\n- std::stringstream message;\n- message << \"The given 'encoder' has to be memorizing its generated code words.\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-}\n-\n-template <typename B, typename R>\n-Decoder_BCH_genius_fast<B, R>\n-::~Decoder_BCH_genius_fast()\n-{\n-}\n-\n-template <typename B, typename R>\n-void Decoder_BCH_genius_fast<B, R>\n-::_decode(B *Y_N, const int frame_id)\n-{\n- throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n-}\n-\n-template <typename B, typename R>\n-void Decoder_BCH_genius_fast<B, R>\n-::_decode_hiho(const B *Y_N, B *V_K, const int frame_id)\n-{\n- auto& X_N = encoder.get_X_N(frame_id);\n-\n- int n_error = tools::hamming_distance(X_N.data(), Y_N, this->N);\n-\n- if (n_error <= this->t) // then copy X_N from the encoder that is Y_N corrected\n- std::copy(X_N.data() + this->N - this->K, X_N.data() + this->N, V_K);\n- else // then copy Y_N uncorrected\n- std::copy(Y_N + this->N - this->K, Y_N + this->N, V_K);\n-}\n-\n-template <typename B, typename R>\n-void Decoder_BCH_genius_fast<B, R>\n-::_decode_hiho_cw(const B *Y_N, B *V_N, const int frame_id)\n-{\n- auto& X_N = encoder.get_X_N(frame_id);\n-\n- int n_error = tools::hamming_distance(X_N.data(), Y_N, this->N);\n-\n- if (n_error <= this->t) // then copy X_N from the encoder that is Y_N corrected\n- std::copy(X_N.data(), X_N.data() + this->N, V_N);\n- else // then copy Y_N uncorrected\n- std::copy(Y_N, Y_N + this->N, V_N);\n-}\n-\n-template <typename B, typename R>\n-void Decoder_BCH_genius_fast<B, R>\n-::_decode_siho(const R *Y_N, B *V_K, const int frame_id)\n-{\n- tools::hard_decide(Y_N, this->YH_N.data(), this->N);\n-\n- this->_decode_hiho(this->YH_N.data(), V_K, frame_id);\n-}\n-\n-template <typename B, typename R>\n-void Decoder_BCH_genius_fast<B, R>\n-::_decode_siho_cw(const R *Y_N, B *V_N, const int frame_id)\n-{\n- tools::hard_decide(Y_N, this->YH_N.data(), this->N);\n-\n- this->_decode_hiho_cw(this->YH_N.data(), V_N, frame_id);\n-}\n-\n-// ==================================================================================== explicit template instantiation\n-#include \"Tools/types.h\"\n-#ifdef MULTI_PREC\n-template class aff3ct::module::Decoder_BCH_genius_fast<B_8,Q_8>;\n-template class aff3ct::module::Decoder_BCH_genius_fast<B_16,Q_16>;\n-template class aff3ct::module::Decoder_BCH_genius_fast<B_32,Q_32>;\n-template class aff3ct::module::Decoder_BCH_genius_fast<B_64,Q_64>;\n-#else\n-template class aff3ct::module::Decoder_BCH_genius_fast<B,Q>;\n-#endif\n-// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "DELETE",
"old_path": "src/Module/Decoder/BCH/Genius/Decoder_BCH_genius_fast.hpp",
"new_path": null,
"diff": "-#ifndef DECODER_BCH_GENIUS_FAST\n-#define DECODER_BCH_GENIUS_FAST\n-\n-#include <vector>\n-\n-#include \"Module/Encoder/Encoder.hpp\"\n-#include \"../Decoder_BCH.hpp\"\n-\n-namespace aff3ct\n-{\n-namespace module\n-{\n-template <typename B = int, typename R = float>\n-class Decoder_BCH_genius_fast : public Decoder_BCH<B,R>\n-{\n-protected:\n- Encoder<B> &encoder;\n-\n-public:\n- Decoder_BCH_genius_fast(const int K, const int N, const int t, Encoder<B> &encoder, const int n_frames = 1);\n- virtual ~Decoder_BCH_genius_fast();\n-\n-protected:\n- virtual void _decode ( B *Y_N, const int frame_id);\n- virtual void _decode_hiho (const B *Y_N, B *V_K, const int frame_id);\n- virtual void _decode_hiho_cw(const B *Y_N, B *V_N, const int frame_id);\n- virtual void _decode_siho (const R *Y_N, B *V_K, const int frame_id);\n- virtual void _decode_siho_cw(const R *Y_N, B *V_N, const int frame_id);\n-};\n-}\n-}\n-\n-#endif /* DECODER_BCH_GENIUS_FAST */\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Keep only the BCH decoder genius fast
|
8,483 |
19.03.2018 12:31:59
| -3,600 |
17be4c91b69b2dbe328279511b7e4213b6251043
|
Remove unused files encoder vch adaptative
|
[
{
"change_type": "DELETE",
"old_path": "src/Module/Encoder/BCH/Adaptative/Encoder_BCH_adaptative.cpp",
"new_path": null,
"diff": "-#include <vector>\n-#include <cmath>\n-#include <iostream>\n-#include <cmath>\n-\n-#include \"Encoder_BCH_adaptative.hpp\"\n-\n-using namespace aff3ct;\n-using namespace aff3ct::module;\n-\n-template <typename B>\n-Encoder_BCH_adaptative<B>\n-::Encoder_BCH_adaptative(const int& K, const int& N, const tools::BCH_polynomial_generator& GF_poly, const int n_frames)\n- : Encoder_BCH<B>(K, N, GF_poly, n_frames), K_adap(K), N_adap(N)\n-{\n- const std::string name = \"Encoder_BCH_adaptative\";\n- this->set_name(name);\n-\n-}\n-\n-template <typename B>\n-Encoder_BCH_adaptative<B>\n-::~Encoder_BCH_adaptative()\n-{\n-}\n-\n-template <typename B>\n-void Encoder_BCH_adaptative<B>\n-::__encode(const B *U_K, B *bb)\n-{\n-}\n-\n-template <typename B>\n-void Encoder_BCH_adaptative<B>\n-::_encode(const B *U_K, B *X_N, const int frame_id)\n-{\n- // generate the parity bits\n- this->__encode(U_K, X_N);\n-\n- // copy the sys bits at the end of the codeword\n- std::copy(U_K, U_K + this->K, X_N + this->N - this->K);\n-}\n-\n-// ==================================================================================== explicit template instantiation\n-#include \"Tools/types.h\"\n-#ifdef MULTI_PREC\n-template class aff3ct::module::Encoder_BCH_adaptative<B_8>;\n-template class aff3ct::module::Encoder_BCH_adaptative<B_16>;\n-template class aff3ct::module::Encoder_BCH_adaptative<B_32>;\n-template class aff3ct::module::Encoder_BCH_adaptative<B_64>;\n-#else\n-template class aff3ct::module::Encoder_BCH_adaptative<B>;\n-#endif\n-// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "DELETE",
"old_path": "src/Module/Encoder/BCH/Adaptative/Encoder_BCH_adaptative.hpp",
"new_path": null,
"diff": "-#ifndef ENCODER_BCH_ADAPTATIVE_HPP_\n-#define ENCODER_BCH_ADAPTATIVE_HPP_\n-\n-#include <vector>\n-\n-#include \"../Encoder_BCH.hpp\"\n-#include \"Tools/Code/BCH/BCH_polynomial_generator.hpp\"\n-\n-namespace aff3ct\n-{\n-namespace module\n-{\n-template <typename B = int>\n-class Encoder_BCH_adaptative : public Encoder_BCH<B>\n-{\n-protected:\n- const int K_adap;\n- const int N_adap;\n-\n-public:\n- Encoder_BCH_adaptative(const int& K, const int& N, const tools::BCH_polynomial_generator& GF, const int n_frames = 1);\n-\n- virtual ~Encoder_BCH_adaptative();\n-\n-protected:\n- virtual void _encode(const B *U_K, B *X_N, const int frame_id);\n- virtual void __encode(const B *U_K, B *bb);\n-};\n-}\n-}\n-\n-#endif // ENCODER_BCH_ADAPTATIVE_HPP_\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Remove unused files encoder vch adaptative
|
8,483 |
19.03.2018 12:36:29
| -3,600 |
6b5c9dae74baefd46ad3d583ed9de42d3ab28bda
|
Create common.cpp file; Add robust specialization of hamming_distance function; Use it in Monitor_BFER.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"diff": "#include <stdexcept>\n#include \"Monitor_BFER.hpp\"\n+#include \"Tools/Perf/common.h\"\nusing namespace aff3ct::module;\n@@ -48,9 +49,7 @@ template <typename B>\nint Monitor_BFER<B>\n::_check_errors(const B *U, const B *V, const int frame_id)\n{\n- auto bit_errors_count = 0;\n- for (auto b = 0; b < this->size; b++)\n- bit_errors_count += !U[b] != !V[b];\n+ int bit_errors_count = tools::hamming_distance(U, V, this->size);\nif (bit_errors_count)\n{\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Perf/common.cpp",
"diff": "+#include <limits>\n+\n+#include \"common.h\"\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+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+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+\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+// ==================================================================================== 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": "MODIFY",
"old_path": "src/Tools/Perf/common.h",
"new_path": "src/Tools/Perf/common.h",
"diff": "@@ -7,58 +7,14 @@ namespace aff3ct\n{\nnamespace tools\n{\n-template <typename B = int, typename R = float>\n-inline void hard_decide(const R *in, B *out, const int size)\n-{\n- const auto vec_loop_size = (size / mipp::nElReg<R>()) * mipp::nElReg<R>();\n- if (mipp::isAligned(in) && mipp::isAligned(out))\n- {\n- for (auto i = 0; i < vec_loop_size; i += mipp::nElReg<R>())\n- {\n- const auto r_in = mipp::Reg<R>(&in[i]);\n- const auto r_out = mipp::cast<R,B>(r_in) >> (sizeof(B) * 8 - 1);\n- r_out.store(&out[i]);\n- }\n- }\n- else\n- {\n- for (auto i = 0; i < vec_loop_size; i += mipp::nElReg<R>())\n- {\n- mipp::Reg<R> r_in;\n- r_in.loadu(&in[i]);\n- const auto r_out = mipp::cast<R,B>(r_in) >> (sizeof(B) * 8 - 1);\n- r_out.storeu(&out[i]);\n- }\n- }\n- for (auto i = vec_loop_size; i < size; i++)\n- out[i] = in[i] < 0;\n-}\n+template <typename B = int, typename Q = float>\n+void hard_decide(const Q *in, B *out, const int size);\n-template <typename B = int>\n-inline size_t hamming_distance(const B *in1, const B *in2, const int size)\n-{\n- const mipp::Reg<B> zeros = (B)0, ones = (B)1;\n- mipp::Reg<B> counter = (B)0;\n-\n- const auto vec_loop_size = (size / mipp::nElReg<B>()) * mipp::nElReg<B>();\n-\n- for (auto i = 0; i < vec_loop_size; i += mipp::nElReg<B>())\n- {\n- const auto r_in1 = mipp::Reg<B>(&in1[i]);\n- const auto r_in2 = mipp::Reg<B>(&in2[i]);\n- const auto m_in1 = r_in1 != zeros;\n- const auto m_in2 = r_in2 != zeros;\n- counter += mipp::blend(ones, zeros, m_in1 ^ m_in2);\n- }\n-\n- size_t ham_dist = mipp::hadd(counter);\n-\n- for (auto i = vec_loop_size; i < size; i++)\n- ham_dist += (!in1[i] != !in2[i])? 1 : 0;\n-\n- return ham_dist;\n-}\n+template <typename B = int32_t>\n+size_t hamming_distance_seq(const B *in1, const B *in2, const int size);\n+template <typename B = int32_t>\n+size_t hamming_distance(const B *in1, const B *in2, const int size);\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Create common.cpp file; Add robust specialization of hamming_distance function; Use it in Monitor_BFER.
|
8,483 |
20.03.2018 18:17:54
| -3,600 |
e5d533548f90bccf21156770044356c799f62454
|
Add comments in common.h; Fix common.cpp to make it work with AVX1 in sequential mode
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Perf/common.cpp",
"new_path": "src/Tools/Perf/common.cpp",
"diff": "#include \"common.h\"\n+//********************************************************************************************************** hard_decide\n+\ntemplate <typename B, typename Q>\nvoid aff3ct::tools::hard_decide(const Q *in, B *out, const int size)\n{\n@@ -31,6 +33,8 @@ void aff3ct::tools::hard_decide(const Q *in, B *out, const int size)\n+//************************************************************************************************* hamming_distance_seq\n+\ntemplate <typename B>\ninline size_t aff3ct::tools::hamming_distance_seq(const B *in1, const B *in2, const int size)\n{\n@@ -42,6 +46,20 @@ inline size_t aff3ct::tools::hamming_distance_seq(const B *in1, const B *in2, co\nreturn ham_dist;\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+\ntemplate <typename B>\ninline mipp::Reg<B> popcnt(const mipp::Reg<B>& q_in1, const mipp::Reg<B>& q_in2)\n{\n@@ -51,7 +69,6 @@ inline mipp::Reg<B> popcnt(const mipp::Reg<B>& q_in1, const mipp::Reg<B>& q_in2)\nreturn mipp::blend(ones, zeros, m_in1 ^ m_in2);\n}\n-\ntemplate <typename B>\nsize_t aff3ct::tools::hamming_distance(const B *in1, const B *in2, const int size)\n{\n@@ -142,6 +159,8 @@ size_t hamming_distance<int8_t>(const int8_t *in1, const int8_t *in2, const int\n}\n}\n+#endif // #ifdef MIPP_AVX\n+\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Perf/common.h",
"new_path": "src/Tools/Perf/common.h",
"diff": "@@ -7,12 +7,22 @@ namespace aff3ct\n{\nnamespace tools\n{\n+/*\n+ * take the hard decision on the array 'in' and fill 'out', both of length 'size'\n+ */\ntemplate <typename B = int, typename Q = float>\nvoid hard_decide(const Q *in, B *out, const int size);\n+/*\n+ * compute the Hamming distance between the arrays 'in1' and 'in2' of length 'size'\n+ */\ntemplate <typename B = int32_t>\nsize_t hamming_distance_seq(const B *in1, const B *in2, const int size);\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+ */\ntemplate <typename B = int32_t>\nsize_t hamming_distance(const B *in1, const B *in2, const int size);\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add comments in common.h; Fix common.cpp to make it work with AVX1 in sequential mode
|
8,483 |
20.03.2018 18:33:44
| -3,600 |
f24baa55292da67fbdfec50f7191d75a060b61cc
|
Fix the pyber repo path. Thanks to codechecker123 for this correction
|
[
{
"change_type": "MODIFY",
"old_path": "doc/pages/PyBER.md",
"new_path": "doc/pages/PyBER.md",
"diff": "@@ -14,7 +14,7 @@ Next, install the required dependencies to run **PyBER**:\n## Run PyBER\n-From the `plotter/PyBER/` directory:\n+From the https://github.com/aff3ct/PyBER repo root directory:\n$ python3 pyBER.py\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix the pyber repo path. Thanks to codechecker123 for this correction
|
8,483 |
21.03.2018 10:48:47
| -3,600 |
d08dbe91452e124574f2cd28894ec77680713d58
|
Use the already defined names to select the good Codec
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Codec/Codec_HIHO.cpp",
"new_path": "src/Factory/Module/Codec/Codec_HIHO.cpp",
"diff": "@@ -29,7 +29,7 @@ template <typename B, typename Q>\nmodule::Codec_HIHO<B,Q>* Codec_HIHO::parameters\n::build(module::CRC<B>* crc) const\n{\n- if (get_name() == \"Codec BCH\" ) return dynamic_cast<const Codec_BCH ::parameters&>(*this).template build<B,Q>(crc);\n+ if (get_name() == Codec_BCH_name) return dynamic_cast<const Codec_BCH ::parameters&>(*this).template build<B,Q>(crc);\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Codec/Codec_SIHO.cpp",
"new_path": "src/Factory/Module/Codec/Codec_SIHO.cpp",
"diff": "@@ -38,16 +38,16 @@ template <typename B, typename Q>\nmodule::Codec_SIHO<B,Q>* Codec_SIHO::parameters\n::build(module::CRC<B>* crc) const\n{\n- if (get_name() == \"Codec BCH\" ) return dynamic_cast<const Codec_BCH ::parameters&>(*this).template build<B,Q>(crc);\n- else if (get_name() == \"Codec LDPC\" ) return dynamic_cast<const Codec_LDPC ::parameters&>(*this).template build<B,Q>(crc);\n- else if (get_name() == \"Codec Polar\" ) return dynamic_cast<const Codec_polar ::parameters&>(*this).template build<B,Q>(crc);\n- else if (get_name() == \"Codec RA\" ) return dynamic_cast<const Codec_RA ::parameters&>(*this).template build<B,Q>(crc);\n- else if (get_name() == \"Codec Repetition\") return dynamic_cast<const Codec_repetition::parameters&>(*this).template build<B,Q>(crc);\n- else if (get_name() == \"Codec RSC\" ) return dynamic_cast<const Codec_RSC ::parameters&>(*this).template build<B,Q>(crc);\n- else if (get_name() == \"Codec RSC DB\" ) return dynamic_cast<const Codec_RSC_DB ::parameters&>(*this).template build<B,Q>(crc);\n- else if (get_name() == \"Codec Turbo\" ) return dynamic_cast<const Codec_turbo ::parameters&>(*this).template build<B,Q>(crc);\n- else if (get_name() == \"Codec Turbo DB\" ) return dynamic_cast<const Codec_turbo_DB ::parameters&>(*this).template build<B,Q>(crc);\n- else if (get_name() == \"Codec Uncoded\" ) return dynamic_cast<const Codec_uncoded ::parameters&>(*this).template build<B,Q>(crc);\n+ if (get_name() == Codec_BCH_name ) return dynamic_cast<const Codec_BCH ::parameters&>(*this).template build<B,Q>(crc);\n+ else if (get_name() == Codec_LDPC_name ) return dynamic_cast<const Codec_LDPC ::parameters&>(*this).template build<B,Q>(crc);\n+ else if (get_name() == Codec_polar_name ) return dynamic_cast<const Codec_polar ::parameters&>(*this).template build<B,Q>(crc);\n+ else if (get_name() == Codec_RA_name ) return dynamic_cast<const Codec_RA ::parameters&>(*this).template build<B,Q>(crc);\n+ else if (get_name() == Codec_repetition_name) return dynamic_cast<const Codec_repetition::parameters&>(*this).template build<B,Q>(crc);\n+ else if (get_name() == Codec_RSC_name ) return dynamic_cast<const Codec_RSC ::parameters&>(*this).template build<B,Q>(crc);\n+ else if (get_name() == Codec_RSC_DB_name ) return dynamic_cast<const Codec_RSC_DB ::parameters&>(*this).template build<B,Q>(crc);\n+ else if (get_name() == Codec_turbo_name ) return dynamic_cast<const Codec_turbo ::parameters&>(*this).template build<B,Q>(crc);\n+ else if (get_name() == Codec_turbo_DB_name ) return dynamic_cast<const Codec_turbo_DB ::parameters&>(*this).template build<B,Q>(crc);\n+ else if (get_name() == Codec_uncoded_name ) return dynamic_cast<const Codec_uncoded ::parameters&>(*this).template build<B,Q>(crc);\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Codec/Codec_SIHO_HIHO.cpp",
"new_path": "src/Factory/Module/Codec/Codec_SIHO_HIHO.cpp",
"diff": "@@ -31,7 +31,7 @@ template <typename B, typename Q>\nmodule::Codec_SIHO_HIHO<B,Q>* Codec_SIHO_HIHO::parameters\n::build(module::CRC<B>* crc) const\n{\n- if (get_name() == \"Codec BCH\" ) return dynamic_cast<const Codec_BCH ::parameters&>(*this).template build<B,Q>(crc);\n+ if (get_name() == Codec_BCH_name) return dynamic_cast<const Codec_BCH ::parameters&>(*this).template build<B,Q>(crc);\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Codec/Codec_SISO.cpp",
"new_path": "src/Factory/Module/Codec/Codec_SISO.cpp",
"diff": "@@ -33,11 +33,11 @@ template <typename B, typename Q>\nmodule::Codec_SISO<B,Q>* Codec_SISO::parameters\n::build(module::CRC<B>* crc) const\n{\n- if (get_name() == \"Codec LDPC\" ) return dynamic_cast<const Codec_LDPC ::parameters&>(*this).template build<B,Q>(crc);\n- else if (get_name() == \"Codec Polar\" ) return dynamic_cast<const Codec_polar ::parameters&>(*this).template build<B,Q>(crc);\n- else if (get_name() == \"Codec RSC\" ) return dynamic_cast<const Codec_RSC ::parameters&>(*this).template build<B,Q>(crc);\n- else if (get_name() == \"Codec RSC DB\" ) return dynamic_cast<const Codec_RSC_DB ::parameters&>(*this).template build<B,Q>(crc);\n- else if (get_name() == \"Codec Uncoded\") return dynamic_cast<const Codec_uncoded::parameters&>(*this).template build<B,Q>(crc);\n+ if (get_name() == Codec_LDPC_name ) return dynamic_cast<const Codec_LDPC ::parameters&>(*this).template build<B,Q>(crc);\n+ else if (get_name() == Codec_polar_name ) return dynamic_cast<const Codec_polar ::parameters&>(*this).template build<B,Q>(crc);\n+ else if (get_name() == Codec_RSC_name ) return dynamic_cast<const Codec_RSC ::parameters&>(*this).template build<B,Q>(crc);\n+ else if (get_name() == Codec_RSC_DB_name ) return dynamic_cast<const Codec_RSC_DB ::parameters&>(*this).template build<B,Q>(crc);\n+ else if (get_name() == Codec_uncoded_name) return dynamic_cast<const Codec_uncoded::parameters&>(*this).template build<B,Q>(crc);\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Codec/Codec_SISO_SIHO.cpp",
"new_path": "src/Factory/Module/Codec/Codec_SISO_SIHO.cpp",
"diff": "@@ -35,11 +35,11 @@ template <typename B, typename Q>\nmodule::Codec_SISO_SIHO<B,Q>* Codec_SISO_SIHO::parameters\n::build(module::CRC<B>* crc) const\n{\n- if (get_name() == \"Codec LDPC\" ) return dynamic_cast<const Codec_LDPC ::parameters&>(*this).template build<B,Q>(crc);\n- else if (get_name() == \"Codec Polar\" ) return dynamic_cast<const Codec_polar ::parameters&>(*this).template build<B,Q>(crc);\n- else if (get_name() == \"Codec RSC\" ) return dynamic_cast<const Codec_RSC ::parameters&>(*this).template build<B,Q>(crc);\n- else if (get_name() == \"Codec RSC DB\" ) return dynamic_cast<const Codec_RSC_DB ::parameters&>(*this).template build<B,Q>(crc);\n- else if (get_name() == \"Codec Uncoded\") return dynamic_cast<const Codec_uncoded::parameters&>(*this).template build<B,Q>(crc);\n+ if (get_name() == Codec_LDPC_name ) return dynamic_cast<const Codec_LDPC ::parameters&>(*this).template build<B,Q>(crc);\n+ else if (get_name() == Codec_polar_name ) return dynamic_cast<const Codec_polar ::parameters&>(*this).template build<B,Q>(crc);\n+ else if (get_name() == Codec_RSC_name ) return dynamic_cast<const Codec_RSC ::parameters&>(*this).template build<B,Q>(crc);\n+ else if (get_name() == Codec_RSC_DB_name ) return dynamic_cast<const Codec_RSC_DB ::parameters&>(*this).template build<B,Q>(crc);\n+ else if (get_name() == Codec_uncoded_name) return dynamic_cast<const Codec_uncoded::parameters&>(*this).template build<B,Q>(crc);\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Use the already defined names to select the good Codec
|
8,483 |
21.03.2018 17:59:23
| -3,600 |
2378dcbc848ccd031461861d88cc18037dc531b6
|
Remove integral wrappers; Add mid left right rectangular and Simpson approximation integral functions
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/CPM/Modem_CPM.hxx",
"new_path": "src/Module/Modem/CPM/Modem_CPM.hxx",
"diff": "@@ -262,7 +262,7 @@ R Modem_CPM<B,R,Q,MAX>\nreturn (R)0.0;\nGMSK<R> g((R)0.3, -(R)cpm.L / (R)2.0);\n- return tools::rect_integral_seq(g, (R)0.0, t_stamp, (int)(t_stamp / (R)1e-4));\n+ return tools::mid_rect_integral_seq(g, (R)0.0, t_stamp, (int)(t_stamp / (R)1e-4));\n}\nelse if (cpm.wave_shape == \"RCOS\")\nreturn t_stamp / ((R)2.0 * cpm.L) - sin((R)2.0 * (R)M_PI * t_stamp / (R)cpm.L) / (R)4.0 / (R)M_PI;\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 <mipp.h>\n-\nnamespace aff3ct\n{\nnamespace tools\n{\n-enum NUM_INTEG_APPROX {RECT, TRAPZ};\n-\n/*\n- * Numerical integration\n- * Computes the numerical integral of the array 'in' of length 'size' via the given 'method' with 'step' spacing\n- * Possible methods are rectangular integration \"RECT\", trapezoidal integration \"TRAPZ\"\n+ * Trapezium numerical integration\n+ * Computes the approximate integral of the array 'y' of length 'size' via the trapezium method with 'step' spacing\n* Operations are optimized with MIPP.\n*/\ntemplate <typename R>\n-inline R integral(const R* in, const R step, const int size, const NUM_INTEG_APPROX approx = NUM_INTEG_APPROX::RECT);\n+inline R trapz_integral(const R* y, const R step, int size);\n+\n+/*\n+ * Trapezium numerical integration\n+ * Computes the approximate integral of the array 'y' of length 'size' via the trapezium method with 'step' spacing\n+ */\n+template <typename R>\n+inline R trapz_integral_seq(const R* y, const R step, int size);\n/*\n- * Numerical integration\n- * Computes the numerical integral of the array 'in' of length 'size' via the given 'method' with 'step' spacing\n- * Possible methods are rectangular integration \"RECT\", trapezoidal integration \"TRAPZ\"\n+ * Trapezium numerical integration\n+ * Computes the approximate integral of the array ('x','y') of length 'size' via the trapezium method\n*/\ntemplate <typename R>\n-inline R integral_seq(const R* in, const R step, const int size, const NUM_INTEG_APPROX approx = NUM_INTEG_APPROX::RECT);\n+inline R trapz_integral_seq(const R* x, const R* y, int size);\n/*\n- * Numerical integration\n- * Computes the numerical integral of the function 'f' from 'min' to 'max' with 'number_steps' steps via the rectangular method\n- * Possible methods are rectangular integration \"RECT\", trapezoidal integration \"TRAPZ\"\n+ * Trapezium numerical integration\n+ * Computes the approximate integral of the function 'f' from 'min' to 'max' with 'number_steps' steps via the trapezium method\n*/\ntemplate <typename R, typename Function>\n-inline R integral_seq(Function f, const R min, const R max, const int number_steps, const NUM_INTEG_APPROX approx = NUM_INTEG_APPROX::RECT);\n+inline R trapz_integral_seq(Function f, const R min, const R max, const int number_steps);\n/*\n- * Trapezoidal numerical integration\n- * Computes the approximate integral of the array 'in' of length 'size' via the trapezoidal method with 'step' spacing\n+ * Rectangular numerical integration\n+ * Computes the approximate integral of the array 'y' of length 'size' via the rectangular method with 'step' spacing\n* Operations are optimized with MIPP.\n*/\ntemplate <typename R>\n-inline R trapz_integral(const R* in, const R step, int size);\n+inline R rect_integral(const R* y, const R step, const int size);\n/*\n- * Trapezoidal numerical integration\n- * Computes the approximate integral of the array 'in' of length 'size' via the trapezoidal method with 'step' spacing\n+ * Rectangular numerical integration\n+ * Computes the approximate integral of the array 'y' of length 'size' via the rectangular method with 'step' spacing\n*/\ntemplate <typename R>\n-inline R trapz_integral_seq(const R* in, const R step, int size);\n+inline R rect_integral_seq(const R* y, const R step, const int size);\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+ * Middle Rectangular numerical integration\n+ * Computes the approximate integral of the function 'f' from 'min' to 'max' with 'number_steps' steps via the middle rectangular method\n+ * the function 'f' must be a \"R(*f)(const R x)\" callable object\n*/\ntemplate <typename R, typename Function>\n-inline R trapz_integral_seq(Function f, const R min, const R max, const int number_steps);\n+inline R mid_rect_integral_seq(Function f, const R min, const R max, const int number_steps);\n/*\n- * Rectangular numerical integration\n- * Computes the approximate integral of the array 'in' of length 'size' via the rectangular method with 'step' spacing\n- * Operations are optimized with MIPP.\n+ * Left Rectangular numerical integration\n+ * Computes the approximate integral of the function 'f' from 'min' to 'max' with 'number_steps' steps via the left rectangular method\n+ * the function 'f' must be a \"R(*f)(const R x)\" callable object\n+ */\n+template <typename R, typename Function>\n+inline R left_rect_integral_seq(Function f, const R min, const R max, const int number_steps);\n+\n+/*\n+ * Right Rectangular numerical integration\n+ * Computes the approximate integral of the function 'f' from 'min' to 'max' with 'number_steps' steps via the right rectangular method\n+ * the function 'f' must be a \"R(*f)(const R x)\" callable object\n+ */\n+template <typename R, typename Function>\n+inline R right_rect_integral_seq(Function f, const R min, const R max, const int number_steps);\n+\n+/*\n+ * Middle Rectangular numerical integration\n+ * Computes the approximate integral of the array ('x','y') of length 'size' via the middle rectangular method\n*/\ntemplate <typename R>\n-inline R rect_integral(const R* in, const R step, const int size);\n+inline R mid_rect_integral_seq(const R* x, const R* y, int size);\n/*\n- * Rectangular numerical integration\n- * Computes the approximate integral of the array 'in' of length 'size' via the rectangular method with 'step' spacing\n+ * Left Rectangular numerical integration\n+ * Computes the approximate integral of the array ('x','y') of length 'size' via the left rectangular method\n*/\ntemplate <typename R>\n-inline R rect_integral_seq(const R* in, const R step, const int size);\n+inline R left_rect_integral_seq(const R* x, const R* y, int size);\n/*\n- * Rectangular numerical integration\n- * Computes the approximate integral of the function 'f' from 'min' to 'max' with 'number_steps' steps via the rectangular method\n- * the function 'f' must be a \"R(*f)(const R x)\" callable object\n+ * Right Rectangular numerical integration\n+ * Computes the approximate integral of the array ('x','y') of length 'size' via the right rectangular method\n+ */\n+template <typename R>\n+inline R right_rect_integral_seq(const R* x, const R* y, int size);\n+\n+/*\n+ * Simpson numerical integration\n+ * Computes the approximate integral of the function 'f' from 'min' to 'max' with 'number_steps' steps via the Simpson method\n*/\ntemplate <typename R, typename Function>\n-inline R rect_integral_seq(Function f, const R min, const R max, const int number_steps);\n+inline R simps_integral_seq(Function f, const R min, const R max, const int number_steps);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/numerical_integration.hxx",
"new_path": "src/Tools/Math/numerical_integration.hxx",
"diff": "#define NUMERICAL_INTEGRATION_HXX_\n#include <sstream>\n+#include <assert.h>\n+#include <mipp.h>\n+#include \"utils.h\"\n#include \"numerical_integration.h\"\n-#include \"Tools/Exception/exception.hpp\"\nnamespace aff3ct\n{\n@@ -12,26 +14,54 @@ namespace tools\n{\ntemplate <typename R>\n-inline R trapz_integral_seq(const R* in, const R step, int size)\n+inline R trapz_integral_seq(const R* y, const R step, int size)\n{\n+ assert(y != 0);\n+ assert(step != 0);\n+ assert(size != 0);\n+\nif (size <= 1)\nreturn (R)0;\n- R area = div2(in[0]);\n+ R area = div2(y[0]);\nsize--;\nfor (auto i = 1; i < size; i++)\n- area += in[i];\n+ area += y[i];\n- area += div2(in[size]);\n+ area += div2(y[size]);\nreturn area * step;\n}\ntemplate <typename R>\n-inline R trapz_integral(const R* in, const R step, int size)\n+inline R trapz_integral_seq(const R* x, const R* y, int size)\n{\n+ assert(x != 0);\n+ assert(y != 0);\n+ assert(size != 0);\n+\n+ if (size <= 1)\n+ return (R)0;\n+\n+ size--;\n+\n+ R area = div2(y[size]);\n+\n+ for (auto i = 0; i < size; i++)\n+ area += div2((y[i+1] + y[i])) * (x[i+1] - x[i]);\n+\n+ return area;\n+}\n+\n+template <typename R>\n+inline R trapz_integral(const R* y, const R step, int size)\n+{\n+ assert(y != 0);\n+ assert(step != 0);\n+ assert(size != 0);\n+\nif (size <= 1)\nreturn (R)0;\n@@ -42,14 +72,14 @@ inline R trapz_integral(const R* in, const R step, int size)\nconst auto vec_loop_size = (size / mipp::N<R>()) * mipp::N<R>();\nfor (auto i = 1; i < vec_loop_size; i += mipp::N<R>())\n- area += mipp::Reg<R>(in+i);\n+ area += mipp::Reg<R>(y+i);\nR a = mipp::hadd(area);\nfor (auto i = vec_loop_size; i < size; i++)\n- a += in[i];\n+ a += y[i];\n- a += div2(in[size] + in[0]);\n+ a += div2(y[size] + y[0]);\nreturn a * step;\n}\n@@ -57,12 +87,15 @@ inline R trapz_integral(const R* in, const R step, int size)\ntemplate <typename R, typename Function>\ninline R trapz_integral_seq(Function f, const R min, const R max, const int number_steps)\n{\n+ assert(number_steps != 0);\n+ assert(max >= min);\n+\nR step = (max - min) / number_steps; // width of rectangle\nR area = (R)0;\nR stop = max - step;\n- for (R i = min + step ; i < stop ; i += step)\n+ for (R i = min + step ; i <= stop ; i += step)\narea += f(i);\narea += div2(f(max) + f(min));\n@@ -71,23 +104,31 @@ inline R trapz_integral_seq(Function f, const R min, const R max, const int numb\n}\ntemplate <typename R>\n-inline R rect_integral_seq(const R* in, const R step, const int size)\n+inline R rect_integral_seq(const R* y, const R step, const int size)\n{\n+ assert(y != 0);\n+ assert(step != 0);\n+ assert(size != 0);\n+\nif (size <= 1)\nreturn (R)0;\nR area = 0;\nfor (auto i = 0; i < size; i++)\n- area += in[i];\n+ area += y[i];\nreturn area * step;\n}\ntemplate <typename R>\n-inline R rect_integral(const R* in, const R step, const int size)\n+inline R rect_integral(const R* y, const R step, const int size)\n{\n+ assert(y != 0);\n+ assert(step != 0);\n+ assert(size != 0);\n+\nif (size <= 1)\nreturn (R)0;\n@@ -96,131 +137,134 @@ inline R rect_integral(const R* in, const R step, const int size)\nconst auto vec_loop_size = (size / mipp::N<R>()) * mipp::N<R>();\nfor (auto i = 0; i < vec_loop_size; i += mipp::N<R>())\n- area += mipp::Reg<R>(in+i);\n+ area += mipp::Reg<R>(y+i);\nR a = mipp::hadd(area);\nfor (auto i = vec_loop_size; i < size; i++)\n- a += in[i];\n+ a += y[i];\nreturn a * step;\n}\ntemplate <typename R, typename Function>\n-inline R rect_integral_seq(Function f, const R min, const R max, const int number_steps)\n+inline R mid_rect_integral_seq(Function f, const R min, const R max, const int number_steps)\n{\n+ assert(number_steps != 0);\n+ assert(max >= min);\n+\nR step = (max - min) / number_steps; // width of rectangle\nR area = (R)0;\n- for (auto i = 0; i < number_steps; i++)\n- area += f(min + ((R)i + (R)0.5) * step);\n+ for (R i = min + step * (R)0.5 ; i < max ; i += step)\n+ area += f(i);\nreturn area * step;\n}\n-template <typename R>\n-inline R integral_seq(const R* in, const R step, const int size, const NUM_INTEG_APPROX approx)\n-{\n- if (step <= 0)\n+template <typename R, typename Function>\n+inline R left_rect_integral_seq(Function f, const R min, const R max, const int number_steps)\n{\n- std::stringstream message;\n- message << \"'step' has to be strictly positive ('step' = \" << step << \").\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n+ assert(number_steps != 0);\n+ assert(max >= min);\n- if (size < 0)\n- {\n+ R step = (max - min) / number_steps; // width of rectangle\n+ R area = (R)0;\n+\n+ for (R i = min ; i < max ; i += step)\n+ area += f(i);\n- std::stringstream message;\n- message << \"'size' has to be positive ('size' = \" << size << \").\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ return area * step;\n}\n- switch (approx)\n+template <typename R, typename Function>\n+inline R right_rect_integral_seq(Function f, const R min, const R max, const int number_steps)\n{\n- case NUM_INTEG_APPROX::RECT :\n- return rect_integral_seq(in, step, size);\n+ assert(number_steps != 0);\n+ assert(max >= min);\n- case NUM_INTEG_APPROX::TRAPZ :\n- return trapz_integral_seq(in, step, size);\n+ R step = (max - min) / number_steps; // width of rectangle\n+ R area = (R)0;\n- default:\n- {\n- std::stringstream message;\n- message << \"Unknown approximation method ('approx' = \" << approx << \").\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n- }\n+ for (R i = min + step ; i <= max ; i += step)\n+ area += f(i);\n+ return area * step;\n}\ntemplate <typename R>\n-inline R integral(const R* in, const R step, const int size, const NUM_INTEG_APPROX approx)\n-{\n- if (step <= 0)\n+inline R mid_rect_integral_seq(const R* x, const R* y, int size)\n{\n- std::stringstream message;\n- message << \"'step' has to be strictly positive ('step' = \" << step << \").\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n+ assert(x != 0);\n+ assert(y != 0);\n+ assert(size != 0);\n- if (size < 0)\n- {\n+ if (size <= 1)\n+ return (R)0;\n- std::stringstream message;\n- message << \"'size' has to be positive ('size' = \" << size << \").\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n+ size--;\n- switch (approx)\n- {\n- case NUM_INTEG_APPROX::RECT :\n- return rect_integral(in, step, size);\n+ R area = 0;\n- case NUM_INTEG_APPROX::TRAPZ :\n- return trapz_integral(in, step, size);\n+ for (auto i = 0; i < size; i++)\n+ area += div2((y[i+1] + y[i])) * (x[i+1] - x[i]);\n- default:\n- {\n- std::stringstream message;\n- message << \"Unknown approximation method ('approx' = \" << approx << \").\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n- }\n+ return area;\n}\n-template <typename R, typename Function>\n-inline R integral_seq(Function f, const R min, const R max, const int number_steps, const NUM_INTEG_APPROX approx)\n-{\n- if (max < min)\n+template <typename R>\n+inline R left_rect_integral_seq(const R* x, const R* y, int size)\n{\n- std::stringstream message;\n- message << \"'max' has to be equal or greater than 'min' ('max' = \" << max << \", 'min' = \" << min << \").\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ assert(x != 0);\n+ assert(y != 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 += y[i] * (x[i+1] - x[i]);\n+\n+ return area;\n}\n- if (number_steps <= 0)\n+template <typename R>\n+inline R right_rect_integral_seq(const R* x, const R* y, int size)\n{\n- std::stringstream message;\n- message << \"'number_steps' has to be greater than 0 ('number_steps' = \" << number_steps << \").\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ assert(x != 0);\n+ assert(y != 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 += y[i+1] * (x[i+1] - x[i]);\n+\n+ return area;\n}\n- switch (approx)\n+template <typename R, typename Function>\n+inline R simps_integral_seq(Function f, const R min, const R max, const int number_steps)\n{\n- case NUM_INTEG_APPROX::RECT :\n- return rect_integral_seq(f, min, max, number_steps);\n+ assert(number_steps != 0);\n+ assert(max >= min);\n+\n+ R step = (max - min) / number_steps; // width of rectangle\n+ R area = (R)0;\n- case NUM_INTEG_APPROX::TRAPZ :\n- return trapz_integral_seq(f, min, max, number_steps);\n+ for (R i = min ; i < max ; i += step)\n+ area += f(i) + 4*f(i+div2(step)) + f(i+step);\n- default:\n- {\n- std::stringstream message;\n- message << \"Unknown approximation method ('approx' = \" << approx << \").\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n- }\n+ return area * step / (R)6;\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Remove integral wrappers; Add mid left right rectangular and Simpson approximation integral functions
|
8,483 |
21.03.2018 18:03:55
| -3,600 |
56732934b471c437721b20ab7f03da0aef2caa63
|
Fix error in trapezium integration X Y
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/numerical_integration.hxx",
"new_path": "src/Tools/Math/numerical_integration.hxx",
"diff": "@@ -47,7 +47,7 @@ inline R trapz_integral_seq(const R* x, const R* y, int size)\nsize--;\n- R area = div2(y[size]);\n+ R area = 0;\nfor (auto i = 0; i < size; i++)\narea += div2((y[i+1] + y[i])) * (x[i+1] - x[i]);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix error in trapezium integration X Y
|
8,483 |
23.03.2018 11:49:45
| -3,600 |
9be9aa901735422ad69dee00e4a7f0a8246ea3ea
|
Add linear interpolation algorithm
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Math/interpolation.h",
"diff": "+#ifndef INTERPOLATION_H_\n+#define INTERPOLATION_H_\n+\n+#include <vector>\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+\n+/*\n+ * Compute the linear interpolation of xVal from the original data yData matching with its abscissa xData.\n+ * xData, of length lData, must be sorted and strictly monotonic increasing\n+ * xData and yData must have the same length\n+ * If xVal goes out of xData 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 T* xData, const T* yData, const int lData, const T xVal);\n+\n+/*\n+ * Compute the linear interpolation of xVals array, of length lVals, from the original data yData matching with its abscissa xData.\n+ * xData, of length lData, must be sorted and strictly monotonic increasing\n+ * Computed interpolation is returned in the filled array yVals of same size than xVals\n+ */\n+template <typename T>\n+void linear_interpolation(const T* xData, const T* yData, const int lData, // xData is sorted and is strictly monotonic increasing\n+ const T* xVals, T* yVals, const int lVals);\n+\n+/*\n+ * Compute the linear interpolation of xVals vector, from the original data yData matching with its abscissa xData.\n+ * xData, of length lData, must be sorted and strictly monotonic increasing\n+ * Computed interpolation is returned in the filled vector yVals of same size than xVals.\n+ */\n+template <typename T>\n+void linear_interpolation(const std::vector<T>& xData, const std::vector<T>& yData, // xData is sorted and is strictly monotonic increasing\n+ const std::vector<T>& xVals, std::vector<T>& yVals);\n+\n+}\n+}\n+\n+#include \"interpolation.hxx\"\n+\n+#endif // INTERPOLATION_H_\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Math/interpolation.hxx",
"diff": "+#ifndef INTERPOLATION_HXX_\n+#define INTERPOLATION_HXX_\n+\n+#include <algorithm>\n+#include <assert.h>\n+#include <mipp.h>\n+\n+#include \"interpolation.h\"\n+\n+#define PRECISION 1e-5\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+\n+template <typename T>\n+T linear_interpolation(const T* xData, const T* yData, const int lData, const T xVal) // xData is sorted and is strictly monotonic increasing\n+{\n+ auto x_above = std::lower_bound(xData, xData + lData, xVal); // find the position of the first x that is above the xVal\n+\n+ if (x_above == xData)\n+ return *yData;\n+\n+ auto x_below = x_above - 1; // get the position of value just below or equal to xVal[j]\n+ auto y_below = yData + (x_below - xData); // get the position of the matching value y of x_below\n+\n+ if ((xVal - *x_below) < (T)PRECISION) // x_below <= xVal[j]\n+ return *y_below; // same x so take y directly\n+\n+\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+\n+ return *y_below + (*y_above - *y_below) * (xVal - *x_below) / (*x_above - *x_below);\n+}\n+\n+template <typename T>\n+void linear_interpolation(const T* xData, const T* yData, const int lData, // xData is sorted and is strictly monotonic increasing\n+ const T* xVals, T* yVals, const int lVals)\n+{\n+ for(int j = 0; j < lVals; j++)\n+ yVals[j] = linear_interpolation(xData, yData, lData, xVals[j]);\n+}\n+\n+template <typename T>\n+void linear_interpolation(const std::vector<T>& xData, const std::vector<T>& yData, // xData is sorted and is strictly monotonic increasing\n+ const std::vector<T>& xVals, std::vector<T>& yVals)\n+{\n+ assert(xData.size() == yData.size());\n+ assert(xVals.size() == yVals.size());\n+\n+ for(int j = 0; j < xVals.size(); j++)\n+ yVals[j] = linear_interpolation(xData.data(), yData.data(), xData.size(), xVals[j]);\n+}\n+\n+}\n+}\n+\n+#endif\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add linear interpolation algorithm
|
8,483 |
27.03.2018 10:45:30
| -7,200 |
eda8376adb9d41b96f672166b13d77d6c28f692c
|
Finalization of the user pdf noise generator; Add a histogram writer
|
[
{
"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,7 +8,7 @@ using namespace aff3ct::tools;\ntemplate <typename R>\nUser_pdf_noise_generator_std<R>\n::User_pdf_noise_generator_std(const std::vector<R>& _xData, const std::vector<R>& _yData, const int seed)\n-: User_pdf_noise_generator<R>(_xData, _yData), uniform_dist(0, this->cdf.size()-1)\n+: User_pdf_noise_generator<R>(_xData, _yData), uniform_dist(0., 1.)\n{\nthis->set_seed(seed);\n}\n@@ -16,7 +16,7 @@ User_pdf_noise_generator_std<R>\ntemplate <typename R>\nUser_pdf_noise_generator_std<R>\n::User_pdf_noise_generator_std(const std::vector<Point<R>>& _pdf, const int seed)\n-: User_pdf_noise_generator<R>(_pdf), uniform_dist(0, this->cdf.size()-1)\n+: User_pdf_noise_generator<R>(_pdf), uniform_dist(0., 1.)\n{\nthis->set_seed(seed);\n}\n@@ -24,7 +24,7 @@ User_pdf_noise_generator_std<R>\ntemplate <typename R>\nUser_pdf_noise_generator_std<R>\n::User_pdf_noise_generator_std(const std::vector<std::pair<R,R>>& _pdf, const int seed)\n-: User_pdf_noise_generator<R>(_pdf), uniform_dist(0, this->cdf.size()-1)\n+: User_pdf_noise_generator<R>(_pdf), uniform_dist(0., 1.)\n{\nthis->set_seed(seed);\n}\n@@ -47,7 +47,10 @@ void User_pdf_noise_generator_std<R>\n::generate(R *noise, const unsigned length, const R sigma, const R mu)\n{\nfor (unsigned i = 0; i < length; i++)\n- noise[i] = this->cdf[this->uniform_dist(this->rd_engine)].x();\n+ noise[i] = linear_interpolation(this->cdf_y.data(),\n+ this->cdf_x.data(),\n+ this->cdf_x.size(),\n+ this->uniform_dist(this->rd_engine));\n}\n// ==================================================================================== explicit template instantiation\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": "@@ -15,7 +15,7 @@ class User_pdf_noise_generator_std : public User_pdf_noise_generator<R>\n{\nprivate:\nstd::mt19937 rd_engine; // Mersenne Twister 19937\n- std::uniform_int_distribution<unsigned> uniform_dist;\n+ std::uniform_real_distribution<R> uniform_dist;\npublic:\nUser_pdf_noise_generator_std(const std::vector<R>& _xData, const std::vector<R>& _yData, const int seed = 0);\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": "@@ -26,7 +26,7 @@ class User_pdf_noise_generator : public Noise_generator<R>\n{\nprotected:\nstd::vector<Point<R>> pdf; // input probability density function\n- std::vector<Point<R>> cdf; // cumulative density function\n+ std::vector<R> cdf_x, cdf_y; // cumulative density function\npublic:\nUser_pdf_noise_generator(const std::vector<R>& _xData, const std::vector<R>& _yData)\n@@ -40,10 +40,10 @@ public:\nthrow invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- for(unsigned i = 0; i < pdf.size(); i++)\n+ for(unsigned i = 0; i < this->pdf.size(); i++)\n{\n- pdf[i].x(_xData[i]);\n- pdf[i].y(_yData[i]);\n+ this->pdf[i].x(_xData[i]);\n+ this->pdf[i].y(_yData[i]);\n}\ncompute_cdf();\n@@ -58,10 +58,10 @@ public:\nUser_pdf_noise_generator(const std::vector<std::pair<R,R>>& _pdf)\n: Noise_generator<R>(), pdf(_pdf.size())\n{\n- for (unsigned i = 0; i < pdf.size(); i++)\n+ for (unsigned i = 0; i < this->pdf.size(); i++)\n{\n- pdf[i].x(_pdf[i].first);\n- pdf[i].y(_pdf[i].second);\n+ this->pdf[i].x(_pdf[i].first);\n+ this->pdf[i].y(_pdf[i].second);\n}\ncompute_cdf();\n@@ -71,20 +71,31 @@ public:\n{\n}\n+ R get_min_x() const\n+ {\n+ return this->cdf_x.front();\n+ }\n+\n+ R get_max_x() const\n+ {\n+ return this->cdf_x.back();\n+ }\n+\n+\nprotected:\nvoid compute_cdf()\n{\n// first sort it in ascending order\n- std::sort(pdf.begin(), pdf.end(), tools::x_cmp_lt<R>);\n+ std::sort(this->pdf.begin(), this->pdf.end(), tools::x_cmp_lt<R>);\n// then normalize it with its integral value\n- auto integ = tools::trapz_integral_seq(pdf.data(), pdf.size());\n- std::for_each(pdf.begin(), pdf.end(), [integ](Point<R>& p){p.y(p.y()/integ);}); // divide all elements by 'integ'\n+ auto integ = tools::trapz_integral_seq(this->pdf.data(), this->pdf.size());\n+ std::for_each(this->pdf.begin(), this->pdf.end(), [integ](Point<R>& p){p.y(p.y()/integ);}); // divide all elements by 'integ'\n// interpolation on a bigger vector of the input pdf for better integration\n- cdf.resize(10000);//(pdf.size() * 10);\n- const auto min_x = pdf.front().x();\n- const auto max_x = pdf.back().x();\n+ std::vector<Point<R>> cdf(10000);//(pdf.size() * 10);\n+ const auto min_x = this->pdf.front().x();\n+ const auto max_x = this->pdf.back().x();\nconst auto step_x = (max_x - min_x) / (cdf.size() - 1);\nR x = min_x;\n@@ -92,7 +103,7 @@ protected:\ncdf[i].x(x);\ncdf.back().x(max_x); // force the value to have exactly the max instead of an approximation after the \"+= step_x\"\n- linear_interpolation(pdf, cdf);\n+ linear_interpolation(this->pdf, cdf);\n// computing the cumulative distribution function for input pdf\nstd::vector<R> cumul(cdf.size());\n@@ -110,11 +121,14 @@ protected:\nfor (unsigned i = 0; i < erase_index.size(); i++)\ncdf.erase(cdf.begin() + erase_index[i] - i);\n+ this->cdf_x.resize(cdf.size());\n+ this->cdf_y.resize(cdf.size());\n- // std::ofstream file0(\"cdf.csv\");\n- // for(unsigned i = 0; i < cdf.size(); i++)\n- // file0 << i << \"; \" << cdf[i].x() << \"; \" << cdf[i].y() << std::endl;\n-\n+ for (unsigned i = 0; i < cdf.size(); i++)\n+ {\n+ this->cdf_x[i] = cdf[i].x();\n+ this->cdf_y[i] = cdf[i].y();\n+ }\n}\n};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Algo/histogram.h",
"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/Tools/Math/interpolation.h",
"new_path": "src/Tools/Math/interpolation.h",
"diff": "@@ -18,7 +18,7 @@ namespace tools\n* If xVal goes out of xData range, then return the left or right limit value in function of the violated one.\n*/\ntemplate <typename T>\n-T linear_interpolation(const T* xData, const T* yData, const int lData, const T xVal);\n+T linear_interpolation(const T* xData, const T* yData, const unsigned lData, const T xVal);\n/*\n* Compute the linear interpolation of xVal from the original data pair (x,y) of length lData.\n@@ -26,7 +26,7 @@ T linear_interpolation(const T* xData, const T* yData, const int lData, const T\n* If xVal goes out of xData range, then return the left or right limit value in function of the violated one.\n*/\ntemplate <typename T>\n-T linear_interpolation(const Point<T>* data, const int lData, const T xVal);\n+T linear_interpolation(const Point<T>* data, const unsigned lData, const T xVal);\n/*\n* Compute the linear interpolation of xVals array, of length lVals, from the original data yData matching with its abscissa xData.\n@@ -34,8 +34,8 @@ T linear_interpolation(const Point<T>* data, const int lData, const T xVal);\n* Computed interpolation is returned in the filled array yVals of same size than xVals\n*/\ntemplate <typename T>\n-void linear_interpolation(const T* xData, const T* yData, const int lData,\n- const T* xVals, T* yVals, const int lVals);\n+void linear_interpolation(const T* xData, const T* yData, const unsigned lData,\n+ const T* xVals, T* yVals, const unsigned lVals);\n/*\n* Compute the linear interpolation of xVals vector, from the original data yData matching with its abscissa xData.\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/interpolation.hxx",
"new_path": "src/Tools/Math/interpolation.hxx",
"diff": "@@ -13,7 +13,7 @@ namespace tools\n{\ntemplate <typename T>\n-T linear_interpolation(const T* xData, const T* yData, const int lData, const T xVal)\n+T linear_interpolation(const T* xData, const T* yData, const unsigned lData, const T xVal)\n{\nauto x_above = std::lower_bound(xData, xData + lData, xVal); // find the position of the first x that is above the xVal\n@@ -34,7 +34,7 @@ T linear_interpolation(const T* xData, const T* yData, const int lData, const T\n}\ntemplate <typename T>\n-T linear_interpolation(const Point<T>* data, const int lData, const T xVal)\n+T linear_interpolation(const Point<T>* data, const unsigned lData, const T xVal)\n{\n// find the position of the first x that is above the xVal\nauto p_above = std::lower_bound(data, data + lData, xVal, [](const Point<T>& p, const T& x){return p.x() < x;});\n@@ -53,10 +53,10 @@ T linear_interpolation(const Point<T>* data, const int lData, const T xVal)\n}\ntemplate <typename T>\n-void linear_interpolation(const T* xData, const T* yData, const int lData,\n- const T* xVals, T* yVals, const int lVals)\n+void linear_interpolation(const T* xData, const T* yData, const unsigned lData,\n+ const T* xVals, T* yVals, const unsigned lVals)\n{\n- for(int j = 0; j < lVals; j++)\n+ for(unsigned j = 0; j < lVals; j++)\nyVals[j] = linear_interpolation(xData, yData, lData, xVals[j]);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/main.cpp",
"new_path": "src/main.cpp",
"diff": "@@ -172,6 +172,7 @@ int read_arguments(const int argc, const char** argv, factory::Launcher::paramet\n// }\n#include <aff3ct.hpp>\n+#include \"Tools/Algo/Noise_generator/histogram.h\"\nint main(int argc, char **argv)\n{\n@@ -185,40 +186,19 @@ int main(int argc, char **argv)\ntools::User_pdf_gen_std<T> noise_gene0(px, p0);\n- // unsigned noise_length = 10000;\n- // std::vector<T> noise(noise_length);\n- // noise_gene0.generate(noise.data(), noise_length, 0.0);\n+ unsigned noise_length = 1e6;\n+ std::vector<T> noise(noise_length);\n- // std::sort(noise.begin(), noise.end());\n+ noise_gene0.generate(noise.data(), noise_length, 0.0);\n- // std::ofstream file0(\"aff3ct_noise0.txt\");\n- // for(auto& n : noise)\n- // file0 << n << std::endl;\n+ std::ofstream file0(\"aff3ct_noise0.csv\");\n+ histogram(file0, noise, noise_gene0.get_min_x(), noise_gene0.get_max_x());\n- // int count = 1e6;\n- // T noise = 0;\n- // int nintervals = 100;\n- // std::vector<T> hist(nintervals, 0);\n+ tools::User_pdf_gen_std<T> noise_gene1(px, p1);\n- // for (int i = 0; i < count; ++i)\n- // {\n- // noise_gene0.generate(&noise, 1, 0.0);\n- // ++hist[int(noise*nintervals)];\n- // }\n-\n- // // tools::User_pdf_gen_std<T> noise_gene1(px, p1);\n-\n- // std::cout << \"uniform_real_distribution (0.0,1.0):\" << std::endl;\n- // std::cout << std::fixed; std::cout.precision(1);\n+ noise_gene1.generate(noise.data(), noise_length, 0.0);\n+ std::ofstream file1(\"aff3ct_noise1.csv\");\n+ histogram(file1, noise, noise_gene1.get_min_x(), noise_gene1.get_max_x());\n- // std::ofstream file0(\"aff3ct_noise0.txt\");\n- // for(auto& n : noise)\n- // file0 << n << std::endl;\n-\n- // for (int i=0; i<nintervals; ++i)\n- // {\n- // std::cout << float(i)/nintervals << \"-\" << float(i+1)/nintervals << \": \";\n- // std::cout << std::string(p[i]*nstars/nrolls,'*') << std::endl;\n- // }\n}\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Finalization of the user pdf noise generator; Add a histogram writer
|
8,483 |
27.03.2018 10:55:40
| -7,200 |
fc7a42f5c78e3b5845f45f4bffec668cfe985106
|
Cosmetics renaming
|
[
{
"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": "@@ -7,8 +7,8 @@ using namespace aff3ct::tools;\ntemplate <typename R>\nUser_pdf_noise_generator_std<R>\n-::User_pdf_noise_generator_std(const std::vector<R>& _xData, const std::vector<R>& _yData, const int seed)\n-: User_pdf_noise_generator<R>(_xData, _yData), uniform_dist(0., 1.)\n+::User_pdf_noise_generator_std(const std::vector<R>& _x_data, const std::vector<R>& _y_data, const int seed)\n+: User_pdf_noise_generator<R>(_x_data, _y_data), uniform_dist(0., 1.)\n{\nthis->set_seed(seed);\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": "@@ -18,7 +18,7 @@ private:\nstd::uniform_real_distribution<R> uniform_dist;\npublic:\n- User_pdf_noise_generator_std(const std::vector<R>& _xData, const std::vector<R>& _yData, const int seed = 0);\n+ User_pdf_noise_generator_std(const std::vector<R>& _x_data, const std::vector<R>& _y_data, const int seed = 0);\nUser_pdf_noise_generator_std(const std::vector<Point<R>>& _pdf , const int seed = 0);\nUser_pdf_noise_generator_std(const std::vector<std::pair<R,R>>& _pdf , const int seed = 0);\nvirtual ~User_pdf_noise_generator_std();\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": "@@ -29,21 +29,21 @@ protected:\nstd::vector<R> cdf_x, cdf_y; // cumulative density function\npublic:\n- User_pdf_noise_generator(const std::vector<R>& _xData, const std::vector<R>& _yData)\n- : Noise_generator<R>(), pdf(_xData.size())\n+ User_pdf_noise_generator(const std::vector<R>& _x_data, const std::vector<R>& _y_data)\n+ : Noise_generator<R>(), pdf(_x_data.size())\n{\n- if (_xData.size() != _yData.size())\n+ if (_x_data.size() != _y_data.size())\n{\nstd::stringstream message;\n- message << \"'_xData.size()' has to be equal to 0 '_yData.size()' ('_xData.size()'' = \" << _xData.size()\n- << \" and '_yData.size()' = \" << _yData.size() << \").\";\n+ message << \"'_x_data.size()' has to be equal to 0 '_y_data.size()' ('_x_data.size()'' = \" << _x_data.size()\n+ << \" and '_y_data.size()' = \" << _y_data.size() << \").\";\nthrow invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\nfor(unsigned i = 0; i < this->pdf.size(); i++)\n{\n- this->pdf[i].x(_xData[i]);\n- this->pdf[i].y(_yData[i]);\n+ this->pdf[i].x(_x_data[i]);\n+ this->pdf[i].y(_y_data[i]);\n}\ncompute_cdf();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/interpolation.h",
"new_path": "src/Tools/Math/interpolation.h",
"diff": "@@ -12,39 +12,39 @@ namespace tools\n{\n/*\n- * Compute the linear interpolation of xVal from the original data yData matching with its abscissa xData.\n- * xData, of length lData, must be sorted and strictly monotonic increasing\n- * xData and yData must have the same length\n- * If xVal goes out of xData range, then return the left or right limit value in function of the violated one.\n+ * Compute the linear interpolation of xVal from the original data y_data matching with its abscissa x_data.\n+ * x_data, of length lData, must be sorted and strictly monotonic increasing\n+ * x_data and y_data must have the same length\n+ * If xVal goes out of x_data range, then return the left or right limit value in function of the violated one.\n*/\ntemplate <typename T>\n-T linear_interpolation(const T* xData, const T* yData, const unsigned lData, const T xVal);\n+T linear_interpolation(const T* x_data, const T* y_data, const unsigned lData, const T xVal);\n/*\n* Compute the linear interpolation of xVal from the original data pair (x,y) of length lData.\n* data must be sorted and strictly monotonic increasing according to the first element of its pair, x.\n- * If xVal goes out of xData range, then return the left or right limit value in function of the violated one.\n+ * If xVal 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 Point<T>* data, const unsigned lData, const T xVal);\n/*\n- * Compute the linear interpolation of xVals array, of length lVals, from the original data yData matching with its abscissa xData.\n- * xData, of length lData, must be sorted and strictly monotonic increasing\n- * Computed interpolation is returned in the filled array yVals of same size than xVals\n+ * Compute the linear interpolation of x_vals array, of length lVals, from the original data y_data matching with its abscissa x_data.\n+ * x_data, of length lData, 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*/\ntemplate <typename T>\n-void linear_interpolation(const T* xData, const T* yData, const unsigned lData,\n- const T* xVals, T* yVals, const unsigned lVals);\n+void linear_interpolation(const T* x_data, const T* y_data, const unsigned lData,\n+ const T* x_vals, T* y_vals, const unsigned lVals);\n/*\n- * Compute the linear interpolation of xVals vector, from the original data yData matching with its abscissa xData.\n- * xData must be sorted and strictly monotonic increasing\n- * Computed interpolation is returned in the filled vector yVals of same size than xVals.\n+ * Compute the linear 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*/\ntemplate <typename T>\n-void linear_interpolation(const std::vector<T>& xData, const std::vector<T>& yData,\n- const std::vector<T>& xVals, std::vector<T>& yVals);\n+void linear_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* Compute the linear interpolation of x absicca of 'vals' vector, from the original data pair (x,y).\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/interpolation.hxx",
"new_path": "src/Tools/Math/interpolation.hxx",
"diff": "@@ -13,17 +13,17 @@ namespace tools\n{\ntemplate <typename T>\n-T linear_interpolation(const T* xData, const T* yData, const unsigned lData, const T xVal)\n+T linear_interpolation(const T* x_data, const T* y_data, const unsigned lData, const T xVal)\n{\n- auto x_above = std::lower_bound(xData, xData + lData, xVal); // find the position of the first x that is above the xVal\n+ auto x_above = std::lower_bound(x_data, x_data + lData, xVal); // find the position of the first x that is above the xVal\n- if (x_above == xData)\n- return *yData;\n+ if (x_above == x_data)\n+ return *y_data;\nauto x_below = x_above - 1; // get the position of value just below or equal to xVal\n- auto y_below = yData + (x_below - xData); // get the position of the matching value y of x_below\n+ auto y_below = y_data + (x_below - x_data); // get the position of the matching value y of x_below\n- if ((x_above == (xData + lData)) || comp_equal(xVal, *x_below)) // if last or x_below == xVal\n+ if ((x_above == (x_data + lData)) || comp_equal(xVal, *x_below)) // if last or x_below == xVal\nreturn *y_below; // same x so take y directly\n@@ -53,22 +53,22 @@ T linear_interpolation(const Point<T>* data, const unsigned lData, const T xVal)\n}\ntemplate <typename T>\n-void linear_interpolation(const T* xData, const T* yData, const unsigned lData,\n- const T* xVals, T* yVals, const unsigned lVals)\n+void linear_interpolation(const T* x_data, const T* y_data, const unsigned lData,\n+ const T* x_vals, T* y_vals, const unsigned lVals)\n{\nfor(unsigned j = 0; j < lVals; j++)\n- yVals[j] = linear_interpolation(xData, yData, lData, xVals[j]);\n+ y_vals[j] = linear_interpolation(x_data, y_data, lData, x_vals[j]);\n}\ntemplate <typename T>\n-void linear_interpolation(const std::vector<T>& xData, const std::vector<T>& yData,\n- const std::vector<T>& xVals, std::vector<T>& yVals)\n+void linear_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(xData.size() == yData.size());\n- assert(xVals.size() == yVals.size());\n+ assert(x_data.size() == y_data.size());\n+ assert(x_vals.size() == y_vals.size());\n- for(unsigned j = 0; j < xVals.size(); j++)\n- yVals[j] = linear_interpolation(xData.data(), yData.data(), xData.size(), xVals[j]);\n+ for(unsigned j = 0; j < x_vals.size(); j++)\n+ y_vals[j] = linear_interpolation(x_data.data(), y_data.data(), x_data.size(), x_vals[j]);\n}\ntemplate <typename T>\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Cosmetics renaming
|
8,483 |
30.03.2018 18:41:26
| -7,200 |
f4f34ce1ac6805b1242b4e319647b721ac58bd6e
|
Fix Optical Modem demodulation and Channel
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Channel/Channel.cpp",
"new_path": "src/Factory/Module/Channel/Channel.cpp",
"diff": "@@ -171,6 +171,7 @@ module::Channel<R>* Channel::parameters\nreturn new module::Channel_optical<R>(N,\nnew tools::User_pdf_noise_generator_std<R>(file0, seed + 0),\nnew tools::User_pdf_noise_generator_std<R>(file1, seed + 1),\n+ sigma,\nn_frames);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/Optical/Channel_optical.cpp",
"new_path": "src/Module/Channel/Optical/Channel_optical.cpp",
"diff": "@@ -44,17 +44,26 @@ Channel_optical<R>\ndelete noise_generator_p1;\n}\n+template <typename R>\n+void Channel_optical<R>\n+::set_sigma(const R ROP)\n+{\n+ this->sigma = ROP;\n+}\n+\ntemplate <typename R>\nvoid Channel_optical<R>\n::_add_noise(const R *X_N, R *Y_N, const int frame_id)\n{\nfor (auto n = 0; n < this->N; n++)\n+ {\nif (X_N[n])\n- noise_generator_p1->generate(&this->noise[n], 1, this->sigma);\n+ noise_generator_p1->generate(&this->noise[frame_id * this->N + n], 1, this->sigma);\nelse\n- noise_generator_p0->generate(&this->noise[n], 1, this->sigma);\n+ noise_generator_p0->generate(&this->noise[frame_id * this->N + n], 1, this->sigma);\n- std::copy(this->noise.begin(), this->noise.end(), Y_N);\n+ Y_N[n] = this->noise[frame_id * this->N + n];\n+ }\n}\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/Optical/Channel_optical.hpp",
"new_path": "src/Module/Channel/Optical/Channel_optical.hpp",
"diff": "@@ -32,6 +32,7 @@ public:\nvirtual ~Channel_optical();\nvoid _add_noise(const R *X_N, R *Y_N, const int frame_id = -1);\n+ virtual void set_sigma(const R ROP);\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/Optical/Modem_optical.cpp",
"new_path": "src/Module/Modem/Optical/Modem_optical.cpp",
"diff": "@@ -61,6 +61,8 @@ void Modem_optical<B,R,Q>\nif (!std::is_floating_point<Q>::value)\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, \"Type 'Q' has to be float or double.\");\n+ const Q min_value = 1e-10; // when prob_1 ou prob_0 = 0;\n+\nauto dist0 = noise_generator_p0->get_distribution(this->sigma);\nauto pdf_x0 = dist0->get_pdf_x();\nauto pdf_y0 = dist0->get_pdf_y();\n@@ -69,32 +71,40 @@ void Modem_optical<B,R,Q>\n// auto pdf_x1 = dist1->get_pdf_x(); // shall be same than pdf_x0\nauto pdf_y1 = dist1->get_pdf_y();\n-\n+ unsigned x0_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\nauto x0_above = std::lower_bound(pdf_x0.begin(), pdf_x0.end(), Y_N1[i]);\n- unsigned x0_pos = std::distance(x0_above, pdf_x0.begin());\n- if (x0_above != pdf_x0.begin())\n+ if (x0_above == pdf_x0.end())\n+ x0_pos = pdf_x0.size() - 1;\n+ else if (x0_above == pdf_x0.begin())\n+ x0_pos = 0;\n+ else\n{\n+ x0_pos = std::distance(pdf_x0.begin(), x0_above);\n+\nauto x0_below = x0_above - 1;\n- // find which beteween x_below and x_above is the nearest of Y_N1[i]\n+ // find which between x_below and x_above is the nearest of Y_N1[i]\nx0_pos = (Y_N1[i] - *x0_below) < (Y_N1[i] - *x0_above) ? x0_pos - 1 : x0_pos;\n}\n// then get the matching probabilities\n- auto prob_0 = pdf_y0[x0_pos];\n- auto prob_1 = pdf_y1[x0_pos]; // pdf_x1 shall be same than pdf_x0\n+ auto prob_0 = pdf_y0[x0_pos] == (Q)0 ? min_value : pdf_y0[x0_pos];\n+ auto prob_1 = pdf_y1[x0_pos] == (Q)0 ? min_value : pdf_y1[x0_pos]; // pdf_x1 shall be same than pdf_x0\n- if (prob_1 == (Q)0)\n- Y_N2[i] = -std::numeric_limits<Q>::infinity();\n- else\nY_N2[i] = std::log(prob_0/prob_1);\n}\n}\n+template <typename B, typename R, typename Q>\n+void Modem_optical<B,R,Q>\n+::set_sigma(const R ROP)\n+{\n+ this->sigma = ROP;\n+}\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/Optical/Modem_optical.hpp",
"new_path": "src/Module/Modem/Optical/Modem_optical.hpp",
"diff": "@@ -40,6 +40,8 @@ public:\n{\nreturn Modem<B,R,Q>::get_buffer_size_after_filtering(N, 1, 0, 1, false);\n}\n+ virtual void set_sigma(const R ROP);\n+\nprotected:\nvoid _modulate (const B *X_N1, R *X_N2, const int frame_id);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix Optical Modem demodulation and Channel
|
8,483 |
30.03.2018 18:42:26
| -7,200 |
2fa89afc20a912ed84045e4c8262293f914fcd43
|
Set the sigma value as the ROP value when optical channel or modem
|
[
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/Standard/BFER_std.cpp",
"new_path": "src/Simulation/BFER/Standard/BFER_std.cpp",
"diff": "@@ -114,8 +114,16 @@ void BFER_std<B,R,Q>\n// set current sigma\nfor (auto tid = 0; tid < this->params_BFER_std.n_threads; tid++)\n{\n+ if (this->params_BFER_std.chn->type == \"OPTICAL\")\n+ this->channel[tid]->set_sigma(this->snr_b);\n+ else\nthis->channel[tid]->set_sigma(this->sigma);\n+\n+ if (this->params_BFER_std.mdm->type == \"OPTICAL\")\n+ this->modem[tid]->set_sigma(this->snr_b);\n+ else\nthis->modem[tid]->set_sigma(this->params_BFER_std.mdm->complex ? this->sigma * std::sqrt(2.f) : this->sigma);\n+\nthis->codec [tid]->set_sigma(this->sigma);\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Set the sigma value as the ROP value when optical channel or modem
|
8,483 |
30.03.2018 18:43:07
| -7,200 |
b0e9a6078ec02a114cc29339ea4e8cd9385bca3a
|
Fix the distribution file read and save as a separate vector the pdf normalized
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Distribution/Distribution.hpp",
"new_path": "src/Tools/Algo/Distribution/Distribution.hpp",
"diff": "@@ -17,6 +17,9 @@ protected:\nstd::vector<Point<R>> pdf; // input probability density function as Points\nstd::vector<R> pdf_x, pdf_y; // input probability density function as x and y\n+ std::vector<Point<R>> pdf_norm; // normalized probability density function as Points\n+ std::vector<R> pdf_norm_x, pdf_norm_y; // normalized probability density function as x and y\n+\nstd::vector<Point<R>> cdf; // cumulative density function as Points\nstd::vector<R> cdf_x, cdf_y; // cumulative density function as x and y\n@@ -36,6 +39,9 @@ public:\nconst std::vector<Point<R>>& get_pdf () const;\nconst std::vector<R>& get_pdf_x () const;\nconst std::vector<R>& get_pdf_y () const;\n+ const std::vector<Point<R>>& get_pdf_norm () const;\n+ const std::vector<R>& get_pdf_norm_x() const;\n+ const std::vector<R>& get_pdf_norm_y() const;\nprotected:\nvoid compute_cdf();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/Distribution/Distribution.hxx",
"new_path": "src/Tools/Algo/Distribution/Distribution.hxx",
"diff": "@@ -26,7 +26,7 @@ Distribution<R>\nif (_x_data.size() != _y_data.size())\n{\nstd::stringstream message;\n- message << \"'_x_data.size()' has to be equal to 0 '_y_data.size()' ('_x_data.size()'' = \" << _x_data.size()\n+ message << \"'_x_data.size()' has to be equal to '_y_data.size()' ('_x_data.size()' = \" << _x_data.size()\n<< \" and '_y_data.size()' = \" << _y_data.size() << \").\";\nthrow invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n@@ -89,14 +89,16 @@ void Distribution<R>\n// first sort it in ascending order\nstd::sort(this->pdf.begin(), this->pdf.end(), tools::x_cmp_lt<R>);\n+ this->pdf_norm.resize(pdf.size());\n+\n// then normalize it with its integral value\nauto integ = tools::trapz_integral_seq(this->pdf.data(), this->pdf.size());\n- std::for_each(this->pdf.begin(), this->pdf.end(), [integ](Point<R>& p){p.y(p.y()/integ);}); // divide all elements by 'integ'\n+ std::transform(this->pdf.begin(), this->pdf.end(), this->pdf_norm.begin(), [integ](Point<R> p){p.y(p.y()/integ); return p;}); // divide all elements by 'integ'\n// interpolation on a bigger vector of the input pdf for better integration\nthis->cdf.resize(10000);//(pdf.size() * 10);\n- const auto min_x = this->pdf.front().x();\n- const auto max_x = this->pdf.back().x();\n+ const auto min_x = this->pdf_norm.front().x();\n+ const auto max_x = this->pdf_norm.back().x();\nconst auto step_x = (max_x - min_x) / (this->cdf.size() - 1);\nR x = min_x;\n@@ -104,7 +106,7 @@ void Distribution<R>\nthis->cdf[i].x(x);\nthis->cdf.back().x(max_x); // force the value to have exactly the max instead of an approximation after the \"+= step_x\"\n- linear_interpolation(this->pdf, this->cdf);\n+ linear_interpolation(this->pdf_norm, this->cdf);\n// computing the cumulative distribution function for input pdf\nstd::vector<R> cumul(this->cdf.size());\n@@ -140,6 +142,15 @@ void Distribution<R>\nthis->pdf_x[i] = this->pdf[i].x();\nthis->pdf_y[i] = this->pdf[i].y();\n}\n+\n+ // write pdf_norm as x and y vectors\n+ this->pdf_norm_x.resize(this->pdf_norm.size());\n+ this->pdf_norm_y.resize(this->pdf_norm.size());\n+ for (unsigned i = 0; i < this->pdf_norm.size(); i++)\n+ {\n+ this->pdf_norm_x[i] = this->pdf_norm[i].x();\n+ this->pdf_norm_y[i] = this->pdf_norm[i].y();\n+ }\n}\n@@ -185,6 +196,27 @@ const std::vector<R>& Distribution<R>\nreturn this->pdf_y;\n}\n+template <typename R>\n+const std::vector<Point<R>>& Distribution<R>\n+::get_pdf_norm () const\n+{\n+ return this->pdf_norm;\n+}\n+\n+template <typename R>\n+const std::vector<R>& Distribution<R>\n+::get_pdf_norm_x() const\n+{\n+ return this->pdf_norm_x;\n+}\n+\n+template <typename R>\n+const std::vector<R>& Distribution<R>\n+::get_pdf_norm_y() const\n+{\n+ return this->pdf_norm_y;\n+}\n+\n}\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": "@@ -24,7 +24,7 @@ template <typename R = float>\nclass User_pdf_noise_generator : public Noise_generator<R>\n{\nprotected:\n- std::map<R, Distribution<R>*> distributions; // distributions in function of the noise power\n+ std::map<int, Distribution<R>*> distributions; // distributions in function of the noise power\npublic:\nUser_pdf_noise_generator() {}\n@@ -33,8 +33,7 @@ public:\n{\nstd::string line;\nstd::getline(f_distributions, line);\n- auto v_noise_power = tools::Splitter::split(line, \"\", \"\", \";\");\n-\n+ auto v_noise_power = tools::Splitter::split(line, \"\", \"\", \",;\");\n// get the x values\nstd::vector<std::vector<std::string>> v_x(v_noise_power.size());\n@@ -42,7 +41,7 @@ public:\n{\nstd::getline(f_distributions, line);\n- v_x[i] = tools::Splitter::split(line, \"\", \"\", \";\");\n+ v_x[i] = tools::Splitter::split(line, \"\", \"\", \",;\");\nif (i != 0 && v_x[i].size() != v_x[i-1].size())\n{\n@@ -59,7 +58,7 @@ public:\n{\nstd::getline(f_distributions, line);\n- v_y[i] = tools::Splitter::split(line, \"\", \"\", \";\");\n+ v_y[i] = tools::Splitter::split(line, \"\", \"\", \",;\");\nif (i != 0 && v_y[i].size() != v_y[i-1].size())\n{\n@@ -107,7 +106,9 @@ public:\nconst Distribution<R>* get_distribution(const R noise_power)\n{\n- auto it_dis = this->distributions.find(noise_power);\n+ int np = (int)(noise_power*1000);\n+\n+ auto it_dis = this->distributions.find(np);\nif (it_dis == this->distributions.end())\nreturn nullptr;\n@@ -127,7 +128,9 @@ public:\nthrow invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- this->distributions[noise_power] = new_distribution;\n+ int np = (int)(noise_power*1000);\n+\n+ this->distributions[np] = new_distribution;\n}\n};\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix the distribution file read and save as a separate vector the pdf normalized
|
8,483 |
01.04.2018 09:26:46
| -7,200 |
a63ccd5ce1fca48fe768dae53109b88745ee7929
|
Add scripts for the AFF3CT GUI
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "scripts/gui/aff3ct_gui.py",
"diff": "+# import os\n+import sys\n+import time\n+import os\n+import subprocess\n+from PyQt4.QtCore import *\n+from PyQt4.QtGui import *\n+from gui_argument import *\n+\n+\n+class mainTab(argumentTab):\n+ layoutNumberRows = 10\n+ layoutNumberColumns = 4\n+\n+ def __init__(self, aff3ctRoot, aff3ctBinary, simUpdateCallFunction, runCallFunction, grpName):\n+ super(mainTab, self).__init__(grpName)\n+\n+ self.simUpdateCallFunction = simUpdateCallFunction\n+ self.runCallFunction = runCallFunction\n+\n+ self.aff3ctRoot = aff3ctRoot\n+ self.aff3ctBinary = aff3ctBinary\n+\n+ self.addAff3ctRootRow(self.aff3ctRoot)\n+ self.addAff3ctBinaryRow(self.aff3ctBinary)\n+ self.addAff3ctRunRow()\n+\n+ self.updateLayout()\n+\n+ def updateLayout(self):\n+ self.clearLayout()\n+\n+ for a in range(len(self.argList)-1, -1, -1):\n+ if not self.argList[a].getUpdated() :\n+ self.argList[a].delete()\n+ del self.argList[a]\n+\n+ self.layout.addWidget(self.labelAff3ctRoot, self.currentLayoutRow, 0, 1, 1)\n+ self.layout.addWidget(self.textboxAff3ctRoot, self.currentLayoutRow, 1, 1, self.layoutNumberColumns-2)\n+ self.layout.addWidget(self.btnAff3ctRoot, self.currentLayoutRow, self.layoutNumberColumns-1,1,1)\n+ self.currentLayoutRow += 1\n+\n+ self.layout.addWidget(self.labelAff3ctBinary, self.currentLayoutRow, 0, 1, 1)\n+ self.layout.addWidget(self.textboxAff3ctBinary, self.currentLayoutRow, 1, 1, self.layoutNumberColumns-2)\n+ self.layout.addWidget(self.btnAff3ctBinary, self.currentLayoutRow, self.layoutNumberColumns-1,1,1)\n+ self.currentLayoutRow += 1\n+\n+ self.layout.addWidget(self.btnAff3ctRun, self.currentLayoutRow, 0, 1, 1)\n+ self.layout.addWidget(self.btnAff3ctUpdate, self.currentLayoutRow, self.layoutNumberColumns-1, 1, 1)\n+ self.currentLayoutRow += 1\n+\n+ for a in self.argList:\n+ a.addToLayout(self.layout, self.currentLayoutRow)\n+ self.currentLayoutRow += 1\n+\n+ def addAff3ctRootRow(self, defaultPath):\n+ # Create label\n+ self.labelAff3ctRoot = QLabel()\n+ self.labelAff3ctRoot.setText(\"AFF3CT root\")\n+ self.labelAff3ctRoot.setToolTip('Root directory from where will be executed AFF3CT')\n+\n+ # Create textbox\n+ self.textboxAff3ctRoot = QLineEdit()\n+ self.textboxAff3ctRoot.setText(defaultPath)\n+ self.textboxAff3ctRoot.setToolTip('Set path to AFF3CT root directory')\n+ self.textboxAff3ctRoot.textChanged.connect(self.textChanged)\n+\n+ # create AFF3CT path button\n+ self.btnAff3ctRoot = QPushButton(\"Browse\")\n+ self.btnAff3ctRoot.setToolTip('Find AFF3CT root directory')\n+ self.btnAff3ctRoot.clicked.connect(self.fileBrowseAff3ctRoot)\n+\n+ def addAff3ctBinaryRow(self, defaultPath):\n+ # Create label\n+ self.labelAff3ctBinary = QLabel()\n+ self.labelAff3ctBinary.setText(\"AFF3CT binary\")\n+\n+ # Create textbox\n+ self.textboxAff3ctBinary = QLineEdit()\n+ self.textboxAff3ctBinary.setText(defaultPath)\n+ self.textboxAff3ctBinary.setToolTip('Set path to AFF3CT binary')\n+ self.textboxAff3ctBinary.textChanged.connect(self.textChanged)\n+\n+ # create AFF3CT path button\n+ self.btnAff3ctBinary = QPushButton(\"Browse\")\n+ self.btnAff3ctBinary.setToolTip('Find AFF3CT binary')\n+ self.btnAff3ctBinary.clicked.connect(self.fileBrowseAff3ctBinary)\n+\n+ def addAff3ctRunRow(self):\n+ # create AFF3CT run button\n+ self.btnAff3ctRun = QPushButton(\"Run (copy to clipboard)\")\n+ self.btnAff3ctRun.setToolTip('Launch AFF3CT!')\n+ self.btnAff3ctRun.clicked.connect(self.runCallFunction)\n+\n+ # create AFF3CT update button\n+ self.btnAff3ctUpdate = QPushButton(\"Update\")\n+ self.btnAff3ctUpdate.setToolTip('Update the argument lists')\n+ self.btnAff3ctUpdate.clicked.connect(self.simUpdateCallFunction)\n+\n+ def getAff3ctBinary(self):\n+ return self.textboxAff3ctBinary.displayText()\n+\n+ def getAff3ctRoot(self):\n+ return self.textboxAff3ctRoot.displayText()\n+\n+ def fileBrowseAff3ctBinary(self):\n+ gotRoot = QDir(self.getAff3ctRoot())\n+ chosenPath = QFileDialog.getOpenFileName(win, 'Open File')\n+ self.textboxAff3ctBinary.setText(gotRoot.relativeFilePath(chosenPath))\n+\n+ def fileBrowseAff3ctRoot(self):\n+ self.textboxAff3ctRoot.setText(QFileDialog.getExistingDirectory(win, 'Open Folder'))\n+\n+ def addArgument(self, argDecl, argDoc):\n+ # if not argDecl.find(\"--sim-cde-type\") == -1 or not argDecl.find(\"--sim-type\") == -1 :\n+ # super(mainTab, self).addArgument(argDecl, argDoc, self.simUpdateCallFunction)\n+ # else:\n+ super(mainTab, self).addArgument(argDecl, argDoc)\n+\n+ def textChanged(self):\n+ self.aff3ctRoot = self.getAff3ctRoot()\n+ self.aff3ctBinary = self.getAff3ctBinary()\n+ self.simUpdateCallFunction()\n+\n+\n+class aff3ctGui(QTabWidget):\n+ def __init__(self, arg):\n+ super(QTabWidget, self).__init__()\n+\n+ # create our window\n+ self.setWindowTitle('AFF3CT GUI')\n+ self.resize(500, 300)\n+\n+ aff3ctRoot = \"../aff3ct/build\";\n+ aff3ctBinary = \"bin/aff3ct\";\n+\n+ # add main tab\n+ self.addTab(mainTab(aff3ctRoot, aff3ctBinary, self.updateSimu, self.runAff3ct, \"Simulation\"), \"Simulation\")\n+ self.updateSimu()\n+\n+ def getCommand(self):\n+ command = \"\"\n+ for t in range(self.count()):\n+ command += self.widget(t).getCommand() + \" \"\n+\n+ # command.replace(\" \", \" \")\n+ return command\n+\n+ def getMainTab(self):\n+ return self.widget(0)\n+\n+ def getTabIndex(self, grpName):\n+ for t in range(self.count()):\n+ if self.widget(t).getGrpName() == grpName :\n+ return t\n+\n+ return -1\n+\n+ def moveToAff3ctRoot(self):\n+ try :\n+ os.chdir(self.getMainTab().getAff3ctRoot())\n+ except OSError:\n+ pass # certainly already in the right folder but exception is throw when the path is given relatively\n+\n+ def runAff3ct(self):\n+ self.moveToAff3ctRoot()\n+ startTime = time.time()\n+ command = \"./\" + self.getMainTab().getAff3ctBinary() + \" \" + self.getCommand()\n+\n+ command = str(command) # Qstring to normal string\n+ command = \" \".join(command.split()) #remove white spaces\n+ print \"Command: \" + command\n+\n+ elapsedTime = time.time() - startTime\n+\n+ # copy to clipboard\n+ cb = app.clipboard()\n+ cb.clear(mode=cb.Clipboard)\n+ cb.setText(command, mode=cb.Clipboard)\n+\n+ def updateSimu(self):\n+ self.moveToAff3ctRoot()\n+ command = self.getMainTab().getAff3ctBinary() + \" \" + self.getCommand() + \" -h --sim-no-colors\"\n+\n+ command = str(command) # Qstring to normal string\n+ command = \" \".join(command.split()) #remove white spaces\n+\n+ print \"Command: \" + command\n+\n+ argsAFFECT = command.split(\" \")\n+ print \"Command split : \"\n+ print(argsAFFECT)\n+\n+ try:\n+ processAFFECT = subprocess.Popen(argsAFFECT, stdout=subprocess.PIPE,\n+ stderr=subprocess.PIPE)\n+ (stdoutAFFECT, stderrAFFECT) = processAFFECT.communicate()\n+ except OSError:\n+ return\n+\n+ returnCode = processAFFECT.returncode\n+\n+ stdOutput = stdoutAFFECT.decode(encoding='UTF-8').split(\"\\n\")\n+ errOutput = stderrAFFECT.decode(encoding='UTF-8')\n+\n+ print \"stdOutput : \"\n+ print stdOutput\n+ print \"errOutput : \"\n+ print errOutput\n+\n+ self.setUpdatesEnabled(False)\n+ self.setUpdated(False)\n+ self.parseAff3ctHelp(stdOutput, errOutput)\n+ self.clearNotUpdatedTabs()\n+ self.setUpdatesEnabled(True)\n+\n+ def parseAff3ctHelp(self, stdOutput, errOutput):\n+ i = 2 #first line is Usage and second is empty\n+\n+ docStartSpace = \" \"\n+\n+ parameter = \"\"\n+ idxTab = 0\n+ while i < len(stdOutput):\n+ if len(stdOutput[i]) == 0 : # empty line\n+ i += 1\n+\n+ else:\n+ parPos = stdOutput[i].find(\" parameter(s):\")\n+ if parPos == -1: # then still in the same parameter type\n+ # add the argument\n+ argDecl = stdOutput[i ]\n+ argDoc = stdOutput[i+1][len(docStartSpace):]\n+ i += 2\n+\n+ while i < len(stdOutput): # check if there is more doc on several lines\n+ if stdOutput[i][:len(docStartSpace)] == docStartSpace :\n+ argDoc += stdOutput[i][len(docStartSpace):]\n+ i += 1\n+ else :\n+ break\n+\n+ self.widget(idxTab).addArgument(str(argDecl), str(argDoc))\n+ else:\n+ parameter = stdOutput[i][:parPos]\n+ idxTab = self.getTabIndex(parameter)\n+ if idxTab == -1 : # then tab does not exist yet\n+ self.addTab(argumentTab(parameter), parameter)\n+ idxTab = self.getTabIndex(parameter)\n+\n+ i += 1\n+\n+ def clearNotUpdatedTabs(self):\n+ for t in range(self.count()-1, -1, -1):\n+ if not self.widget(t).getUpdated() :\n+ self.removeTab(t)\n+ else:\n+ self.widget(t).updateLayout()\n+\n+ def setUpdated(self, val):\n+ for t in range(self.count()-1, -1, -1):\n+ self.widget(t).setUpdated(val)\n+\n+\n+########################################################################### MAIN\n+if __name__ == '__main__':\n+ app = QApplication(sys.argv)\n+ win = aff3ctGui(\"coucou\")\n+ win.show()\n+ sys.exit(app.exec_())\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "scripts/gui/gui_argument.py",
"diff": "+import os\n+from PyQt4.QtCore import *\n+from PyQt4.QtGui import *\n+\n+class aff3ctArgument(QObject):\n+ layoutNumberRows = 1\n+ layoutNumberColumns = 4\n+ argStartSpace = \" \"\n+\n+ def __init__(self, argDecl, argDoc, updateFunction = \"__noupdate__\"):\n+ super(aff3ctArgument, self).__init__()\n+ self.argDecl = argDecl\n+ self.argDoc = argDoc\n+ self.updateCall = updateFunction != \"__noupdate__\";\n+ self.updateFunction = updateFunction;\n+\n+ self.special = \"\"\n+ self.tag = \"\"\n+ self.name = \"\"\n+ self.range = \"\"\n+ self.updated = True\n+\n+ self.parse()\n+\n+ def parse(self):\n+\n+ if self.argDecl[:len(self.argStartSpace)] == self.argStartSpace:\n+ self.special = \"\"\n+ else:\n+ self.special = self.argDecl[:len(self.argStartSpace)-1]\n+\n+ # parse the name\n+ startpos = len(self.argStartSpace)\n+ posspace = self.argDecl.find(\" \", startpos)\n+ if self.argDecl[posspace-1] == \",\": # then there is a tag\n+ posend = self.argDecl.find(\" \", posspace+1)\n+ else:\n+ posend = posspace\n+\n+ if posend == posspace: # no tag\n+ self.tag = \"\"\n+ self.name = self.argDecl[startpos:posend]\n+ else:\n+ self.name = self.argDecl[startpos:posspace-1]\n+ self.tag = self.argDecl[posspace+1:posend]\n+\n+ pos = self.argDecl.find(\"<\", posend)\n+ if pos == -1:\n+ self.range = \"\"\n+ else:\n+ self.range = self.argDecl[pos+1:-1]\n+\n+ # add check box with the argument label\n+ self.cb = QCheckBox(self.getLabel())\n+ self.cb.setToolTip(self.argDoc) # add the doc as tip\n+ if self.updateCall:\n+ self.cb.stateChanged.connect(self.updateFunction)\n+\n+ if self.special == \"{R}\":\n+ self.cb.setChecked(True)\n+\n+ # create the argument setter\n+ if self.range == \"\": # no range\n+ self.setter = \"NONE\"\n+ else:\n+ pos = self.range.find(\"including set\")\n+ if pos != -1: # then a combo box !\n+ self.setter = \"COMBO\"\n+\n+ # Create combobox\n+ self.combo = QComboBox()\n+ spos = self.range.find(\"={\", pos )\n+ epos = self.range.rfind(\"}\", spos)\n+ self.combo.addItems(self.range[spos + 2:epos].split(\"|\"))\n+ self.combo.setToolTip(self.range[pos:])\n+ if self.updateCall:\n+ self.combo.currentIndexChanged.connect(self.updateFunction)\n+\n+ else:\n+ self.setter = \"LINEEDIT\"\n+\n+ self.lineEdit = QLineEdit()\n+ self.lineEdit.setToolTip(self.range)\n+\n+ if self.range.startswith(\"integer\"):\n+ self.lineEdit.setValidator(QIntValidator())\n+\n+ elif self.range.startswith(\"real number\"):\n+ self.lineEdit.setValidator(QDoubleValidator())\n+\n+ elif self.range.startswith(\"text\"):\n+ pass\n+\n+ elif self.range.startswith(\"file\"):\n+ self.setter += \"_BUTTON\"\n+ self.fb = QPushButton(\"Browse\")\n+ self.fb.clicked.connect(self.fileBrowse)\n+\n+ elif self.range.startswith(\"folder\"):\n+ self.setter += \"_BUTTON\"\n+ self.fb = QPushButton(\"Browse\")\n+ self.fb.clicked.connect(self.folderBrowse)\n+\n+\n+ def addToLayout(self, GridLayout, row):\n+ GridLayout.addWidget(self.cb, row, 0, 1, 1)\n+ if self.setter == \"COMBO\":\n+ GridLayout.addWidget(self.combo, row, 1, 1, 1)\n+ elif self.setter == \"LINEEDIT\":\n+ GridLayout.addWidget(self.lineEdit, row, 1, 1, self.layoutNumberColumns-2)\n+ elif self.setter == \"LINEEDIT_BUTTON\":\n+ GridLayout.addWidget(self.lineEdit, row, 1, 1, self.layoutNumberColumns-2)\n+ GridLayout.addWidget(self.fb, row, self.layoutNumberColumns -1, 1, 1)\n+\n+ def getCommand(self):\n+ command = \"\";\n+ if self.cb.isChecked():\n+ command += self.name + \" \"\n+\n+ if self.setter == \"COMBO\":\n+ command += self.combo.currentText()\n+ elif self.setter.startswith(\"LINEEDIT\"):\n+ command += self.lineEdit.displayText()\n+\n+ return command\n+\n+ def getName(self):\n+ return self.name\n+\n+ def getLabel(self):\n+ if len(self.special):\n+ label = self.special + \" \"\n+ else:\n+ label = self.argStartSpace\n+\n+ label += self.name\n+ if not len(self.tag) == 0:\n+ label += \", \" + self.tag\n+\n+ return label\n+\n+ def compare(self, otherArg):\n+ return self.argDecl == otherArg.argDecl and self.argDoc == otherArg.argDoc\n+\n+ def setUpdated(self, val):\n+ self.updated = val\n+\n+ def getUpdated(self):\n+ return self.updated\n+\n+ def delete(self):\n+ # else it is not hidden automatically\n+ self.cb.hide()\n+\n+ if self.setter == \"COMBO\":\n+ self.combo.hide()\n+ elif self.setter == \"LINEEDIT\":\n+ self.lineEdit.hide()\n+ elif self.setter == \"LINEEDIT_BUTTON\":\n+ self.lineEdit.hide()\n+ self.fb.hide()\n+\n+ self.deleteLater()\n+\n+ def fileBrowse(self):\n+ gotRoot = QDir(os.getcwd())\n+ chosenPath = QFileDialog.getOpenFileName(QWidget(), 'Open File')\n+ self.lineEdit.setText(gotRoot.relativeFilePath(chosenPath))\n+\n+ def folderBrowse(self):\n+ self.lineEdit.setText(QFileDialog.getExistingDirectory(win, 'Open Folder'))\n+\n+\n+class argumentTab(QWidget):\n+\n+ def __init__(self, grpName):\n+ super(QWidget, self).__init__()\n+ self.grpName = grpName\n+\n+ self.argList = []\n+\n+ # layout of the tab\n+ self.layout = QGridLayout()\n+ self.setLayout(self.layout)\n+ self.currentLayoutRow = 0\n+ self.updated = False\n+\n+ def getGrpName(self):\n+ return self.grpName\n+\n+ def setUpdated(self, val):\n+ self.updated = val\n+\n+ for a in self.argList:\n+ a.setUpdated(val)\n+\n+ def getUpdated(self):\n+ return self.updated\n+\n+ def clearLayout(self):\n+ while self.layout.count():\n+ child = self.layout.takeAt(0)\n+ # if child.widget():\n+ # child.widget().deleteLater()\n+\n+ self.currentLayoutRow = 0\n+\n+ def updateLayout(self):\n+ self.clearLayout()\n+\n+ for a in range(len(self.argList)-1, -1, -1):\n+ if not self.argList[a].getUpdated() :\n+ self.argList[a].delete()\n+ del self.argList[a]\n+\n+ for a in self.argList:\n+ a.addToLayout(self.layout, self.currentLayoutRow)\n+ self.currentLayoutRow += 1\n+\n+ def addArgument(self, argDecl, argDoc, updateFunction = \"__noupdate__\"):\n+ self.updated = True\n+\n+ #add to the arg list\n+ newArg = aff3ctArgument(argDecl, argDoc, updateFunction)\n+\n+ #try to find if there is not already another one in the list\n+ for a in self.argList:\n+ if a.compare(newArg):\n+ a.setUpdated(True)\n+ return\n+\n+ self.argList.append(newArg)\n+\n+ #and add to the layout\n+ self.argList[-1].addToLayout(self.layout, self.currentLayoutRow)\n+ self.currentLayoutRow += 1\n+\n+ def getCommand(self):\n+ command = \"\";\n+ for a in self.argList:\n+ command += a.getCommand() + \" \"\n+ return command\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "scripts/gui/readme.md",
"diff": "+To launch the AFF3CT GUI, run __aff3ct_gui.py__ with python3.\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add scripts for the AFF3CT GUI
|
8,483 |
01.04.2018 09:27:52
| -7,200 |
7fc5ec6e6f48c416690247864170d0b81d3fc4a3
|
Move the sim-no-colors argumentin Launcher factory instead of Simulation factory
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Launcher/Launcher.cpp",
"new_path": "src/Factory/Launcher/Launcher.cpp",
"diff": "@@ -133,6 +133,13 @@ void factory::Launcher::parameters\n\"Do not display any legend when launching the simulation.\",\ntools::Argument_info::ADVANCED);\n+\n+#ifdef ENABLE_COOL_BASH\n+ args.add(\n+ {p+\"-no-colors\"},\n+ tools::None(),\n+ \"disable the colors in the shell.\");\n+#endif\n}\nvoid factory::Launcher::parameters\n@@ -163,6 +170,10 @@ void factory::Launcher::parameters\ntools::exception::no_backtrace = vals.exist({\"except-no-bt\"});\ntools::exception::no_addr2line = !vals.exist({\"except-a2l\" });\n+\n+#ifdef ENABLE_COOL_BASH\n+ if (vals.exist({p+\"-no-colors\"})) tools::enable_bash_tools = false;\n+#endif\n}\nvoid factory::Launcher::parameters\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/Simulation.cpp",
"new_path": "src/Factory/Simulation/Simulation.cpp",
"diff": "@@ -100,13 +100,6 @@ void Simulation::parameters\ntools::Integer(tools::Positive(), tools::Non_zero()),\n\"MPI communication frequency between the nodes (in millisec).\");\n#endif\n-\n-#ifdef ENABLE_COOL_BASH\n- args.add(\n- {p+\"-no-colors\"},\n- tools::None(),\n- \"disable the colors in the shell.\");\n-#endif\n}\nvoid Simulation::parameters\n@@ -176,8 +169,6 @@ void Simulation::parameters\n// disable the cool bash mode for PyBER\nif (!this->pyber.empty())\ntools::enable_bash_tools = false;\n-\n- if (vals.exist({p+\"-no-colors\"})) tools::enable_bash_tools = false;\n#endif\n#ifdef MULTI_PREC\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Move the sim-no-colors argumentin Launcher factory instead of Simulation factory
|
8,483 |
01.04.2018 09:33:57
| -7,200 |
576bae60e4ea378a012ede5540076ff7fed91ffa
|
Change root path and add parenthesis
|
[
{
"change_type": "MODIFY",
"old_path": "scripts/gui/aff3ct_gui.py",
"new_path": "scripts/gui/aff3ct_gui.py",
"diff": "@@ -131,7 +131,7 @@ class aff3ctGui(QTabWidget):\nself.setWindowTitle('AFF3CT GUI')\nself.resize(500, 300)\n- aff3ctRoot = \"../aff3ct/build\";\n+ aff3ctRoot = \"../../build\";\naff3ctBinary = \"bin/aff3ct\";\n# add main tab\n@@ -169,7 +169,7 @@ class aff3ctGui(QTabWidget):\ncommand = str(command) # Qstring to normal string\ncommand = \" \".join(command.split()) #remove white spaces\n- print \"Command: \" + command\n+ print(\"Command: \" + command)\nelapsedTime = time.time() - startTime\n@@ -185,10 +185,9 @@ class aff3ctGui(QTabWidget):\ncommand = str(command) # Qstring to normal string\ncommand = \" \".join(command.split()) #remove white spaces\n- print \"Command: \" + command\n+ print(\"Command: \" + command)\nargsAFFECT = command.split(\" \")\n- print \"Command split : \"\nprint(argsAFFECT)\ntry:\n@@ -203,10 +202,10 @@ class aff3ctGui(QTabWidget):\nstdOutput = stdoutAFFECT.decode(encoding='UTF-8').split(\"\\n\")\nerrOutput = stderrAFFECT.decode(encoding='UTF-8')\n- print \"stdOutput : \"\n- print stdOutput\n- print \"errOutput : \"\n- print errOutput\n+ print( \"stdOutput : \")\n+ print( stdOutput)\n+ print( \"errOutput : \")\n+ print( errOutput)\nself.setUpdatesEnabled(False)\nself.setUpdated(False)\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Change root path and add parenthesis
|
8,483 |
03.04.2018 10:03:21
| -7,200 |
f57a03b3a82402d7bc56728524264344beb7c6c9
|
Fix optimized mutual info computation; Remove second constructor of channel optical
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/Optical/Channel_optical.cpp",
"new_path": "src/Module/Channel/Optical/Channel_optical.cpp",
"diff": "@@ -25,23 +25,12 @@ Channel_optical<R>\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, \"'noise_generator_p1' can't be NULL.\");\n}\n-template <typename R>\n-Channel_optical<R>\n-::Channel_optical(const int N, const int seed, const R ROP, const int n_frames)\n-: Channel<R>(N, ROP, n_frames),\n- noise_generator_p0(nullptr),//new tools::Gaussian_noise_generator_std<R>(seed))\n- noise_generator_p1(nullptr)//new tools::Gaussian_noise_generator_std<R>(seed))\n-{\n- const std::string name = \"Channel_optical\";\n- this->set_name(name);\n-}\n-\ntemplate <typename R>\nChannel_optical<R>\n::~Channel_optical()\n{\n- delete noise_generator_p0;\n- delete noise_generator_p1;\n+ if (noise_generator_p0 != nullptr) delete noise_generator_p0;\n+ if (noise_generator_p1 != nullptr) delete noise_generator_p1;\n}\ntemplate <typename R>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/Optical/Channel_optical.hpp",
"new_path": "src/Module/Channel/Optical/Channel_optical.hpp",
"diff": "@@ -23,11 +23,10 @@ protected:\ntools::Noise_generator<R> *noise_generator_p1;\npublic:\n- Channel_optical(const int N, tools::Noise_generator<R> *noise_generator_p0 = nullptr,\n- tools::Noise_generator<R> *noise_generator_p1 = nullptr, const R ROP = (R)1, const int n_frames = 1);\n-\n- Channel_optical(const int N, const int seed, const R ROP = (R)1,\n- const int n_frames = 1);\n+ Channel_optical(const int N,\n+ tools::Noise_generator<R> *noise_generator_p0,\n+ tools::Noise_generator<R> *noise_generator_p1,\n+ const R ROP = (R)1, const int n_frames = 1);\nvirtual ~Channel_optical();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"diff": "@@ -69,7 +69,7 @@ R Monitor_BFER<B,R>\nY + f * this->K,\nf);\n- return MI_sum / (R)this->n_frames;\n+ return MI_sum / (R)this->n_frames * 10000;\n}\n@@ -105,15 +105,11 @@ template <typename B, typename R>\nR Monitor_BFER<B,R>\n::_check_mutual_info(const B *X, const R *Y, const int frame_id)\n{\n- // auto MI_sum_new = tools::_check_mutual_info_histo(X, Y, this->K);\n- auto MI_sum_old = tools::_check_mutual_info_histo_old(X, Y, this->K);\n+ auto mi = tools::_check_mutual_info_histo(X, Y, this->K);\n- // if (MI_sum_new != MI_sum_old)\n- // std::cerr << \"new = \" << MI_sum_new << \", old \" << MI_sum_old << std::endl;\n+ MI_sum += mi;\n- MI_sum += MI_sum_old;\n-\n- return MI_sum_old;\n+ return mi;\n}\ntemplate <typename B, typename R>\n"
},
{
"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": "-#include <stdexcept>\n#include <algorithm>\n#include \"User_pdf_noise_generator_std.hpp\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Algo/mutual_info.h",
"new_path": "src/Tools/Algo/mutual_info.h",
"diff": "@@ -20,7 +20,9 @@ R _check_mutual_info_histo(const B* ref, const R* llr, const unsigned size)\n// compute the llr_sum2 as the sum of the llr[i]^2\n// compute the llr_mean as llr_sum / llr_noninfinite_count\n// compute the llr_variance as sum of (llr[i] - mean)^2 / llr_noninfinite_count\n- // = sum( llr_sum2 + 2 * mean * llr_sum + size * mean^2 ) / llr_noninfinite_count\n+ // = sum( llr_sum2 - 2 * mean * llr_sum + llr_noninfinite_count * mean^2 ) / llr_noninfinite_count\n+ // = sum( llr_sum2 - 2 * mean * llr_sum + llr_sum * mean ) / llr_noninfinite_count\n+ // = sum( llr_sum2 - 1 * mean * llr_sum) / llr_noninfinite_count\nunsigned bit_1_count = 0;\nunsigned llr_0_noninfinite_count = 0;\n@@ -80,9 +82,8 @@ R _check_mutual_info_histo(const B* ref, const R* llr, const unsigned size)\n{\nR llr_0_mean = llr_0_sum / (R)llr_0_noninfinite_count;\nR llr_1_mean = llr_1_sum / (R)llr_1_noninfinite_count;\n- R llr_0_variance = (llr_0_sum2 - (R)2 * llr_0_mean * llr_0_sum + size * llr_0_mean) / (R)llr_0_noninfinite_count;\n- R llr_1_variance = (llr_1_sum2 - (R)2 * llr_1_mean * llr_1_sum + size * llr_1_mean) / (R)llr_1_noninfinite_count;\n-\n+ R llr_0_variance = (llr_0_sum2 - (R)1 * llr_0_mean * llr_0_sum) / (R)llr_0_noninfinite_count;\n+ R llr_1_variance = (llr_1_sum2 - (R)1 * llr_1_mean * llr_1_sum) / (R)llr_1_noninfinite_count;\nbin_width = (R)0.5 * ((R)3.49 * (R)std::sqrt(llr_0_variance) * (R)(std::pow(llr_0_noninfinite_count, (R)-1.0 / (R)3.0)) +\n(R)3.49 * (R)std::sqrt(llr_1_variance) * (R)(std::pow(llr_1_noninfinite_count, (R)-1.0 / (R)3.0)));\n@@ -111,8 +112,8 @@ R _check_mutual_info_histo(const B* ref, const R* llr, const unsigned size)\nbin_count = 4;\n}\n- std::vector<std::vector<unsigned>> histogram(2, std::vector<unsigned>(bin_count));\n- std::vector<std::vector<R >> pdf (2, std::vector<R >(bin_count));\n+ std::vector<std::vector<unsigned>> histogram(2, std::vector<unsigned>(bin_count, 0));\n+ std::vector<std::vector<R >> pdf (2, std::vector<R >(bin_count, 0));\nfor (unsigned i = 0; i < size; i++)\n{\n@@ -149,139 +150,6 @@ R _check_mutual_info_histo(const B* ref, const R* llr, const unsigned size)\nreturn MI;\n}\n-template <typename B, typename R>\n-R _check_mutual_info_histo_old(const B* ref, const R* llr, const unsigned size)\n-{\n- unsigned bit_1_count = 0;\n- for (unsigned i = 0; i < size; i++)\n- bit_1_count += (unsigned)ref[i];\n-\n- unsigned bit_0_count = (unsigned)size - bit_1_count;\n- if (bit_0_count == 0 || bit_1_count == 0)\n- {\n- return (R)0;\n- }\n- else\n- {\n- const R inf = std::numeric_limits<R>::infinity();\n-\n- bool lots_of_bins;\n- unsigned bin_count;\n- int bin_offset = 0;\n- R bin_width = (R)0;\n-\n- // determine the min and max value for llrs / 0 and llrs / 1\n- R llr_0_max = -inf, llr_1_max = -inf;\n- R llr_0_min = +inf, llr_1_min = +inf;\n-\n- unsigned llr_0_noninfinite_count = 0;\n- unsigned llr_1_noninfinite_count = 0;\n-\n- for (unsigned i = 0; i < size; i++)\n- {\n- if (!std::isinf(llr[i]))\n- {\n- if ((int)ref[i] == 0)\n- {\n- llr_0_noninfinite_count++;\n- llr_0_min = std::min(llr[i], llr_0_min);\n- llr_0_max = std::max(llr[i], llr_0_max);\n- }\n- else\n- {\n- llr_1_noninfinite_count++;\n- llr_1_min = std::min(llr[i], llr_1_min);\n- llr_1_max = std::max(llr[i], llr_1_max);\n- }\n- }\n- }\n- if (llr_0_noninfinite_count && llr_1_noninfinite_count && llr_0_min <= llr_1_max && llr_1_min <= llr_0_max)\n- {\n- R llr_0_mean = (R)0;\n- R llr_1_mean = (R)0;\n- for (unsigned i = 0; i < size; i++)\n- {\n- if (!std::isinf(llr[i]))\n- {\n- if ((int)ref[i] == 0) llr_0_mean += llr[i];\n- else llr_1_mean += llr[i];\n- }\n- }\n- llr_0_mean /= llr_0_noninfinite_count;\n- llr_1_mean /= llr_1_noninfinite_count;\n-\n- R llr_0_variance = (R)0;\n- R llr_1_variance = (R)0;\n- for (unsigned i = 0; i < size; i++)\n- {\n- if (!std::isinf(llr[i]))\n- {\n- if ((int)ref[i] == 0) llr_0_variance += std::pow((llr[i] - llr_0_mean), 2);\n- else llr_1_variance += std::pow((llr[i] - llr_1_mean), 2);\n- }\n- }\n- llr_0_variance /= llr_0_noninfinite_count;\n- llr_1_variance /= llr_1_noninfinite_count;\n-\n- bin_width = (R)0.5 * ((R)3.49 * (R)std::sqrt(llr_0_variance) * (R)(std::pow(llr_0_noninfinite_count, (R)-1.0 / (R)3.0)) +\n- (R)3.49 * (R)std::sqrt(llr_1_variance) * (R)(std::pow(llr_1_noninfinite_count, (R)-1.0 / (R)3.0)));\n- if (bin_width > (R)0)\n- {\n- bin_offset = (int)std::floor(std::min(llr_0_min, llr_1_min) / bin_width) -1;\n- auto tmp = std::max(llr_0_max, llr_1_max) / bin_width - (R)bin_offset + (R)1;\n- bin_count = (unsigned)std::ceil(tmp);\n- if ((R)bin_count == tmp)\n- bin_count++;\n- }\n- else\n- {\n- bin_offset = -1;\n- bin_count = 3;\n- }\n- lots_of_bins = true;\n- }\n- else\n- {\n- lots_of_bins = false;\n- bin_count = 4;\n- }\n-\n- std::vector<std::vector<unsigned>> histogram(2, std::vector<unsigned>(bin_count));\n- std::vector<std::vector<R >> pdf (2, std::vector<R >(bin_count));\n- for (unsigned i = 0; i < size; i++)\n- {\n- if (llr[i] == -inf) histogram[(int)ref[i]][0 ]++;\n- else if (llr[i] == inf) histogram[(int)ref[i]][bin_count -1]++;\n- else\n- {\n- if (lots_of_bins)\n- {\n- if (bin_width > 0.0)\n- histogram[(int)ref[i]][(int)(std::floor(llr[i] / bin_width) - bin_offset)]++;\n- else\n- histogram[(int)ref[i]][1]++;\n- }\n- else\n- histogram[(int)ref[i]][(int)ref[i] +1]++;\n- }\n- }\n-\n- for (unsigned i = 0; i < bin_count; i++)\n- {\n- pdf[0][i] = (R)histogram[0][i] / (R)bit_0_count;\n- pdf[1][i] = (R)histogram[1][i] / (R)bit_1_count;\n- }\n-\n- R I_E = (R)0;\n- for (auto b = 0; b < 2; b++)\n- for (unsigned bin_ix = 0; bin_ix < bin_count; bin_ix++)\n- if (pdf[b][bin_ix] > (R)0)\n- I_E += (R)0.5 * pdf[b][bin_ix] * std::log2((R)2.0 * pdf[b][bin_ix] / (pdf[0][bin_ix] + pdf[1][bin_ix]));\n-\n- return I_E;\n- }\n-}\n-\n}\n}\n#endif // MUTUAL_INFO_H__\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix optimized mutual info computation; Remove second constructor of channel optical
|
8,483 |
03.04.2018 17:57:06
| -7,200 |
966589668272070e10ce00daddd1e08f4ee54a39
|
Write the mutual information function with MIPP
|
[
{
"change_type": "DELETE",
"old_path": "src/Tools/Algo/mutual_info.h",
"new_path": null,
"diff": "-#ifndef MUTUAL_INFO_H__\n-#define MUTUAL_INFO_H__\n-\n-#include <cmath>\n-#include <limits>\n-#include <vector>\n-\n-namespace aff3ct\n-{\n-namespace tools\n-{\n-\n-template <typename B, typename R>\n-R _check_mutual_info_histo(const B* ref, const R* llr, const unsigned size)\n-{\n- const R inf = std::numeric_limits<R>::infinity();\n-\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- // compute the llr_sum2 as the sum of the llr[i]^2\n- // compute the llr_mean as llr_sum / llr_noninfinite_count\n- // compute the llr_variance as sum of (llr[i] - mean)^2 / llr_noninfinite_count\n- // = sum( llr_sum2 - 2 * mean * llr_sum + llr_noninfinite_count * mean^2 ) / llr_noninfinite_count\n- // = sum( llr_sum2 - 2 * mean * llr_sum + llr_sum * mean ) / llr_noninfinite_count\n- // = sum( llr_sum2 - 1 * mean * llr_sum) / llr_noninfinite_count\n-\n- unsigned bit_1_count = 0;\n- unsigned llr_0_noninfinite_count = 0;\n- unsigned llr_1_noninfinite_count = 0;\n-\n- R llr_0_sum = (R)0;\n- R llr_1_sum = (R)0;\n- R llr_0_sum2 = (R)0;\n- R llr_1_sum2 = (R)0;\n-\n- R llr_0_max = -inf;\n- R llr_1_max = -inf;\n- R llr_0_min = +inf;\n- R llr_1_min = +inf;\n-\n- for (unsigned i = 0; i < size; i++)\n- {\n- bit_1_count += ref[i] ? (unsigned)1 : (unsigned)0;\n-\n- if (!std::isinf(llr[i]))\n- {\n- if (ref[i])\n- {\n- llr_1_noninfinite_count++;\n-\n- llr_1_sum += llr[i];\n- llr_1_sum2 += llr[i] * llr[i];\n-\n- llr_1_min = std::min(llr[i], llr_1_min);\n- llr_1_max = std::max(llr[i], llr_1_max);\n- }\n- else\n- {\n- llr_0_noninfinite_count++;\n-\n- llr_0_sum += llr[i];\n- llr_0_sum2 += llr[i] * llr[i];\n-\n- llr_0_min = std::min(llr[i], llr_0_min);\n- llr_0_max = std::max(llr[i], llr_0_max);\n- }\n- }\n- }\n-\n- unsigned bit_0_count = size - bit_1_count;\n-\n- if (bit_0_count == 0 || bit_1_count == 0)\n- return (R)0;\n-\n-\n- bool lots_of_bins;\n- unsigned bin_count;\n- int bin_offset = 0;\n- R bin_width = (R)0;\n-\n- if (llr_0_noninfinite_count && llr_1_noninfinite_count && llr_0_min <= llr_1_max && llr_1_min <= llr_0_max)\n- {\n- R llr_0_mean = llr_0_sum / (R)llr_0_noninfinite_count;\n- R llr_1_mean = llr_1_sum / (R)llr_1_noninfinite_count;\n- R llr_0_variance = (llr_0_sum2 - (R)1 * llr_0_mean * llr_0_sum) / (R)llr_0_noninfinite_count;\n- R llr_1_variance = (llr_1_sum2 - (R)1 * llr_1_mean * llr_1_sum) / (R)llr_1_noninfinite_count;\n-\n- bin_width = (R)0.5 * ((R)3.49 * (R)std::sqrt(llr_0_variance) * (R)(std::pow(llr_0_noninfinite_count, (R)-1.0 / (R)3.0)) +\n- (R)3.49 * (R)std::sqrt(llr_1_variance) * (R)(std::pow(llr_1_noninfinite_count, (R)-1.0 / (R)3.0)));\n-\n- if (bin_width > (R)0)\n- {\n- bin_offset = (int)std::floor(std::min(llr_0_min, llr_1_min) / bin_width) -1;\n-\n- auto tmp = std::max(llr_0_max, llr_1_max) / bin_width - (R)bin_offset + (R)1;\n- bin_count = (unsigned)std::ceil(tmp);\n-\n- if ((R)bin_count == tmp)\n- bin_count++;\n- }\n- else\n- {\n- bin_offset = -1;\n- bin_count = 3;\n- }\n-\n- lots_of_bins = true;\n- }\n- else\n- {\n- lots_of_bins = false;\n- bin_count = 4;\n- }\n-\n- std::vector<std::vector<unsigned>> histogram(2, std::vector<unsigned>(bin_count, 0));\n- std::vector<std::vector<R >> pdf (2, std::vector<R >(bin_count, 0));\n-\n- for (unsigned i = 0; i < size; i++)\n- {\n- const unsigned hist_idx = ref[i] ? 1 : 0;\n-\n- if(llr[i] == -inf)\n- histogram[hist_idx].front()++;\n-\n- else if (llr[i] == inf)\n- histogram[hist_idx].back()++;\n-\n- else if (!lots_of_bins)\n- histogram[hist_idx][hist_idx + 1]++;\n-\n- else if (bin_width > (R)0.0)\n- histogram[hist_idx][(int)(std::floor(llr[i] / bin_width) - bin_offset)]++;\n-\n- else\n- histogram[hist_idx][1]++;\n- }\n-\n- for (unsigned i = 0; i < bin_count; i++)\n- {\n- pdf[0][i] = (R)histogram[0][i] / (R)bit_0_count;\n- pdf[1][i] = (R)histogram[1][i] / (R)bit_1_count;\n- }\n-\n- R MI = (R)0;\n- for (auto b = 0; b < 2; b++)\n- for (unsigned bin_ix = 0; bin_ix < bin_count; bin_ix++)\n- if (pdf[b][bin_ix] > (R)0)\n- MI += (R)0.5 * pdf[b][bin_ix] * std::log2((R)2.0 * pdf[b][bin_ix] / (pdf[0][bin_ix] + pdf[1][bin_ix]));\n-\n- return MI;\n-}\n-\n-}\n-}\n-#endif // MUTUAL_INFO_H__\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Perf/common/mutual_info.cpp",
"diff": "+#include <cmath>\n+#include <limits>\n+#include <vector>\n+#include <assert.h>\n+\n+#include \"Tools/types.h\"\n+#include \"mutual_info.h\"\n+\n+#ifndef M_LN2\n+#define M_LN2 std::log(2)\n+#endif\n+\n+#ifdef MIPP_AVX1\n+\n+template <typename B, typename R>\n+R aff3ct::tools::mutual_info_histo(const B* ref, const R* llr, const unsigned size)\n+{\n+ return mutual_info_histo_seq(ref, llr, size);\n+}\n+\n+#else\n+\n+template <typename B, typename R>\n+R aff3ct::tools::mutual_info_histo(const B* ref, const R* llr, const unsigned size)\n+{\n+ static_assert(mipp::N<B>() == mipp::N<R>(), \"B and R shall have the same size\");\n+\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+ * compute the llr_sum2 as the sum of the llr[i]^2\n+ * compute the llr_mean as llr_sum / llr_noninf_count\n+ * compute the llr_variance as sum of (llr[i] - mean)^2 / llr_noninf_count\n+ * = sum( llr_sum2 - 2 * mean * llr_sum + llr_noninf_count * mean^2 ) / llr_noninf_count\n+ * = sum( llr_sum2 - 2 * mean * llr_sum + llr_sum * mean ) / llr_noninf_count\n+ * = sum( llr_sum2 - 1 * mean * llr_sum) / llr_noninf_count\n+ */\n+\n+ const R inf = std::numeric_limits<R>::infinity();\n+\n+ const mipp::Reg<B> Bzeros = (B)0, Bones = (B)1;\n+ const mipp::Reg<R> Rzeros = (R)0, Rones = (R)1;\n+ const mipp::Reg<R> r_infp = (R)+inf;\n+ const mipp::Reg<R> r_infn = (R)-inf;\n+\n+\n+\n+ mipp::Reg<B> r_bit_1_count = (B)0; // sum of ref at 1\n+ mipp::Reg<B> r_llr_0_noninf_count = (B)0; // sum of non infinite llr when ref is 0\n+ mipp::Reg<B> r_llr_1_noninf_count = (B)0; // sum of non infinite llr when ref is 1\n+ mipp::Reg<B> r_llr_0_infpos_count = (B)0; // sum of positive infinite llr when ref is 0\n+ mipp::Reg<B> r_llr_0_infneg_count = (B)0; // sum of negative infinite llr when ref is 0\n+ mipp::Reg<B> r_llr_1_infpos_count = (B)0; // sum of positive infinite llr when ref is 1\n+ mipp::Reg<B> r_llr_1_infneg_count = (B)0; // sum of negative infinite llr when ref is 1\n+\n+ mipp::Reg<R> r_llr_0_sum = (R)0;\n+ mipp::Reg<R> r_llr_1_sum = (R)0;\n+ mipp::Reg<R> r_llr_0_sum2 = (R)0;\n+ mipp::Reg<R> r_llr_1_sum2 = (R)0;\n+\n+ mipp::Reg<R> r_llr_0_max = (R)-inf;\n+ mipp::Reg<R> r_llr_1_max = (R)-inf;\n+ mipp::Reg<R> r_llr_0_min = (R)+inf;\n+ mipp::Reg<R> r_llr_1_min = (R)+inf;\n+\n+ auto vec_loop_size = (size / mipp::N<B>()) * mipp::N<B>();\n+\n+ for (unsigned i = 0; i < vec_loop_size; i += mipp::N<B>())\n+ {\n+ const mipp::Reg<B> r_ref = ref + i;\n+ const auto m_ref = r_ref != Bzeros; // mask is true when ref is not null\n+\n+ r_bit_1_count += mipp::blend(Bones, Bzeros, m_ref);\n+\n+ const mipp::Reg<R> r_llr = llr + i;\n+ auto m_llr_infp = r_llr == r_infp; // mask is true when llr is infinite positive\n+ auto m_llr_infn = r_llr == r_infn; // mask is true when llr is infinite negative\n+ const auto m_llr_ninf = (~m_llr_infp) & (~m_llr_infn); // mask is true when llr is not infinite (pos or neg)\n+\n+ const auto m_ref0_ninf = mipp::andnb(m_ref, m_llr_ninf); // mask is true when ref is 0 and llr is not infinite\n+ const auto m_ref1_ninf = mipp::andb (m_ref, m_llr_ninf); // mask is true when ref is 1 and llr is not infinite\n+\n+ const auto m_ref0_infp = mipp::andnb(m_ref, m_llr_infp); // mask is true when ref is 0 and llr is infinite positive\n+ const auto m_ref1_infp = mipp::andb (m_ref, m_llr_infp); // mask is true when ref is 1 and llr is infinite positive\n+\n+ const auto m_ref0_infn = mipp::andnb(m_ref, m_llr_infn); // mask is true when ref is 0 and llr is infinite negative\n+ const auto m_ref1_infn = mipp::andb (m_ref, m_llr_infn); // mask is true when ref is 1 and llr is infinite negative\n+\n+\n+ r_llr_0_noninf_count += mipp::blend(Bones, Bzeros, m_ref0_ninf);\n+ r_llr_1_noninf_count += mipp::blend(Bones, Bzeros, m_ref1_ninf);\n+\n+ r_llr_0_infpos_count += mipp::blend(Bones, Bzeros, m_ref0_infp);\n+ r_llr_1_infpos_count += mipp::blend(Bones, Bzeros, m_ref1_infp);\n+\n+ r_llr_0_infneg_count += mipp::blend(Bones, Bzeros, m_ref0_infn);\n+ r_llr_1_infneg_count += mipp::blend(Bones, Bzeros, m_ref1_infn);\n+\n+\n+ r_llr_0_sum += mipp::blend(r_llr, Rzeros, m_ref0_ninf);\n+ r_llr_0_sum2 += mipp::blend(r_llr * r_llr, Rzeros, m_ref0_ninf);\n+\n+ r_llr_1_sum += mipp::blend(r_llr, Rzeros, m_ref1_ninf);\n+ r_llr_1_sum2 += mipp::blend(r_llr * r_llr, Rzeros, m_ref1_ninf);\n+\n+\n+ r_llr_0_min = mipp::blend(mipp::min(r_llr, r_llr_0_min), r_llr_0_min, m_ref0_ninf);\n+ r_llr_0_max = mipp::blend(mipp::max(r_llr, r_llr_0_max), r_llr_0_max, m_ref0_ninf);\n+\n+ r_llr_1_min = mipp::blend(mipp::min(r_llr, r_llr_1_min), r_llr_1_min, m_ref1_ninf);\n+ r_llr_1_max = mipp::blend(mipp::max(r_llr, r_llr_1_max), r_llr_1_max, m_ref1_ninf);\n+ }\n+\n+ // reductions\n+ B bit_1_count = mipp::hadd(r_bit_1_count );\n+ B llr_0_noninf_count = mipp::hadd(r_llr_0_noninf_count);\n+ B llr_1_noninf_count = mipp::hadd(r_llr_1_noninf_count);\n+ B llr_0_infpos_count = mipp::hadd(r_llr_0_infpos_count);\n+ B llr_0_infneg_count = mipp::hadd(r_llr_0_infneg_count);\n+ B llr_1_infpos_count = mipp::hadd(r_llr_1_infpos_count);\n+ B llr_1_infneg_count = mipp::hadd(r_llr_1_infneg_count);\n+\n+ R llr_0_sum = mipp::hadd(r_llr_0_sum );\n+ R llr_1_sum = mipp::hadd(r_llr_1_sum );\n+ R llr_0_sum2 = mipp::hadd(r_llr_0_sum2);\n+ R llr_1_sum2 = mipp::hadd(r_llr_1_sum2);\n+\n+ R llr_0_max = mipp::hmax(r_llr_0_max);\n+ R llr_1_max = mipp::hmax(r_llr_1_max);\n+ R llr_0_min = mipp::hmin(r_llr_0_min);\n+ R llr_1_min = mipp::hmin(r_llr_1_min);\n+\n+ // finishes the loop sequentially if needed\n+ for (unsigned i = vec_loop_size; i < size; i++)\n+ {\n+ bit_1_count += ref[i] ? (unsigned)1 : (unsigned)0;\n+\n+ if (llr[i] == +inf)\n+ {\n+ if (ref[i])\n+ llr_1_infpos_count ++;\n+ else\n+ llr_0_infpos_count ++;\n+ }\n+ else if (llr[i] == -inf)\n+ {\n+ if (ref[i])\n+ llr_1_infneg_count ++;\n+ else\n+ llr_0_infneg_count ++;\n+ }\n+ else\n+ {\n+ if (ref[i])\n+ {\n+ llr_1_noninf_count++;\n+\n+ llr_1_sum += llr[i];\n+ llr_1_sum2 += llr[i] * llr[i];\n+\n+ llr_1_min = std::min(llr[i], llr_1_min);\n+ llr_1_max = std::max(llr[i], llr_1_max);\n+ }\n+ else\n+ {\n+ llr_0_noninf_count++;\n+\n+ llr_0_sum += llr[i];\n+ llr_0_sum2 += llr[i] * llr[i];\n+\n+ llr_0_min = std::min(llr[i], llr_0_min);\n+ llr_0_max = std::max(llr[i], llr_0_max);\n+ }\n+ }\n+ }\n+\n+\n+ B bit_0_count = (B)size - bit_1_count;\n+\n+ // if all ones or all zeros then quit\n+ if (bit_1_count == 0 || bit_0_count == 0)\n+ return (R)0;\n+\n+\n+\n+ bool lots_of_bins;\n+ unsigned bin_count;\n+ int bin_offset = 0;\n+ R bin_width = (R)0;\n+\n+ if (llr_0_noninf_count && llr_1_noninf_count && llr_0_min <= llr_1_max && llr_1_min <= llr_0_max)\n+ {\n+ R llr_0_mean = llr_0_sum / (R)llr_0_noninf_count;\n+ R llr_1_mean = llr_1_sum / (R)llr_1_noninf_count;\n+ R llr_0_variance = (llr_0_sum2 - (R)1 * llr_0_mean * llr_0_sum) / (R)llr_0_noninf_count;\n+ R llr_1_variance = (llr_1_sum2 - (R)1 * llr_1_mean * llr_1_sum) / (R)llr_1_noninf_count;\n+\n+ bin_width = (R)0.5 * ((R)3.49 * (R)std::sqrt(llr_0_variance) * (R)(std::pow(llr_0_noninf_count, (R)-1.0 / (R)3.0)) +\n+ (R)3.49 * (R)std::sqrt(llr_1_variance) * (R)(std::pow(llr_1_noninf_count, (R)-1.0 / (R)3.0)));\n+\n+ if (bin_width > (R)0)\n+ {\n+ bin_offset = (int)std::floor(std::min(llr_0_min, llr_1_min) / bin_width) -1;\n+\n+ auto tmp = std::max(llr_0_max, llr_1_max) / bin_width - (R)bin_offset + (R)1;\n+ bin_count = (unsigned)std::ceil(tmp);\n+\n+ if ((R)bin_count == tmp)\n+ bin_count++;\n+ }\n+ else\n+ {\n+ bin_offset = -1;\n+ bin_count = 3;\n+ }\n+\n+ lots_of_bins = true;\n+ }\n+ else\n+ {\n+ lots_of_bins = false;\n+ bin_count = 4;\n+ }\n+\n+\n+ std::vector<std::vector<B>> hist(2, std::vector<B>(bin_count, 0));\n+\n+\n+ hist[0].front() = llr_0_infneg_count;\n+ hist[0].back () = llr_0_infpos_count;\n+ hist[1].front() = llr_1_infneg_count;\n+ hist[1].back () = llr_1_infpos_count;\n+\n+ if (!lots_of_bins)\n+ {\n+ hist[0][1] = llr_0_noninf_count;\n+ hist[1][2] = llr_1_noninf_count;\n+ }\n+ else if (bin_width == (R)0.0 || bin_offset == -1)\n+ {\n+ hist[0][1] = llr_0_noninf_count;\n+ hist[1][1] = llr_1_noninf_count;\n+ }\n+ else\n+ {\n+ for (unsigned i = 0; i < size; i++)\n+ {\n+ const unsigned hist_idx = ref[i] ? 1 : 0;\n+ hist[hist_idx][(int)(std::floor(llr[i] / bin_width) - bin_offset)] += std::isinf(llr[i]) ? 0 : 1;\n+ }\n+ }\n+\n+ const mipp::Reg<R> r_ln2 = (R)M_LN2;\n+ mipp::Reg<R> r_MI = (R)0;\n+\n+ vec_loop_size = (bin_count / mipp::N<B>()) * mipp::N<B>();\n+\n+ for (unsigned i = 0; i < vec_loop_size; i += mipp::N<B>())\n+ {\n+ const mipp::Reg<B> r_hist0 = hist[0].data() + i;\n+ const mipp::Reg<B> r_hist1 = hist[1].data() + i;\n+ const auto m_hist0 = r_hist0 != Bzeros; // mask is true when hist0 is not null\n+ const auto m_hist1 = r_hist1 != Bzeros; // mask is true when hist1 is not null\n+\n+ const auto r_hist0_R = mipp::cvt<B, R>(r_hist0) / (R)bit_0_count;\n+ const auto r_hist1_R = mipp::cvt<B, R>(r_hist1) / (R)bit_1_count;\n+\n+ const auto r_ln_sum = r_ln2 - mipp::log(r_hist0_R + r_hist1_R);\n+\n+ const auto temp0 = r_hist0_R * (r_ln_sum + mipp::log(r_hist0_R));\n+ const auto temp1 = r_hist1_R * (r_ln_sum + mipp::log(r_hist1_R));\n+\n+ r_MI += mipp::blend(temp0, Rzeros, m_hist0);\n+ r_MI += mipp::blend(temp1, Rzeros, m_hist1);\n+ }\n+\n+ // reductions\n+ R MI = mipp::hadd(r_MI);\n+\n+ for (unsigned i = vec_loop_size; i < bin_count; i++)\n+ {\n+ const auto pdf0 = (hist[0][i] == 0)? (R)0 : (R)hist[0][i] / (R)bit_0_count;\n+ const auto pdf1 = (hist[1][i] == 0)? (R)0 : (R)hist[1][i] / (R)bit_1_count;\n+ const auto sum = pdf0 + pdf1;\n+\n+ if (sum == (R)0.0)\n+ continue;\n+\n+ const auto ln_sum = (R)M_LN2 - std::log(pdf0 + pdf1);\n+\n+ MI += (pdf0 == (R)0.0) ? (R)0.0 : pdf0 * (ln_sum + std::log(pdf0));\n+ MI += (pdf1 == (R)0.0) ? (R)0.0 : pdf1 * (ln_sum + std::log(pdf1));\n+ }\n+\n+ return MI * (R)0.5 / (R)M_LN2;\n+}\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+template <>\n+Q_8 mutual_info_histo<B_8,Q_8>(const B_8* ref, const Q_8* llr, const unsigned size)\n+{\n+ return mutual_info_histo_seq(ref, llr, size);\n+}\n+\n+template <>\n+Q_16 mutual_info_histo<B_16,Q_16>(const B_16* ref, const Q_16* llr, const unsigned size)\n+{\n+ return mutual_info_histo_seq(ref, llr, size);\n+}\n+}\n+}\n+#endif // #ifdef MIPP_AVX\n+\n+template <typename B, typename R>\n+R aff3ct::tools::mutual_info_histo_seq(const B* ref, const R* llr, const unsigned size)\n+{\n+ const R inf = std::numeric_limits<R>::infinity();\n+\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+ // compute the llr_sum2 as the sum of the llr[i]^2\n+ // compute the llr_mean as llr_sum / llr_noninf_count\n+ // compute the llr_variance as sum of (llr[i] - mean)^2 / llr_noninf_count\n+ // = sum( llr_sum2 - 2 * mean * llr_sum + llr_noninf_count * mean^2 ) / llr_noninf_count\n+ // = sum( llr_sum2 - 2 * mean * llr_sum + llr_sum * mean ) / llr_noninf_count\n+ // = sum( llr_sum2 - 1 * mean * llr_sum) / llr_noninf_count\n+\n+ unsigned bit_1_count = 0;\n+ unsigned llr_0_noninf_count = 0;\n+ unsigned llr_1_noninf_count = 0;\n+\n+ R llr_0_sum = (R)0;\n+ R llr_1_sum = (R)0;\n+ R llr_0_sum2 = (R)0;\n+ R llr_1_sum2 = (R)0;\n+\n+ R llr_0_max = -inf;\n+ R llr_1_max = -inf;\n+ R llr_0_min = +inf;\n+ R llr_1_min = +inf;\n+\n+ for (unsigned i = 0; i < size; i++)\n+ {\n+ bit_1_count += ref[i] ? (unsigned)1 : (unsigned)0;\n+\n+ if (!std::isinf(llr[i]))\n+ {\n+ if (ref[i])\n+ {\n+ llr_1_noninf_count++;\n+\n+ llr_1_sum += llr[i];\n+ llr_1_sum2 += llr[i] * llr[i];\n+\n+ llr_1_min = std::min(llr[i], llr_1_min);\n+ llr_1_max = std::max(llr[i], llr_1_max);\n+ }\n+ else\n+ {\n+ llr_0_noninf_count++;\n+\n+ llr_0_sum += llr[i];\n+ llr_0_sum2 += llr[i] * llr[i];\n+\n+ llr_0_min = std::min(llr[i], llr_0_min);\n+ llr_0_max = std::max(llr[i], llr_0_max);\n+ }\n+ }\n+ }\n+\n+ unsigned bit_0_count = size - bit_1_count;\n+\n+ if (bit_0_count == 0 || bit_1_count == 0)\n+ return (R)0;\n+\n+\n+ bool lots_of_bins;\n+ unsigned bin_count;\n+ int bin_offset = 0;\n+ R bin_width = (R)0;\n+\n+ if (llr_0_noninf_count && llr_1_noninf_count && llr_0_min <= llr_1_max && llr_1_min <= llr_0_max)\n+ {\n+ R llr_0_mean = llr_0_sum / (R)llr_0_noninf_count;\n+ R llr_1_mean = llr_1_sum / (R)llr_1_noninf_count;\n+ R llr_0_variance = (llr_0_sum2 - (R)1 * llr_0_mean * llr_0_sum) / (R)llr_0_noninf_count;\n+ R llr_1_variance = (llr_1_sum2 - (R)1 * llr_1_mean * llr_1_sum) / (R)llr_1_noninf_count;\n+\n+ bin_width = (R)0.5 * ((R)3.49 * (R)std::sqrt(llr_0_variance) * (R)(std::pow(llr_0_noninf_count, (R)-1.0 / (R)3.0)) +\n+ (R)3.49 * (R)std::sqrt(llr_1_variance) * (R)(std::pow(llr_1_noninf_count, (R)-1.0 / (R)3.0)));\n+\n+ if (bin_width > (R)0)\n+ {\n+ bin_offset = (int)std::floor(std::min(llr_0_min, llr_1_min) / bin_width) -1;\n+\n+ auto tmp = std::max(llr_0_max, llr_1_max) / bin_width - (R)bin_offset + (R)1;\n+ bin_count = (unsigned)std::ceil(tmp);\n+\n+ if ((R)bin_count == tmp)\n+ bin_count++;\n+ }\n+ else\n+ {\n+ bin_offset = -1;\n+ bin_count = 3;\n+ }\n+\n+ lots_of_bins = true;\n+ }\n+ else\n+ {\n+ lots_of_bins = false;\n+ bin_count = 4;\n+ }\n+\n+ std::vector<std::vector<unsigned>> hist(2, std::vector<unsigned>(bin_count, 0));\n+ std::vector<std::vector<R >> pdf (2, std::vector<R >(bin_count, 0));\n+\n+ for (unsigned i = 0; i < size; i++)\n+ {\n+ const unsigned hist_idx = ref[i] ? 1 : 0;\n+\n+ if(llr[i] == -inf)\n+ hist[hist_idx].front()++;\n+\n+ else if (llr[i] == inf)\n+ hist[hist_idx].back()++;\n+\n+ else if (!lots_of_bins)\n+ hist[hist_idx][hist_idx + 1]++;\n+\n+ else if (bin_width > (R)0.0)\n+ hist[hist_idx][(int)(std::floor(llr[i] / bin_width) - bin_offset)]++;\n+\n+ else\n+ hist[hist_idx][1]++;\n+ }\n+\n+ for (unsigned i = 0; i < bin_count; i++)\n+ {\n+ pdf[0][i] = (R)hist[0][i] / (R)bit_0_count;\n+ pdf[1][i] = (R)hist[1][i] / (R)bit_1_count;\n+ }\n+\n+ R MI = (R)0;\n+ for (auto b = 0; b < 2; b++)\n+ for (unsigned bin_ix = 0; bin_ix < bin_count; bin_ix++)\n+ if (pdf[b][bin_ix] > (R)0)\n+ MI += (R)0.5 * pdf[b][bin_ix] * std::log2((R)2.0 * pdf[b][bin_ix] / (pdf[0][bin_ix] + pdf[1][bin_ix]));\n+\n+ return MI;\n+}\n+\n+// ==================================================================================== explicit template instantiation\n+#ifdef MULTI_PREC\n+template Q_8 aff3ct::tools::mutual_info_histo<B_8, Q_8 >(const B_8*, const Q_8*, const unsigned);\n+template Q_16 aff3ct::tools::mutual_info_histo<B_16, Q_16>(const B_16*, const Q_16*, const unsigned);\n+template Q_32 aff3ct::tools::mutual_info_histo<B_32, Q_32>(const B_32*, const Q_32*, const unsigned);\n+template Q_64 aff3ct::tools::mutual_info_histo<B_64, Q_64>(const B_64*, const Q_64*, const unsigned);\n+#else\n+template Q aff3ct::tools::mutual_info_histo<B, Q>(const B*, const Q*, const unsigned);\n+#endif\n+\n+#ifdef MULTI_PREC\n+template Q_8 aff3ct::tools::mutual_info_histo_seq<B_8, Q_8 >(const B_8*, const Q_8*, const unsigned);\n+template Q_16 aff3ct::tools::mutual_info_histo_seq<B_16, Q_16>(const B_16*, const Q_16*, const unsigned);\n+template Q_32 aff3ct::tools::mutual_info_histo_seq<B_32, Q_32>(const B_32*, const Q_32*, const unsigned);\n+template Q_64 aff3ct::tools::mutual_info_histo_seq<B_64, Q_64>(const B_64*, const Q_64*, const unsigned);\n+#else\n+template Q aff3ct::tools::mutual_info_histo_seq<B, Q>(const B*, const Q*, const unsigned);\n+#endif\n+// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Perf/common/mutual_info.h",
"diff": "+#ifndef MUTUAL_INFO_H__\n+#define MUTUAL_INFO_H__\n+\n+#include <mipp.h>\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+\n+/*\n+ * compute the mutal information between 'ref' and 'llr' of length 'size'\n+ * with the histogram method\n+ */\n+template <typename B, typename R>\n+R mutual_info_histo_seq(const B* ref, const R* llr, const unsigned size);\n+\n+/*\n+ * compute the mutal information between 'ref' and 'llr' of length 'size'\n+ * with the histogram method\n+ * operations are optimized with MIPP except on 8 or 16 bits and for AVX architecture\n+ * that call mutual_info_histo_seq\n+ */\n+template <typename B, typename R>\n+R mutual_info_histo(const B* ref, const R* llr, const unsigned size);\n+\n+}\n+}\n+#endif // MUTUAL_INFO_H__\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Write the mutual information function with MIPP
|
8,483 |
03.04.2018 18:00:40
| -7,200 |
9020cecda56691e7c77904d0de0752eae69323ac
|
Rename check_mutual_info_N into get_mutual_info
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"diff": "@@ -31,12 +31,12 @@ Monitor_BFER<B,R>\nstatic_cast<B*>(ps_V.get_dataptr()));\n});\n- auto &p2 = this->create_task(\"check_mutual_info_N\", mnt::tsk::check_mutual_info_N);\n+ auto &p2 = this->create_task(\"get_mutual_info\", mnt::tsk::get_mutual_info);\nauto &ps_X = this->template create_socket_in<B>(p2, \"X\", this->N * this->n_frames);\nauto &ps_Y = this->template create_socket_in<R>(p2, \"Y\", this->N * this->n_frames);\nthis->create_codelet(p2, [this, &ps_X, &ps_Y]() -> int\n{\n- return this->check_mutual_info(static_cast<B*>(ps_X.get_dataptr()),\n+ return this->get_mutual_info(static_cast<B*>(ps_X.get_dataptr()),\nstatic_cast<R*>(ps_Y.get_dataptr()));\n});\n}\n@@ -59,14 +59,14 @@ int Monitor_BFER<B,R>\ntemplate <typename B, typename R>\nR Monitor_BFER<B,R>\n-::check_mutual_info(const B *X, const R *Y, const int frame_id)\n+::get_mutual_info(const B *X, const R *Y, const int frame_id)\n{\nconst auto f_start = (frame_id < 0) ? 0 : frame_id % this->n_frames;\nconst auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\nR MI_sum = 0;\nfor (auto f = f_start; f < f_stop; f++)\n- MI_sum += this->_check_mutual_info(X + f * this->K,\n+ MI_sum += this->_get_mutual_info(X + f * this->K,\nY + f * this->K,\nf);\n@@ -104,16 +104,10 @@ int Monitor_BFER<B,R>\ntemplate <typename B, typename R>\nR Monitor_BFER<B,R>\n-::_check_mutual_info(const B *X, const R *Y, const int frame_id)\n+::_get_mutual_info(const B *X, const R *Y, const int frame_id)\n{\nauto mi = tools::mutual_info_histo(X, Y, this->N);\n- // auto mi_seq = tools::mutual_info_histo_seq(X, Y, this->N);\n-\n- // if (!tools::comp_equal(mi, mi_seq))\n- // std::cout << \"mi = \" << mi << \", mi_seq = \" << mi_seq << std::endl;\n-\nMI_sum += mi;\n-\nreturn mi;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER.hpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER.hpp",
"diff": "@@ -70,7 +70,7 @@ public:\n}\ntemplate <class AB = std::allocator<B>, class AR = std::allocator<R>>\n- R check_mutual_info(const std::vector<B,AB>& X, const std::vector<R,AR>& Y, const int frame_id = -1)\n+ R get_mutual_info(const std::vector<B,AB>& X, const std::vector<R,AR>& Y, const int frame_id = -1)\n{\nif ((int)X.K() != this->K * this->n_frames)\n{\n@@ -100,7 +100,7 @@ public:\n}\nvirtual int check_errors (const B *U, const B *Y, const int frame_id = -1);\n- virtual R check_mutual_info(const B *X, const R *Y, const int frame_id = -1);\n+ virtual R get_mutual_info(const B *X, const R *Y, const int frame_id = -1);\nvirtual bool fe_limit_achieved();\nunsigned get_fe_limit() const;\n@@ -122,7 +122,7 @@ public:\nvirtual void clear_callbacks();\nprotected:\n- virtual R _check_mutual_info(const B *X, const R *Y, const int frame_id);\n+ virtual R _get_mutual_info(const B *X, const R *Y, const int frame_id);\nvirtual int _check_errors (const B *U, const B *Y, const int frame_id);\n};\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/Monitor.hpp",
"new_path": "src/Module/Monitor/Monitor.hpp",
"diff": "@@ -27,14 +27,14 @@ namespace module\n{\nnamespace tsk\n{\n- enum list { check_errors, check_mutual_info, check_mutual_info_N, SIZE };\n+ enum list { check_errors, check_mutual_info, get_mutual_info, SIZE };\n}\nnamespace sck\n{\nnamespace check_errors { enum list { U, V , SIZE }; }\nnamespace check_mutual_info{ enum list { bits, llrs_a, llrs_e, SIZE }; }\n- namespace check_mutual_info_N { enum list { X, Y , SIZE }; }\n+ namespace get_mutual_info { enum list { X, Y , SIZE }; }\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": "@@ -244,8 +244,8 @@ void BFER_std_threads<B,R,Q>\nif (this->params_BFER_std.mutinfo)\n{\n- mnt[mnt::tsk::check_mutual_info_N][mnt::sck::check_mutual_info_N::X](enc[enc::tsk::encode][enc::sck::encode::X_N]);\n- mnt[mnt::tsk::check_mutual_info_N][mnt::sck::check_mutual_info_N::Y](qnt[qnt::tsk::process][qnt::sck::process::Y_N2]);\n+ mnt[mnt::tsk::get_mutual_info][mnt::sck::get_mutual_info::X](enc[enc::tsk::encode][enc::sck::encode::X_N]);\n+ mnt[mnt::tsk::get_mutual_info][mnt::sck::get_mutual_info::Y](qnt[qnt::tsk::process][qnt::sck::process::Y_N2]);\n}\n}\n@@ -359,7 +359,7 @@ void BFER_std_threads<B,R,Q>\nmonitor[mnt::tsk::check_errors].exec();\nif (this->params_BFER_std.mutinfo)\n- monitor[mnt::tsk::check_mutual_info_N].exec();\n+ monitor[mnt::tsk::get_mutual_info].exec();\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Rename check_mutual_info_N into get_mutual_info
|
8,483 |
04.04.2018 08:28:08
| -7,200 |
8f27aa4cf596c338320d354658f266f28d667095
|
Correct MSVC error by undefining the min max MACROS
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Perf/common/mutual_info.cpp",
"new_path": "src/Tools/Perf/common/mutual_info.cpp",
"diff": "#include \"Tools/types.h\"\n#include \"mutual_info.h\"\n+#ifdef min // for windows MSVC that defines those macros\n+#undef min\n+#endif\n+\n+#ifdef max // for windows MSVC that defines those macros\n+#undef max\n+#endif\n+\n#ifndef M_LN2\n#define M_LN2 std::log(2)\n#endif\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Correct MSVC error by undefining the min max MACROS
|
8,483 |
04.04.2018 10:25:01
| -7,200 |
4b5621b80df686a0bb9c662603688cc42317c615
|
Add algorithm include for min mac
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Perf/common/mutual_info.cpp",
"new_path": "src/Tools/Perf/common/mutual_info.cpp",
"diff": "#include <cmath>\n+#include <algorithm>\n#include <limits>\n#include <vector>\n#include <assert.h>\n#include \"Tools/types.h\"\n#include \"mutual_info.h\"\n-#ifdef min // for windows MSVC that defines those macros\n-#undef min\n-#endif\n-\n-#ifdef max // for windows MSVC that defines those macros\n-#undef max\n-#endif\n-\n#ifndef M_LN2\n#define M_LN2 std::log(2)\n#endif\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add algorithm include for min mac
|
8,483 |
04.04.2018 11:21:22
| -7,200 |
edf00582698a8d2899b393ccf4d90f24578dc66a
|
Do not compute mutual info on 8 or 16 bits
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"diff": "@@ -105,12 +105,34 @@ int Monitor_BFER<B,R>\ntemplate <typename B, typename R>\nR Monitor_BFER<B,R>\n::_get_mutual_info(const B *X, const R *Y, const int frame_id)\n+{\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, \"The mutual_info_histo calculation does not support this type.\");\n+}\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+template <>\n+float Monitor_BFER<int,float>\n+::_get_mutual_info(const int *X, const float *Y, const int frame_id)\n{\nauto mi = tools::mutual_info_histo(X, Y, this->N);\nMI_sum += mi;\nreturn mi;\n}\n+template <>\n+double Monitor_BFER<long,double>\n+::_get_mutual_info(const long *X, const double *Y, const int frame_id)\n+{\n+ auto mi = tools::mutual_info_histo(X, Y, this->N);\n+ MI_sum += mi;\n+ return mi;\n+}\n+}\n+}\n+\ntemplate <typename B, typename R>\nbool Monitor_BFER<B,R>\n::fe_limit_achieved()\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Perf/common/mutual_info.cpp",
"new_path": "src/Tools/Perf/common/mutual_info.cpp",
"diff": "#include <vector>\n#include <assert.h>\n-#include \"Tools/types.h\"\n#include \"mutual_info.h\"\n#ifndef M_LN2\n@@ -294,23 +293,6 @@ R aff3ct::tools::mutual_info_histo(const B* ref, const R* llr, const unsigned si\nreturn MI * (R)0.5 / (R)M_LN2;\n}\n-namespace aff3ct\n-{\n-namespace tools\n-{\n-template <>\n-Q_8 mutual_info_histo<B_8,Q_8>(const B_8* ref, const Q_8* llr, const unsigned size)\n-{\n- return mutual_info_histo_seq(ref, llr, size);\n-}\n-\n-template <>\n-Q_16 mutual_info_histo<B_16,Q_16>(const B_16* ref, const Q_16* llr, const unsigned size)\n-{\n- return mutual_info_histo_seq(ref, llr, size);\n-}\n-}\n-}\n#endif // #ifdef MIPP_AVX\ntemplate <typename B, typename R>\n@@ -454,9 +436,8 @@ R aff3ct::tools::mutual_info_histo_seq(const B* ref, const R* llr, const unsigne\n}\n// ==================================================================================== explicit template instantiation\n+#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n-template Q_8 aff3ct::tools::mutual_info_histo<B_8, Q_8 >(const B_8*, const Q_8*, const unsigned);\n-template Q_16 aff3ct::tools::mutual_info_histo<B_16, Q_16>(const B_16*, const Q_16*, const unsigned);\ntemplate Q_32 aff3ct::tools::mutual_info_histo<B_32, Q_32>(const B_32*, const Q_32*, const unsigned);\ntemplate Q_64 aff3ct::tools::mutual_info_histo<B_64, Q_64>(const B_64*, const Q_64*, const unsigned);\n#else\n@@ -464,8 +445,6 @@ template Q aff3ct::tools::mutual_info_histo<B, Q>(const B*, const Q*, const unsi\n#endif\n#ifdef MULTI_PREC\n-template Q_8 aff3ct::tools::mutual_info_histo_seq<B_8, Q_8 >(const B_8*, const Q_8*, const unsigned);\n-template Q_16 aff3ct::tools::mutual_info_histo_seq<B_16, Q_16>(const B_16*, const Q_16*, const unsigned);\ntemplate Q_32 aff3ct::tools::mutual_info_histo_seq<B_32, Q_32>(const B_32*, const Q_32*, const unsigned);\ntemplate Q_64 aff3ct::tools::mutual_info_histo_seq<B_64, Q_64>(const B_64*, const Q_64*, const unsigned);\n#else\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Do not compute mutual info on 8 or 16 bits
|
8,483 |
04.04.2018 11:45:43
| -7,200 |
bcb8dbb2a8b334c44c35a9a0f447631de12d0222
|
Update aff3ct_gui.py
|
[
{
"change_type": "MODIFY",
"old_path": "scripts/gui/aff3ct_gui.py",
"new_path": "scripts/gui/aff3ct_gui.py",
"diff": "@@ -126,11 +126,11 @@ class mainTab(argumentTab):\nclass aff3ctGui(QTabWidget):\n- def __init__(self, arg):\n+ def __init__(self, title):\nsuper(QTabWidget, self).__init__()\n# create our window\n- self.setWindowTitle('AFF3CT GUI')\n+ self.setWindowTitle(title)\nself.resize(500, 300)\naff3ctRoot = \"../../build\";\n@@ -141,6 +141,7 @@ class aff3ctGui(QTabWidget):\nself.updateSimu()\ndef getCommand(self):\n+ # TODO : return arguments in a list directly to not have to split them in function of a space or other because some arguments (as text) can have spaces\ncommand = \"\"\nfor t in range(self.count()):\ncommand += self.widget(t).getCommand() + \" \"\n@@ -266,6 +267,6 @@ class aff3ctGui(QTabWidget):\n########################################################################### MAIN\nif __name__ == '__main__':\napp = QApplication(sys.argv)\n- win = aff3ctGui(\"coucou\")\n+ win = aff3ctGui('AFF3CT GUI')\nwin.show()\nsys.exit(app.exec_())\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Update aff3ct_gui.py
|
8,490 |
04.04.2018 11:51:25
| -7,200 |
853dd20e2a104fec2af4dbe6c37525b30ab986f1
|
Use Qt5 instead of Qt4.
|
[
{
"change_type": "MODIFY",
"old_path": "scripts/gui/aff3ct_gui.py",
"new_path": "scripts/gui/aff3ct_gui.py",
"diff": "@@ -5,8 +5,8 @@ import sys\nimport time\nimport os\nimport subprocess\n-from PyQt4.QtCore import *\n-from PyQt4.QtGui import *\n+from PyQt5.QtCore import *\n+from PyQt5.QtGui import *\nfrom gui_argument import *\n"
},
{
"change_type": "MODIFY",
"old_path": "scripts/gui/gui_argument.py",
"new_path": "scripts/gui/gui_argument.py",
"diff": "import os\n-from PyQt4.QtCore import *\n-from PyQt4.QtGui import *\n+from PyQt5.QtCore import *\n+from PyQt5.QtGui import *\n+from PyQt5.QtWidgets import *\nclass aff3ctArgument(QObject):\nlayoutNumberRows = 1\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Use Qt5 instead of Qt4.
|
8,483 |
04.04.2018 11:59:50
| -7,200 |
917374ff75bc385346705c10629c1cd321bea298
|
Set directly the type from types.h
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"diff": "@@ -109,13 +109,15 @@ R Monitor_BFER<B,R>\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, \"The mutual_info_histo calculation does not support this type.\");\n}\n+#include \"Tools/types.h\"\n+\nnamespace aff3ct\n{\nnamespace module\n{\ntemplate <>\n-float Monitor_BFER<int,float>\n-::_get_mutual_info(const int *X, const float *Y, const int frame_id)\n+Q_32 Monitor_BFER<B_32,Q_32>\n+::_get_mutual_info(const B_32 *X, const Q_32 *Y, const int frame_id)\n{\nauto mi = tools::mutual_info_histo(X, Y, this->N);\nMI_sum += mi;\n@@ -123,8 +125,8 @@ float Monitor_BFER<int,float>\n}\ntemplate <>\n-double Monitor_BFER<long,double>\n-::_get_mutual_info(const long *X, const double *Y, const int frame_id)\n+Q_64 Monitor_BFER<B_64,Q_64>\n+::_get_mutual_info(const B_64 *X, const Q_64 *Y, const int frame_id)\n{\nauto mi = tools::mutual_info_histo(X, Y, this->N);\nMI_sum += mi;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Set directly the type from types.h
|
8,483 |
04.04.2018 12:29:30
| -7,200 |
4a648e3aef8c21004cc7e07efd0fd015d62e9e6d
|
Try with defined macro
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER.cpp",
"diff": "@@ -110,7 +110,7 @@ R Monitor_BFER<B,R>\n}\n#include \"Tools/types.h\"\n-\n+#if defined(MULTI_PREC) | defined (PREC_32_BIT)\nnamespace aff3ct\n{\nnamespace module\n@@ -123,7 +123,15 @@ Q_32 Monitor_BFER<B_32,Q_32>\nMI_sum += mi;\nreturn mi;\n}\n+}\n+}\n+#endif\n+#if defined(MULTI_PREC) | defined (PREC_64_BIT)\n+namespace aff3ct\n+{\n+namespace module\n+{\ntemplate <>\nQ_64 Monitor_BFER<B_64,Q_64>\n::_get_mutual_info(const B_64 *X, const Q_64 *Y, const int frame_id)\n@@ -134,6 +142,7 @@ Q_64 Monitor_BFER<B_64,Q_64>\n}\n}\n}\n+#endif\ntemplate <typename B, typename R>\nbool Monitor_BFER<B,R>\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Try with defined macro
|
8,483 |
04.04.2018 14:58:01
| -7,200 |
96330cf657988d1eb663eb9cb8187ecec9b310c4
|
Fix get buffer size after filtering, set back CPM that has been removed
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Modem/Modem.cpp",
"new_path": "src/Factory/Module/Modem/Modem.cpp",
"diff": "@@ -367,6 +367,7 @@ int Modem\nelse if (type == \"QAM\" ) return module::Modem_QAM <>::size_fil(N, bps );\nelse if (type == \"PSK\" ) return module::Modem_PSK <>::size_fil(N, bps );\nelse if (type == \"USER\" ) return module::Modem_user <>::size_fil(N, bps );\n+ else if (type == \"CPM\" ) return module::Modem_CPM <>::size_fil(N, bps, cpm_L, cpm_p);\nelse if (type == \"OPTICAL\" ) return module::Modem_optical <>::size_fil(N );\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix get buffer size after filtering, set back CPM that has been removed
|
8,483 |
04.04.2018 16:33:18
| -7,200 |
ac8047fe496a1a5c58b985f87676200234cfb356
|
Add hamming distance with floating point and with only one frame compared to a all zero word
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Perf/common/hamming_distance.cpp",
"new_path": "src/Tools/Perf/common/hamming_distance.cpp",
"diff": "#include <limits>\n+#include <cmath>\n#include \"hamming_distance.h\"\n-//************************************************************************************************* hamming_distance_seq\n+//*************************************************************************************** hamming_distance_seq(in1, in2)\ntemplate <typename B>\ninline size_t aff3ct::tools::hamming_distance_seq(const B *in1, const B *in2, const unsigned size)\n@@ -15,6 +16,85 @@ inline size_t aff3ct::tools::hamming_distance_seq(const B *in1, const B *in2, co\nreturn ham_dist;\n}\n+template <typename B>\n+inline size_t hamming_distance_seq_real(const B *in1, const B *in2, const unsigned size)\n+{\n+ size_t ham_dist = 0;\n+\n+ for (unsigned i = 0; i < size; i++)\n+ ham_dist += std::signbit(in1[i]) ^ std::signbit(in2[i]) ? (size_t)1 : (size_t)0;\n+\n+ return ham_dist;\n+}\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+\n+template <>\n+inline size_t hamming_distance_seq(const float *in1, const float *in2, const unsigned size)\n+{\n+ return hamming_distance_seq_real(in1, in2, size);\n+}\n+\n+template <>\n+inline size_t hamming_distance_seq(const double *in1, const double *in2, const unsigned size)\n+{\n+ return hamming_distance_seq_real(in1, in2, size);\n+}\n+\n+}\n+}\n+\n+\n+\n+//********************************************************************************************* hamming_distance_seq(in)\n+\n+template <typename B>\n+inline size_t aff3ct::tools::hamming_distance_seq(const B *in, const unsigned size)\n+{\n+ size_t ham_dist = 0;\n+\n+ for (unsigned i = 0; i < size; i++)\n+ ham_dist += !in[i] ? (size_t)0 : (size_t)1;\n+\n+ return ham_dist;\n+}\n+\n+\n+template <typename B>\n+inline size_t hamming_distance_seq_real(const B *in, const unsigned size)\n+{\n+ size_t ham_dist = 0;\n+\n+ for (unsigned i = 0; i < size; i++)\n+ ham_dist += std::signbit(in[i]) ? (size_t)1 : (size_t)0;\n+\n+ return ham_dist;\n+}\n+\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+\n+template <>\n+inline size_t hamming_distance_seq(const float *in, const unsigned size)\n+{\n+ return hamming_distance_seq_real(in, size);\n+}\n+\n+template <>\n+inline size_t hamming_distance_seq(const double *in, const unsigned size)\n+{\n+ return hamming_distance_seq_real(in, size);\n+}\n+\n+}\n+}\n+\n//***************************************************************************************************** hamming_distance\n@@ -27,7 +107,18 @@ size_t aff3ct::tools::hamming_distance(const B *in1, const B *in2, const unsigne\nreturn hamming_distance_seq(in1, in2, size);\n}\n-#else\n+template <typename B>\n+size_t aff3ct::tools::hamming_distance(const B *in, const unsigned size)\n+{\n+ return hamming_distance_seq(in, size);\n+}\n+\n+\n+\n+\n+#else // MIPP_AVX1\n+\n+\ntemplate <typename B>\ninline mipp::Reg<B> popcnt(const mipp::Reg<B>& q_in1, const mipp::Reg<B>& q_in2)\n@@ -38,6 +129,37 @@ inline mipp::Reg<B> popcnt(const mipp::Reg<B>& q_in1, const mipp::Reg<B>& q_in2)\nreturn mipp::blend(ones, zeros, m_in1 ^ m_in2);\n}\n+template <typename B>\n+inline mipp::Reg<B> popcnt(const mipp::Reg<B>& q_in)\n+{\n+ const mipp::Reg<B> zeros = (B)0, ones = (B)1;\n+ const auto m_in = q_in != zeros;\n+ return mipp::blend(ones, zeros, m_in);\n+}\n+\n+template <typename B>\n+inline mipp::Reg<B> popcnt_real(const mipp::Reg<B>& q_in)\n+{\n+ const mipp::Reg<B> zeros = (B)0, ones = (B)1;\n+ const auto m_in = q_in < zeros;\n+ return mipp::blend(ones, zeros, m_in);\n+}\n+\n+template <>\n+inline mipp::Reg<float> popcnt(const mipp::Reg<float>& q_in)\n+{\n+ return popcnt_real(q_in);\n+}\n+\n+template <>\n+inline mipp::Reg<double> popcnt(const mipp::Reg<double>& q_in)\n+{\n+ return popcnt_real(q_in);\n+}\n+\n+\n+\n+\ntemplate <typename B>\nsize_t aff3ct::tools::hamming_distance(const B *in1, const B *in2, const unsigned size)\n{\n@@ -48,13 +170,30 @@ size_t aff3ct::tools::hamming_distance(const B *in1, const B *in2, const unsigne\nfor (unsigned i = 0; i < vec_loop_size; i += mipp::N<B>())\ncounter += popcnt<B>(in1 + i, in2 + i);\n- size_t ham_dist = mipp::hadd(counter);\n+ size_t ham_dist = (size_t)mipp::hadd(counter);\nham_dist += tools::hamming_distance_seq(in1 + vec_loop_size, in2 + vec_loop_size, size - vec_loop_size);\nreturn ham_dist;\n}\n+template <typename B>\n+size_t aff3ct::tools::hamming_distance(const B *in, const unsigned 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 (unsigned i = 0; i < vec_loop_size; i += mipp::N<B>())\n+ counter += popcnt<B>(in + i);\n+\n+ size_t ham_dist = (size_t)mipp::hadd(counter);\n+\n+ ham_dist += tools::hamming_distance_seq(in + vec_loop_size, size - vec_loop_size);\n+\n+ return ham_dist;\n+}\n+\nnamespace aff3ct\n{\nnamespace tools\n@@ -125,6 +264,74 @@ size_t hamming_distance<int8_t>(const int8_t *in1, const int8_t *in2, const unsi\nreturn ham_dist;\n}\n+\n+\n+template <>\n+size_t hamming_distance<int16_t>(const int16_t *in, const unsigned 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 (unsigned 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 (unsigned i = ii; i < vec_loop_size2; i += mipp::N<int16_t>())\n+ counter16 += popcnt<int16_t>(in + 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>(in + 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 *in, const unsigned 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 (unsigned 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 (unsigned i = ii; i < vec_loop_size2; i += mipp::N<int8_t>())\n+ counter8 += popcnt<int8_t>(in + 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>(in + vec_loop_size, size - vec_loop_size);\n+\n+ return ham_dist;\n+}\n}\n}\n@@ -140,6 +347,8 @@ template size_t aff3ct::tools::hamming_distance<B_64>(const B_64*, const B_64*,\n#else\ntemplate size_t aff3ct::tools::hamming_distance<B>(const B*, const B*, const unsigned);\n#endif\n+template size_t aff3ct::tools::hamming_distance<float>(const float*, const float*, const unsigned);\n+template size_t aff3ct::tools::hamming_distance<double>(const double*, const double*, const unsigned);\n#ifdef MULTI_PREC\ntemplate size_t aff3ct::tools::hamming_distance_seq<B_8 >(const B_8*, const B_8*, const unsigned);\n@@ -149,5 +358,31 @@ template size_t aff3ct::tools::hamming_distance_seq<B_64>(const B_64*, const B_6\n#else\ntemplate size_t aff3ct::tools::hamming_distance_seq<B>(const B*, const B*, const unsigned);\n#endif\n+template size_t aff3ct::tools::hamming_distance_seq<float>(const float*, const float*, const unsigned);\n+template size_t aff3ct::tools::hamming_distance_seq<double>(const double*, const double*, const unsigned);\n+\n+#ifdef MULTI_PREC\n+template size_t aff3ct::tools::hamming_distance<B_8 >(const B_8*, const unsigned);\n+template size_t aff3ct::tools::hamming_distance<B_16>(const B_16*, const unsigned);\n+template size_t aff3ct::tools::hamming_distance<B_32>(const B_32*, const unsigned);\n+template size_t aff3ct::tools::hamming_distance<B_64>(const B_64*, const unsigned);\n+#else\n+template size_t aff3ct::tools::hamming_distance<B>(const B*, const unsigned);\n+#endif\n+template size_t aff3ct::tools::hamming_distance<float>(const float*, const unsigned);\n+template size_t aff3ct::tools::hamming_distance<double>(const double*, const unsigned);\n+\n+\n+#ifdef MULTI_PREC\n+template size_t aff3ct::tools::hamming_distance_seq<B_8 >(const B_8*, const unsigned);\n+template size_t aff3ct::tools::hamming_distance_seq<B_16>(const B_16*, const unsigned);\n+template size_t aff3ct::tools::hamming_distance_seq<B_32>(const B_32*, const unsigned);\n+template size_t aff3ct::tools::hamming_distance_seq<B_64>(const B_64*, const unsigned);\n+#else\n+template size_t aff3ct::tools::hamming_distance_seq<B>(const B*, const unsigned);\n+#endif\n+template size_t aff3ct::tools::hamming_distance_seq<float>(const float*, const unsigned);\n+template size_t aff3ct::tools::hamming_distance_seq<double>(const double*, const unsigned);\n+\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Perf/common/hamming_distance.h",
"new_path": "src/Tools/Perf/common/hamming_distance.h",
"diff": "@@ -9,6 +9,7 @@ namespace tools\n{\n/*\n* compute the Hamming distance between the arrays 'in1' and 'in2' of length 'size'\n+ * when B is a floating point type then compute the hamming distance from their sign\n*/\ntemplate <typename B = int32_t>\nsize_t hamming_distance_seq(const B *in1, const B *in2, const unsigned size);\n@@ -16,9 +17,25 @@ size_t hamming_distance_seq(const B *in1, const B *in2, const unsigned size);\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+ * when B is a floating point type then compute the hamming distance from their sign\n*/\ntemplate <typename B = int32_t>\nsize_t hamming_distance(const B *in1, const B *in2, const unsigned size);\n+\n+/*\n+ * compute the Hamming distance between the arrays 'in' and a all zero word of length 'size'\n+ * when B is a floating point type then compute the hamming distance from the sign\n+ */\n+template <typename B = int32_t>\n+size_t hamming_distance_seq(const B *in, const unsigned size);\n+\n+/*\n+ * compute the Hamming distance between the arrays 'in' and a all zero word of length 'size'\n+ * Operations are optimized with MIPP except for AVX architecture that call hamming_distance_seq.\n+ * when B is a floating point type then compute the hamming distance from the sign\n+ */\n+template <typename B = int32_t>\n+size_t hamming_distance(const B *in, const unsigned size);\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add hamming distance with floating point and with only one frame compared to a all zero word
|
8,483 |
04.04.2018 16:41:47
| -7,200 |
f6d73cdc031a0fb3765b5294804b546a7c676622
|
Optimize channel optical by getting vals at one time
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/Optical/Channel_optical.cpp",
"new_path": "src/Module/Channel/Optical/Channel_optical.cpp",
"diff": "#include <algorithm>\n#include \"Tools/Exception/exception.hpp\"\n+#include \"Tools/Perf/common/hamming_distance.h\"\n#include \"Channel_optical.hpp\"\n@@ -13,7 +14,9 @@ Channel_optical<R>\nconst R ROP, const int n_frames)\n: Channel<R>(N, ROP, n_frames),\nnoise_generator_p0(noise_generator_p0),\n- noise_generator_p1(noise_generator_p1)\n+ noise_generator_p1(noise_generator_p1),\n+ gene_noise0(this->N),\n+ gene_noise1(this->N)\n{\nconst std::string name = \"Channel_optical\";\nthis->set_name(name);\n@@ -40,16 +43,23 @@ void Channel_optical<R>\nthis->sigma = ROP;\n}\n+\ntemplate <typename R>\nvoid Channel_optical<R>\n::_add_noise(const R *X_N, R *Y_N, const int frame_id)\n{\n+ auto n1 = tools::hamming_distance(X_N, this->N); // number of 1 in the frame\n+\n+ noise_generator_p1->generate(this->gene_noise1.data(), n1, this->sigma);\n+ noise_generator_p0->generate(this->gene_noise0.data(), this->N - n1, this->sigma);\n+\n+ unsigned idx0 = 0, idx1 = 0;\nfor (auto n = 0; n < this->N; n++)\n{\nif (X_N[n])\n- noise_generator_p1->generate(&this->noise[frame_id * this->N + n], 1, this->sigma);\n+ this->noise[frame_id * this->N + n] = this->gene_noise1[idx1++];\nelse\n- noise_generator_p0->generate(&this->noise[frame_id * this->N + n], 1, this->sigma);\n+ this->noise[frame_id * this->N + n] = this->gene_noise0[idx0++];\nY_N[n] = this->noise[frame_id * this->N + n];\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/Optical/Channel_optical.hpp",
"new_path": "src/Module/Channel/Optical/Channel_optical.hpp",
"diff": "@@ -22,6 +22,9 @@ protected:\ntools::Noise_generator<R> *noise_generator_p0;\ntools::Noise_generator<R> *noise_generator_p1;\n+ std::vector<R> gene_noise0;\n+ std::vector<R> gene_noise1;\n+\npublic:\nChannel_optical(const int N,\ntools::Noise_generator<R> *noise_generator_p0,\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Optimize channel optical by getting vals at one time
|
8,483 |
05.04.2018 10:21:25
| -7,200 |
afa62eff83593a7819feeedf9dc64733b9b5e3c6
|
Add commands in readme and increase the default gui window size
|
[
{
"change_type": "MODIFY",
"old_path": "scripts/gui/aff3ct_gui.py",
"new_path": "scripts/gui/aff3ct_gui.py",
"diff": "@@ -131,7 +131,7 @@ class aff3ctGui(QTabWidget):\n# create our window\nself.setWindowTitle(title)\n- self.resize(500, 300)\n+ self.resize(1000, 800)\naff3ctRoot = \"../../build\";\naff3ctBinary = \"bin/aff3ct\";\n"
},
{
"change_type": "MODIFY",
"old_path": "scripts/gui/readme.md",
"new_path": "scripts/gui/readme.md",
"diff": "To launch the AFF3CT GUI, run __aff3ct_gui.py__ with python3.\n+\n+ python3 aff3ct_gui.py\n+\n+You need PyQt5:\n+\n+ sudo apt install python3-pyqt5\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add commands in readme and increase the default gui window size
|
8,483 |
05.04.2018 10:29:49
| -7,200 |
0f5462bf50228e630909d640074acf91ae26644f
|
Set also the OOK as a not complex modulation
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Modem/Modem.cpp",
"new_path": "src/Factory/Module/Modem/Modem.cpp",
"diff": "@@ -175,7 +175,7 @@ void Modem::parameters\nif(vals.exist({p+\"-cpm-map\" })) this->mapping = vals.at ({p+\"-cpm-map\" });\nif(vals.exist({p+\"-cpm-ws\" })) this->wave_shape = vals.at ({p+\"-cpm-ws\" });\n- if (this->type.find(\"BPSK\") != std::string::npos || this->type == \"PAM\")\n+ if (this->type.find(\"BPSK\") != std::string::npos || this->type == \"PAM\" || this->type == \"OOK\")\nthis->complex = false;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Set also the OOK as a not complex modulation
|
8,483 |
05.04.2018 11:14:04
| -7,200 |
a5b981dd9cc2cb759e41445b8e39abf3aba57392
|
Separate CRC.hpp into two files (.hxx)
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/CRC/CRC.hpp",
"new_path": "src/Module/CRC/CRC.hpp",
"diff": "#include <string>\n#include <vector>\n-#include <sstream>\n-\n-#include \"Tools/Exception/exception.hpp\"\n#include \"Module/Module.hpp\"\n@@ -59,71 +56,21 @@ public:\n* \\param n_frames: number of frames to process in the CRC.\n* \\param name: CRC's name.\n*/\n- CRC(const int K, const int size, const int n_frames = 1)\n- : Module(n_frames), K(K), size(size)\n- {\n- const std::string name = \"CRC\";\n- this->set_name(name);\n- this->set_short_name(name);\n-\n- if (K <= 0)\n- {\n- std::stringstream message;\n- message << \"'K' has to be greater than 0 ('K' = \" << K << \").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- auto &p1 = this->create_task(\"build\");\n- auto &p1s_U_K1 = this->template create_socket_in <B>(p1, \"U_K1\", this->K * this->n_frames);\n- auto &p1s_U_K2 = this->template create_socket_out<B>(p1, \"U_K2\", (this->K + this->size) * this->n_frames);\n- this->create_codelet(p1, [this, &p1s_U_K1, &p1s_U_K2]() -> int\n- {\n- this->build(static_cast<B*>(p1s_U_K1.get_dataptr()),\n- static_cast<B*>(p1s_U_K2.get_dataptr()));\n-\n- return 0;\n- });\n-\n- auto &p2 = this->create_task(\"extract\");\n- auto &p2s_V_K1 = this->template create_socket_in <B>(p2, \"V_K1\", (this->K + this->size) * this->n_frames);\n- auto &p2s_V_K2 = this->template create_socket_out<B>(p2, \"V_K2\", this->K * this->n_frames);\n- this->create_codelet(p2, [this, &p2s_V_K1, &p2s_V_K2]() -> int\n- {\n- this->extract(static_cast<B*>(p2s_V_K1.get_dataptr()),\n- static_cast<B*>(p2s_V_K2.get_dataptr()));\n-\n- return 0;\n- });\n-\n- auto &p3 = this->create_task(\"check\");\n- auto &p3s_V_K = this->template create_socket_in<B>(p3, \"V_K\", (this->K + this->size) * this->n_frames);\n- this->create_codelet(p3, [this, &p3s_V_K]() -> int\n- {\n- return this->check(static_cast<B*>(p3s_V_K.get_dataptr())) ? 1 : 0;\n- });\n- }\n+ CRC(const int K, const int size, const int n_frames = 1);\n/*!\n* \\brief Destructor.\n*/\n- virtual ~CRC()\n- {\n- }\n+ virtual ~CRC();\n- int get_K() const\n- {\n- return this->K;\n- }\n+ int get_K() const;\n/*!\n* \\brief Gets the size of the CRC (the number of bits for the CRC signature).\n*\n* \\return the size of the CRC.\n*/\n- virtual int get_size()\n- {\n- return size;\n- }\n+ virtual int get_size();\n/*!\n* \\brief Computes and adds the CRC in the vector of information bits (the CRC bits are often put at the end of the\n@@ -133,88 +80,14 @@ public:\n* U_K.\n*/\ntemplate <class A = std::allocator<B>>\n- void build(const std::vector<B,A>& U_K1, std::vector<B,A>& U_K2, const int frame_id = -1)\n- {\n- if (this->K * this->n_frames != (int)U_K1.size())\n- {\n- std::stringstream message;\n- message << \"'U_K1.size()' has to be equal to 'K' * 'n_frames' ('U_K1.size()' = \" << U_K1.size()\n- << \", 'K' = \" << this->K << \", 'n_frames' = \" << this->n_frames << \").\";\n- throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n- }\n+ void build(const std::vector<B,A>& U_K1, std::vector<B,A>& U_K2, const int frame_id = -1);\n- if ((this->K + this->get_size()) * this->n_frames != (int)U_K2.size())\n- {\n- std::stringstream message;\n- message << \"'U_K2.size()' has to be equal to ('K' + 'get_size()') * 'n_frames' ('U_K2.size()' = \"\n- << U_K2.size() << \", 'K' = \" << this->K << \", 'get_size()' = \" << this->get_size()\n- << \", 'n_frames' = \" << this->n_frames << \").\";\n- throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- if (frame_id != -1 && frame_id >= this->n_frames)\n- {\n- std::stringstream message;\n- message << \"'frame_id' has to be equal to '-1' or to be smaller than 'n_frames' ('frame_id' = \"\n- << frame_id << \", 'n_frames' = \" << this->n_frames << \").\";\n- throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- this->build(U_K1.data(), U_K2.data(), frame_id);\n- }\n-\n- virtual void build(const B *U_K1, B *U_K2, const int frame_id = -1)\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- this->_build(U_K1 + f * this->K,\n- U_K2 + f * (this->K + this->get_size()),\n- f);\n- }\n+ virtual void build(const B *U_K1, B *U_K2, const int frame_id = -1);\ntemplate <class A = std::allocator<B>>\n- void extract(const std::vector<B,A>& V_K1, std::vector<B,A>& V_K2, const int frame_id = -1)\n- {\n- if ((this->K + this->get_size()) * this->n_frames != (int)V_K1.size())\n- {\n- std::stringstream message;\n- message << \"'V_K1.size()' has to be equal to ('K' + 'get_size()') * 'n_frames' ('V_K1.size()' = \"\n- << V_K1.size() << \", 'K' = \" << this->K << \", 'get_size()' = \" << this->get_size()\n- << \", 'n_frames' = \" << this->n_frames << \").\";\n- throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n- }\n+ void extract(const std::vector<B,A>& V_K1, std::vector<B,A>& V_K2, const int frame_id = -1);\n- if (this->K * this->n_frames != (int)V_K2.size())\n- {\n- std::stringstream message;\n- message << \"'V_K2.size()' has to be equal to 'K' * 'n_frames' ('V_K2.size()' = \" << V_K2.size()\n- << \", 'K' = \" << this->K << \", 'n_frames' = \" << this->n_frames << \").\";\n- throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- if (frame_id != -1 && frame_id >= this->n_frames)\n- {\n- std::stringstream message;\n- message << \"'frame_id' has to be equal to '-1' or to be smaller than 'n_frames' ('frame_id' = \"\n- << frame_id << \", 'n_frames' = \" << this->n_frames << \").\";\n- throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- this->extract(V_K1.data(), V_K2.data(), frame_id);\n- }\n-\n- virtual void extract(const B *V_K1, B *V_K2, const int frame_id = -1)\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- this->_extract(V_K1 + f * (this->K + this->get_size()),\n- V_K2 + f * this->K,\n- f);\n- }\n+ virtual void extract(const B *V_K1, B *V_K2, const int frame_id = -1);\n/*!\n* \\brief Checks if the CRC is verified or not.\n@@ -226,49 +99,9 @@ public:\n* \\return true if the CRC is verified, false otherwise.\n*/\ntemplate <class A = std::allocator<B>>\n- bool check(const std::vector<B,A>& V_K, const int n_frames = -1, const int frame_id = -1)\n- {\n- if (n_frames <= 0 && n_frames != -1)\n- {\n- std::stringstream message;\n- message << \"'n_frames' has to be greater than 0 or equal to -1 ('n_frames' = \" << n_frames << \").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- if (frame_id != -1 && frame_id >= (n_frames ? n_frames : this->n_frames))\n- {\n- std::stringstream message;\n- message << \"'frame_id' has to be equal to '-1' or to be smaller than 'n_frames' ('frame_id' = \"\n- << frame_id << \", 'n_frames' = \" << (n_frames ? n_frames : this->n_frames) << \").\";\n- throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- if ((this->K + (int)this->get_size()) * n_frames != (int)V_K.size() &&\n- (this->K + (int)this->get_size()) * this->n_frames != (int)V_K.size())\n- {\n- std::stringstream message;\n- message << \"'V_K.size()' has to be equal to ('K' + 'size') * 'n_frames' ('V_K.size()' = \" << V_K.size()\n- << \", 'K' = \" << this->K\n- << \", 'n_frames' = \" << (n_frames != -1 ? n_frames : this->n_frames) << \").\";\n- throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- return this->check(V_K.data(), n_frames, frame_id);\n- }\n-\n- virtual bool check(const B *V_K, const int n_frames = -1, const int frame_id = -1)\n- {\n- const int real_n_frames = (n_frames != -1) ? n_frames : this->n_frames;\n-\n- const auto f_start = (frame_id < 0) ? 0 : frame_id % real_n_frames;\n- const auto f_stop = (frame_id < 0) ? real_n_frames : f_start +1;\n+ bool check(const std::vector<B,A>& V_K, const int n_frames = -1, const int frame_id = -1);\n- auto f = f_start;\n- while (f < f_stop && this->_check(V_K + f * (this->K + this->get_size()), f))\n- f++;\n-\n- return f == f_stop;\n- }\n+ virtual bool check(const B *V_K, const int n_frames = -1, const int frame_id = -1);\n/*!\n* \\brief Checks if the CRC is verified or not (works on packed bits).\n@@ -280,74 +113,22 @@ public:\n* \\return true if the CRC is verified, false otherwise.\n*/\ntemplate <class A = std::allocator<B>>\n- bool check_packed(const std::vector<B,A>& V_K, const int n_frames = -1, const int frame_id = -1)\n- {\n- if (n_frames <= 0 && n_frames != -1)\n- {\n- std::stringstream message;\n- message << \"'n_frames' has to be greater than 0 or equal to -1 ('n_frames' = \" << n_frames << \").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n+ bool check_packed(const std::vector<B,A>& V_K, const int n_frames = -1, const int frame_id = -1);\n- if (frame_id != -1 && frame_id >= (n_frames ? n_frames : this->n_frames))\n- {\n- std::stringstream message;\n- message << \"'frame_id' has to be equal to '-1' or to be smaller than 'n_frames' ('frame_id' = \"\n- << frame_id << \", 'n_frames' = \" << (n_frames ? n_frames : this->n_frames) << \").\";\n- throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- if ((this->K + (int)this->get_size()) * n_frames != (int)V_K.size() &&\n- (this->K + (int)this->get_size()) * this->n_frames != (int)V_K.size())\n- {\n- std::stringstream message;\n- message << \"'V_K.size()' has to be equal to ('K' + 'size') * 'n_frames' ('V_K.size()' = \" << V_K.size()\n- << \", 'K' = \" << this->K\n- << \", 'n_frames' = \" << (n_frames != -1 ? n_frames : this->n_frames) << \").\";\n- throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- return this->check_packed(V_K.data(), n_frames, frame_id);\n- }\n-\n- bool check_packed(const B *V_K, const int n_frames = -1, const int frame_id = -1)\n- {\n- const int real_n_frames = (n_frames != -1) ? n_frames : this->n_frames;\n-\n- const auto f_start = (frame_id < 0) ? 0 : frame_id % real_n_frames;\n- const auto f_stop = (frame_id < 0) ? real_n_frames : f_start +1;\n-\n- auto f = f_start;\n- while (f < f_stop && this->_check_packed(V_K + f * (this->K + this->get_size()), f))\n- f++;\n-\n- return f == f_stop;\n- }\n+ bool check_packed(const B *V_K, const int n_frames = -1, const int frame_id = -1);\nprotected:\n- virtual void _build(const B *U_K1, B *U_K2, const int frame_id)\n- {\n- throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n- }\n+ virtual void _build(const B *U_K1, B *U_K2, const int frame_id);\n- virtual void _extract(const B *V_K1, B *V_K2, const int frame_id)\n- {\n- throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n- }\n+ virtual void _extract(const B *V_K1, B *V_K2, const int frame_id);\n- virtual bool _check(const B *V_K, const int frame_id)\n- {\n- throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n- return false;\n- }\n+ virtual bool _check(const B *V_K, const int frame_id);\n- virtual bool _check_packed(const B *V_K, const int frame_id)\n- {\n- throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n- return false;\n- }\n+ virtual bool _check_packed(const B *V_K, const int frame_id);\n};\n}\n}\n+#include \"CRC.hxx\"\n+\n#endif\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/CRC/CRC.hxx",
"diff": "+/*!\n+ * \\file\n+ * \\brief Adds/builds and checks a Cyclic Redundancy Check (CRC) for a set of information bits.\n+ *\n+ * \\section LICENSE\n+ * This file is under MIT license (https://opensource.org/licenses/MIT).\n+ */\n+#ifndef CRC_HXX_\n+#define CRC_HXX_\n+\n+#include <sstream>\n+\n+#include \"Tools/Exception/exception.hpp\"\n+\n+#include \"CRC.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+\n+template <typename B>\n+CRC<B>::\n+CRC(const int K, const int size, const int n_frame)\n+: Module(n_frames), K(K), size(size)\n+{\n+ const std::string name = \"CRC\";\n+ this->set_name(name);\n+ this->set_short_name(name);\n+\n+ if (K <= 0)\n+ {\n+ std::stringstream message;\n+ message << \"'K' has to be greater than 0 ('K' = \" << K << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ auto &p1 = this->create_task(\"build\");\n+ auto &p1s_U_K1 = this->template create_socket_in <B>(p1, \"U_K1\", this->K * this->n_frames);\n+ auto &p1s_U_K2 = this->template create_socket_out<B>(p1, \"U_K2\", (this->K + this->size) * this->n_frames);\n+ this->create_codelet(p1, [this, &p1s_U_K1, &p1s_U_K2]() -> int\n+ {\n+ this->build(static_cast<B*>(p1s_U_K1.get_dataptr()),\n+ static_cast<B*>(p1s_U_K2.get_dataptr()));\n+\n+ return 0;\n+ });\n+\n+ auto &p2 = this->create_task(\"extract\");\n+ auto &p2s_V_K1 = this->template create_socket_in <B>(p2, \"V_K1\", (this->K + this->size) * this->n_frames);\n+ auto &p2s_V_K2 = this->template create_socket_out<B>(p2, \"V_K2\", this->K * this->n_frames);\n+ this->create_codelet(p2, [this, &p2s_V_K1, &p2s_V_K2]() -> int\n+ {\n+ this->extract(static_cast<B*>(p2s_V_K1.get_dataptr()),\n+ static_cast<B*>(p2s_V_K2.get_dataptr()));\n+\n+ return 0;\n+ });\n+\n+ auto &p3 = this->create_task(\"check\");\n+ auto &p3s_V_K = this->template create_socket_in<B>(p3, \"V_K\", (this->K + this->size) * this->n_frames);\n+ this->create_codelet(p3, [this, &p3s_V_K]() -> int\n+ {\n+ return this->check(static_cast<B*>(p3s_V_K.get_dataptr())) ? 1 : 0;\n+ });\n+}\n+\n+\n+template <typename B>\n+CRC<B>::\n+~CRC()\n+{\n+}\n+\n+template <typename B>\n+int CRC<B>::\n+get_K() const\n+{\n+ return this->K;\n+}\n+\n+\n+template <typename B>\n+int CRC<B>::\n+get_size()\n+{\n+ return size;\n+}\n+\n+\n+template <typename B>\n+template <class A>\n+void CRC<B>::\n+build(const std::vector<B,A>& U_K1, std::vector<B,A>& U_K2, const int frame_id)\n+{\n+ if (this->K * this->n_frames != (int)U_K1.size())\n+ {\n+ std::stringstream message;\n+ message << \"'U_K1.size()' has to be equal to 'K' * 'n_frames' ('U_K1.size()' = \" << U_K1.size()\n+ << \", 'K' = \" << this->K << \", 'n_frames' = \" << this->n_frames << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if ((this->K + this->get_size()) * this->n_frames != (int)U_K2.size())\n+ {\n+ std::stringstream message;\n+ message << \"'U_K2.size()' has to be equal to ('K' + 'get_size()') * 'n_frames' ('U_K2.size()' = \"\n+ << U_K2.size() << \", 'K' = \" << this->K << \", 'get_size()' = \" << this->get_size()\n+ << \", 'n_frames' = \" << this->n_frames << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (frame_id != -1 && frame_id >= this->n_frames)\n+ {\n+ std::stringstream message;\n+ message << \"'frame_id' has to be equal to '-1' or to be smaller than 'n_frames' ('frame_id' = \"\n+ << frame_id << \", 'n_frames' = \" << this->n_frames << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ this->build(U_K1.data(), U_K2.data(), frame_id);\n+}\n+\n+template <typename B>\n+void CRC<B>::\n+build(const B *U_K1, B *U_K2, const int frame_id)\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+ this->_build(U_K1 + f * this->K,\n+ U_K2 + f * (this->K + this->get_size()),\n+ f);\n+}\n+\n+template <typename B>\n+template <class A>\n+void CRC<B>::\n+extract(const std::vector<B,A>& V_K1, std::vector<B,A>& V_K2, const int frame_id)\n+{\n+ if ((this->K + this->get_size()) * this->n_frames != (int)V_K1.size())\n+ {\n+ std::stringstream message;\n+ message << \"'V_K1.size()' has to be equal to ('K' + 'get_size()') * 'n_frames' ('V_K1.size()' = \"\n+ << V_K1.size() << \", 'K' = \" << this->K << \", 'get_size()' = \" << this->get_size()\n+ << \", 'n_frames' = \" << this->n_frames << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (this->K * this->n_frames != (int)V_K2.size())\n+ {\n+ std::stringstream message;\n+ message << \"'V_K2.size()' has to be equal to 'K' * 'n_frames' ('V_K2.size()' = \" << V_K2.size()\n+ << \", 'K' = \" << this->K << \", 'n_frames' = \" << this->n_frames << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (frame_id != -1 && frame_id >= this->n_frames)\n+ {\n+ std::stringstream message;\n+ message << \"'frame_id' has to be equal to '-1' or to be smaller than 'n_frames' ('frame_id' = \"\n+ << frame_id << \", 'n_frames' = \" << this->n_frames << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ this->extract(V_K1.data(), V_K2.data(), frame_id);\n+}\n+\n+template <typename B>\n+void CRC<B>::\n+extract(const B *V_K1, B *V_K2, const int frame_id)\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+ this->_extract(V_K1 + f * (this->K + this->get_size()),\n+ V_K2 + f * this->K,\n+ f);\n+}\n+\n+\n+template <typename B>\n+template <class A>\n+bool CRC<B>::\n+check(const std::vector<B,A>& V_K, const int n_frames, const int frame_id)\n+{\n+ if (n_frames <= 0 && n_frames != -1)\n+ {\n+ std::stringstream message;\n+ message << \"'n_frames' has to be greater than 0 or equal to -1 ('n_frames' = \" << n_frames << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (frame_id != -1 && frame_id >= (n_frames ? n_frames : this->n_frames))\n+ {\n+ std::stringstream message;\n+ message << \"'frame_id' has to be equal to '-1' or to be smaller than 'n_frames' ('frame_id' = \"\n+ << frame_id << \", 'n_frames' = \" << (n_frames ? n_frames : this->n_frames) << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if ((this->K + (int)this->get_size()) * n_frames != (int)V_K.size() &&\n+ (this->K + (int)this->get_size()) * this->n_frames != (int)V_K.size())\n+ {\n+ std::stringstream message;\n+ message << \"'V_K.size()' has to be equal to ('K' + 'size') * 'n_frames' ('V_K.size()' = \" << V_K.size()\n+ << \", 'K' = \" << this->K\n+ << \", 'n_frames' = \" << (n_frames != -1 ? n_frames : this->n_frames) << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ return this->check(V_K.data(), n_frames, frame_id);\n+}\n+\n+template <typename B>\n+bool CRC<B>::\n+check(const B *V_K, const int n_frames, const int frame_id)\n+{\n+ const int real_n_frames = (n_frames != -1) ? n_frames : this->n_frames;\n+\n+ const auto f_start = (frame_id < 0) ? 0 : frame_id % real_n_frames;\n+ const auto f_stop = (frame_id < 0) ? real_n_frames : f_start +1;\n+\n+ auto f = f_start;\n+ while (f < f_stop && this->_check(V_K + f * (this->K + this->get_size()), f))\n+ f++;\n+\n+ return f == f_stop;\n+}\n+\n+template <typename B>\n+template <class A>\n+bool CRC<B>::\n+check_packed(const std::vector<B,A>& V_K, const int n_frames, const int frame_id)\n+{\n+ if (n_frames <= 0 && n_frames != -1)\n+ {\n+ std::stringstream message;\n+ message << \"'n_frames' has to be greater than 0 or equal to -1 ('n_frames' = \" << n_frames << \").\";\n+ throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if (frame_id != -1 && frame_id >= (n_frames ? n_frames : this->n_frames))\n+ {\n+ std::stringstream message;\n+ message << \"'frame_id' has to be equal to '-1' or to be smaller than 'n_frames' ('frame_id' = \"\n+ << frame_id << \", 'n_frames' = \" << (n_frames ? n_frames : this->n_frames) << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ if ((this->K + (int)this->get_size()) * n_frames != (int)V_K.size() &&\n+ (this->K + (int)this->get_size()) * this->n_frames != (int)V_K.size())\n+ {\n+ std::stringstream message;\n+ message << \"'V_K.size()' has to be equal to ('K' + 'size') * 'n_frames' ('V_K.size()' = \" << V_K.size()\n+ << \", 'K' = \" << this->K\n+ << \", 'n_frames' = \" << (n_frames != -1 ? n_frames : this->n_frames) << \").\";\n+ throw tools::length_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ return this->check_packed(V_K.data(), n_frames, frame_id);\n+}\n+\n+template <typename B>\n+bool CRC<B>::\n+check_packed(const B *V_K, const int n_frames, const int frame_id)\n+{\n+ const int real_n_frames = (n_frames != -1) ? n_frames : this->n_frames;\n+\n+ const auto f_start = (frame_id < 0) ? 0 : frame_id % real_n_frames;\n+ const auto f_stop = (frame_id < 0) ? real_n_frames : f_start +1;\n+\n+ auto f = f_start;\n+ while (f < f_stop && this->_check_packed(V_K + f * (this->K + this->get_size()), f))\n+ f++;\n+\n+ return f == f_stop;\n+}\n+\n+template <typename B>\n+void CRC<B>::\n+_build(const B *U_K1, B *U_K2, const int frame_id)\n+{\n+ throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n+}\n+\n+template <typename B>\n+void CRC<B>::\n+_extract(const B *V_K1, B *V_K2, const int frame_id)\n+{\n+ throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n+}\n+\n+template <typename B>\n+bool CRC<B>::\n+_check(const B *V_K, const int frame_id)\n+{\n+ throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n+ return false;\n+}\n+\n+template <typename B>\n+bool CRC<B>::\n+_check_packed(const B *V_K, const int frame_id)\n+{\n+ throw tools::unimplemented_error(__FILE__, __LINE__, __func__);\n+ return false;\n+}\n+\n+}\n+}\n+\n+#endif\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Separate CRC.hpp into two files (.hxx)
|
8,483 |
05.04.2018 13:19:02
| -7,200 |
613d1575be04bab2cbdf7a4a3261956b5d3a98e0
|
Apply cppcheck style messages
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Monitor/BFER/Monitor_BFER_reduction.hpp",
"new_path": "src/Module/Monitor/BFER/Monitor_BFER_reduction.hpp",
"diff": "@@ -18,7 +18,7 @@ private:\nstd::vector<Monitor_BFER<B>*> monitors;\npublic:\n- Monitor_BFER_reduction(const std::vector<Monitor_BFER<B>*> &monitors);\n+ explicit Monitor_BFER_reduction(const std::vector<Monitor_BFER<B>*> &monitors);\nvirtual ~Monitor_BFER_reduction();\nunsigned long long get_n_analyzed_fra_historic() const;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/LDPC/Standard/DVBS2/DVBS2_constants.cpp",
"new_path": "src/Tools/Code/LDPC/Standard/DVBS2/DVBS2_constants.cpp",
"diff": "@@ -17,11 +17,11 @@ Sparse_matrix aff3ct::tools::build_H(const dvbs2_values& dvbs2)\nSparse_matrix H(dvbs2.N, dvbs2.NmK);\nconst int *p = dvbs2.EncValues.data();\n- int xPos = 0, yPos, nbPos;\n+ int xPos = 0, yPos;\nfor (int y = 0; y < dvbs2.N_LINES; y++)\n{\n- nbPos = (*p++);\n+ int nbPos = (*p++);\nfor (int l = 0; l < dvbs2.M; l++)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/main.cpp",
"new_path": "src/main.cpp",
"diff": "@@ -138,7 +138,7 @@ int sc_main(int argc, char **argv)\ntry\n{\n- launcher::Launcher *launcher = nullptr;\n+ launcher::Launcher *launcher;\n#ifdef MULTI_PREC\nswitch (params.sim_prec)\n{\n@@ -148,7 +148,7 @@ int sc_main(int argc, char **argv)\n#if defined(__x86_64) || defined(__x86_64__) || defined(_WIN64) || defined(__aarch64__)\ncase 64: launcher = factory::Launcher::build<B_64,R_64,Q_64>(params, argc, (const char**)argv); break;\n#endif\n- default: break;\n+ default: launcher = nullptr; break;\n}\n#else\nlauncher = factory::Launcher::build<B,R,Q>(params, argc, (const char**)argv);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Apply cppcheck style messages
|
8,483 |
05.04.2018 13:19:44
| -7,200 |
1984b0898907cb9530cade4a151e33b753e52321
|
Implement templated methods of Module in a .hxx instead of a .cpp
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Module.cpp",
"new_path": "src/Module/Module.cpp",
"diff": "@@ -96,27 +96,6 @@ create_task(const std::string &name, const int id)\nreturn *t;\n}\n-template <typename T>\n-Socket& Module::\n-create_socket_in(Task& task, const std::string &name, const size_t n_elmts)\n-{\n- return task.template create_socket_in<T>(name, n_elmts);\n-}\n-\n-template <typename T>\n-Socket& Module::\n-create_socket_in_out(Task& task, const std::string &name, const size_t n_elmts)\n-{\n- return task.template create_socket_in_out<T>(name, n_elmts);\n-}\n-\n-template <typename T>\n-Socket& Module::\n-create_socket_out(Task& task, const std::string &name, const size_t n_elmts)\n-{\n- return task.template create_socket_out<T>(name, n_elmts);\n-}\n-\nvoid Module::\ncreate_codelet(Task& task, std::function<int(void)> codelet)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Module.hpp",
"new_path": "src/Module/Module.hpp",
"diff": "@@ -94,5 +94,6 @@ protected:\n};\n}\n}\n+#include \"Module.hxx\"\n#endif /* MODULE_HPP_ */\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Module.hxx",
"diff": "+#ifndef MODULE_HXX_\n+#define MODULE_HXX_\n+\n+#include <sstream>\n+\n+#include \"Tools/Exception/exception.hpp\"\n+\n+#include \"Module.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+\n+template <typename T>\n+inline Socket& Module::\n+create_socket_in(Task& task, const std::string &name, const size_t n_elmts)\n+{\n+ return task.template create_socket_in<T>(name, n_elmts);\n+}\n+\n+template <typename T>\n+inline Socket& Module::\n+create_socket_in_out(Task& task, const std::string &name, const size_t n_elmts)\n+{\n+ return task.template create_socket_in_out<T>(name, n_elmts);\n+}\n+\n+template <typename T>\n+inline Socket& Module::\n+create_socket_out(Task& task, const std::string &name, const size_t n_elmts)\n+{\n+ return task.template create_socket_out<T>(name, n_elmts);\n+}\n+\n+}\n+}\n+#endif\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Implement templated methods of Module in a .hxx instead of a .cpp
|
8,483 |
05.04.2018 15:24:01
| -7,200 |
75adf2e6e44bcc6e3e3e65b507516b2d33391058
|
Add is_complex_mod and is_complex_fil static methods to all Modems to get their complex status
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Modem/Modem.cpp",
"new_path": "src/Factory/Module/Modem/Modem.cpp",
"diff": "@@ -175,10 +175,6 @@ void Modem::parameters\nif(vals.exist({p+\"-cpm-map\" })) this->mapping = vals.at ({p+\"-cpm-map\" });\nif(vals.exist({p+\"-cpm-ws\" })) this->wave_shape = vals.at ({p+\"-cpm-ws\" });\n- if (this->type.find(\"BPSK\") != std::string::npos || this->type == \"PAM\" || this->type == \"OOK\")\n- this->complex = false;\n-\n-\n// force the number of bits per symbol to 1 when BPSK mod\nif (this->type == \"BPSK\" || this->type == \"BPSK_FAST\" || this->type == \"OOK\")\nthis->bps = 1;\n@@ -186,6 +182,8 @@ void Modem::parameters\nif (this->type == \"SCMA\")\nthis->bps = 3;\n+ this->complex = is_complex_mod(this->type, this->bps);\n+\nthis->N_mod = get_buffer_size_after_modulation(this->type,\nthis->N,\nthis->bps,\n@@ -348,6 +346,38 @@ int Modem\nthrow tools::cannot_allocate(__FILE__, __LINE__, __func__);\n}\n+bool Modem\n+::is_complex_mod(const std::string &type, const int bps)\n+{\n+ if (type == \"BPSK\" ) return module::Modem_BPSK <>::is_complex_mod();\n+ else if (type == \"BPSK_FAST\") return module::Modem_BPSK_fast<>::is_complex_mod();\n+ else if (type == \"OOK\" ) return module::Modem_OOK <>::is_complex_mod();\n+ else if (type == \"SCMA\" ) return module::Modem_SCMA <>::is_complex_mod();\n+ else if (type == \"PAM\" ) return module::Modem_PAM <>::is_complex_mod();\n+ else if (type == \"QAM\" ) return module::Modem_QAM <>::is_complex_mod();\n+ else if (type == \"PSK\" ) return module::Modem_PSK <>::is_complex_mod();\n+ else if (type == \"USER\" ) return module::Modem_user <>::is_complex_mod();\n+ else if (type == \"CPM\" ) return module::Modem_CPM <>::is_complex_mod();\n+\n+ throw tools::cannot_allocate(__FILE__, __LINE__, __func__);\n+}\n+\n+bool Modem\n+::is_complex_fil(const std::string &type, const int bps)\n+{\n+ if (type == \"BPSK\" ) return module::Modem_BPSK <>::is_complex_fil();\n+ else if (type == \"BPSK_FAST\") return module::Modem_BPSK_fast<>::is_complex_fil();\n+ else if (type == \"OOK\" ) return module::Modem_OOK <>::is_complex_fil();\n+ else if (type == \"SCMA\" ) return module::Modem_SCMA <>::is_complex_fil();\n+ else if (type == \"PAM\" ) return module::Modem_PAM <>::is_complex_fil();\n+ else if (type == \"QAM\" ) return module::Modem_QAM <>::is_complex_fil();\n+ else if (type == \"PSK\" ) return module::Modem_PSK <>::is_complex_fil();\n+ else if (type == \"USER\" ) return module::Modem_user <>::is_complex_fil();\n+ else if (type == \"CPM\" ) return module::Modem_CPM <>::is_complex_fil();\n+\n+ throw tools::cannot_allocate(__FILE__, __LINE__, __func__);\n+}\n+\n// ==================================================================================== explicit template instantiation\n#include \"Tools/types.h\"\n#ifdef MULTI_PREC\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Modem/Modem.hpp",
"new_path": "src/Factory/Module/Modem/Modem.hpp",
"diff": "@@ -77,6 +77,9 @@ struct Modem : public Factory\ntemplate <typename B = int, typename R = float, typename Q = R>\nstatic module::Modem<B,R,Q>* build(const parameters ¶ms);\n+ static bool is_complex_mod(const std::string &type, const int bps = 1);\n+ static bool is_complex_fil(const std::string &type, const int bps = 1);\n+\nstatic int get_buffer_size_after_modulation(const std::string &type,\nconst int N,\nconst int bps = 1,\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/BPSK/Modem_BPSK.hpp",
"new_path": "src/Module/Modem/BPSK/Modem_BPSK.hpp",
"diff": "@@ -20,14 +20,24 @@ public:\nvoid set_sigma(const R sigma);\n+ static bool is_complex_mod()\n+ {\n+ return false;\n+ }\n+\n+ static bool is_complex_fil()\n+ {\n+ return false;\n+ }\n+\nstatic int size_mod(const int N)\n{\n- return Modem<B,R,Q>::get_buffer_size_after_modulation(N, 1, 0, 1, false);\n+ return Modem<B,R,Q>::get_buffer_size_after_modulation(N, 1, 0, 1, is_complex_mod());\n}\nstatic int size_fil(const int N)\n{\n- return Modem<B,R,Q>::get_buffer_size_after_filtering(N, 1, 0, 1, false);\n+ return Modem<B,R,Q>::get_buffer_size_after_filtering(N, 1, 0, 1, is_complex_fil());\n}\nprotected:\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": "@@ -20,14 +20,24 @@ public:\nvoid set_sigma(const R sigma);\n+ static bool is_complex_mod()\n+ {\n+ return false;\n+ }\n+\n+ static bool is_complex_fil()\n+ {\n+ return false;\n+ }\n+\nstatic int size_mod(const int N)\n{\n- return Modem<B,R,Q>::get_buffer_size_after_modulation(N, 1, 0, 1, false);\n+ return Modem<B,R,Q>::get_buffer_size_after_modulation(N, 1, 0, 1, is_complex_mod());\n}\nstatic int size_fil(const int N)\n{\n- return Modem<B,R,Q>::get_buffer_size_after_filtering(N, 1, 0, 1, false);\n+ return Modem<B,R,Q>::get_buffer_size_after_filtering(N, 1, 0, 1, is_complex_fil());\n}\nprotected:\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/CPM/Modem_CPM.hpp",
"new_path": "src/Module/Modem/CPM/Modem_CPM.hpp",
"diff": "@@ -61,12 +61,22 @@ public:\nvoid set_sigma(const R sigma);\n+ static bool is_complex_mod()\n+ {\n+ return true;\n+ }\n+\n+ static bool is_complex_fil()\n+ {\n+ return false;\n+ }\n+\nstatic int size_mod(const int N, const int bps, const int L, const int p, const int ups)\n{\nint m_order = (int)1 << bps;\nint n_tl = (int)(std::ceil((float)(p - 1) / (float)(m_order - 1))) + L - 1;\n- return Modem<B,R,Q>::get_buffer_size_after_modulation(N, bps, n_tl, ups, true);\n+ return Modem<B,R,Q>::get_buffer_size_after_modulation(N, bps, n_tl, ups, is_complex_mod());\n}\nstatic int size_fil(const int N, const int bps, const int L, const int p)\n@@ -77,7 +87,7 @@ public:\nint n_bits_wa = (int)std::ceil(std::log2(n_wa));\nint max_wa_id = (int)(1 << n_bits_wa);\n- return Modem<B,R,Q>::get_buffer_size_after_filtering(N, bps, n_tl, max_wa_id, false);\n+ return Modem<B,R,Q>::get_buffer_size_after_filtering(N, bps, n_tl, max_wa_id, is_complex_fil());\n}\nprotected:\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/OOK/Modem_OOK.hpp",
"new_path": "src/Module/Modem/OOK/Modem_OOK.hpp",
"diff": "@@ -20,14 +20,24 @@ public:\nvoid set_sigma(const R sigma);\n+ static bool is_complex_mod()\n+ {\n+ return false;\n+ }\n+\n+ static bool is_complex_fil()\n+ {\n+ return false;\n+ }\n+\nstatic int size_mod(const int N)\n{\n- return Modem<B,R,Q>::get_buffer_size_after_modulation(N, 1, 0, 1, false);\n+ return Modem<B,R,Q>::get_buffer_size_after_modulation(N, 1, 0, 1, is_complex_mod());\n}\nstatic int size_fil(const int N)\n{\n- return Modem<B,R,Q>::get_buffer_size_after_filtering(N, 1, 0, 1, false);\n+ return Modem<B,R,Q>::get_buffer_size_after_filtering(N, 1, 0, 1, is_complex_fil());\n}\nprotected:\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/PAM/Modem_PAM.hpp",
"new_path": "src/Module/Modem/PAM/Modem_PAM.hpp",
"diff": "@@ -29,14 +29,24 @@ public:\nvoid set_sigma(const R sigma);\n+ static bool is_complex_mod()\n+ {\n+ return false;\n+ }\n+\n+ static bool is_complex_fil()\n+ {\n+ return false;\n+ }\n+\nstatic int size_mod(const int N, const int bps)\n{\n- return Modem<B,R,Q>::get_buffer_size_after_modulation(N, bps, 0, 1, false);\n+ return Modem<B,R,Q>::get_buffer_size_after_modulation(N, bps, 0, 1, is_complex_mod());\n}\nstatic int size_fil(const int N, const int bps)\n{\n- return Modem<B,R,Q>::get_buffer_size_after_filtering(N, bps, 0, 1, false);\n+ return Modem<B,R,Q>::get_buffer_size_after_filtering(N, bps, 0, 1, is_complex_fil());\n}\nprotected:\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/PSK/Modem_PSK.hpp",
"new_path": "src/Module/Modem/PSK/Modem_PSK.hpp",
"diff": "@@ -29,14 +29,24 @@ public:\nvoid set_sigma(const R sigma);\n+ static bool is_complex_mod()\n+ {\n+ return true;\n+ }\n+\n+ static bool is_complex_fil()\n+ {\n+ return true;\n+ }\n+\nstatic int size_mod(const int N, const int bps)\n{\n- return Modem<B,R,Q>::get_buffer_size_after_modulation(N, bps, 0, 1, true);\n+ return Modem<B,R,Q>::get_buffer_size_after_modulation(N, bps, 0, 1, is_complex_mod());\n}\nstatic int size_fil(const int N, const int bps)\n{\n- return Modem<B,R,Q>::get_buffer_size_after_filtering(N, bps, 0, 1, true);\n+ return Modem<B,R,Q>::get_buffer_size_after_filtering(N, bps, 0, 1, is_complex_fil());\n}\nprotected:\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/QAM/Modem_QAM.hpp",
"new_path": "src/Module/Modem/QAM/Modem_QAM.hpp",
"diff": "@@ -30,14 +30,24 @@ public:\nvoid set_sigma(const R sigma);\n+ static bool is_complex_mod()\n+ {\n+ return true;\n+ }\n+\n+ static bool is_complex_fil()\n+ {\n+ return true;\n+ }\n+\nstatic int size_mod(const int N, const int bps)\n{\n- return Modem<B,R,Q>::get_buffer_size_after_modulation(N, bps, 0, 1, true);\n+ return Modem<B,R,Q>::get_buffer_size_after_modulation(N, bps, 0, 1, is_complex_mod());\n}\nstatic int size_fil(const int N, const int bps)\n{\n- return Modem<B,R,Q>::get_buffer_size_after_filtering(N, bps, 0, 1, true);\n+ return Modem<B,R,Q>::get_buffer_size_after_filtering(N, bps, 0, 1, is_complex_fil());\n}\nprotected:\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/SCMA/Modem_SCMA.hpp",
"new_path": "src/Module/Modem/SCMA/Modem_SCMA.hpp",
"diff": "@@ -35,6 +35,16 @@ public:\nvirtual void demodulate_wg(const R *H_N, const Q *Y_N1, Q *Y_N2, const int frame_id = -1); using Modem<B,R,Q>::demodulate_wg;\nvirtual void filter ( const R *Y_N1, R *Y_N2, const int frame_id = -1); using Modem<B,R,Q>::filter;\n+ static bool is_complex_mod()\n+ {\n+ return true;\n+ }\n+\n+ static bool is_complex_fil()\n+ {\n+ return true;\n+ }\n+\nstatic int size_mod(const int N, const int bps)\n{\nreturn ((int)std::pow(2,bps) * ((N +1) / 2));\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/User/Modem_user.hpp",
"new_path": "src/Module/Modem/User/Modem_user.hpp",
"diff": "@@ -31,14 +31,24 @@ public:\nvoid set_sigma(const R sigma);\n+ static bool is_complex_mod()\n+ {\n+ return true;\n+ }\n+\n+ static bool is_complex_fil()\n+ {\n+ return true;\n+ }\n+\nstatic int size_mod(const int N, const int bps)\n{\n- return Modem<B,R,Q>::get_buffer_size_after_modulation(N, bps, 0, 1, true);\n+ return Modem<B,R,Q>::get_buffer_size_after_modulation(N, bps, 0, 1, is_complex_mod());\n}\nstatic int size_fil(const int N, const int bps)\n{\n- return Modem<B,R,Q>::get_buffer_size_after_filtering(N, bps, 0, 1, true);\n+ return Modem<B,R,Q>::get_buffer_size_after_filtering(N, bps, 0, 1, is_complex_fil());\n}\nprotected:\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add is_complex_mod and is_complex_fil static methods to all Modems to get their complex status
|
8,483 |
05.04.2018 15:56:53
| -7,200 |
18fa20994599eb531c5b46ac4cb1f831da27023e
|
Check if sigma is diff than -1 to init it in Modem constructors; Add a sigma_c getter
|
[
{
"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 sigma = -1.f; // noise variance sigma\n// ------- common parameters\nint n_frames = 1;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/BPSK/Modem_BPSK.cpp",
"new_path": "src/Module/Modem/BPSK/Modem_BPSK.cpp",
"diff": "@@ -11,11 +11,13 @@ template <typename B, typename R, typename Q>\nModem_BPSK<B,R,Q>\n::Modem_BPSK(const int N, const R sigma, const bool disable_sig2, const int n_frames)\n: Modem<B,R,Q>(N, sigma, n_frames),\n- disable_sig2(disable_sig2), two_on_square_sigma((R)2.0 / (sigma * sigma))\n+ disable_sig2(disable_sig2)\n{\nconst std::string name = \"Modem_BPSK\";\nthis->set_name(name);\n+ if (sigma != (R)-1.0) set_sigma(sigma);\n+\nif (disable_sig2)\nthis->set_demodulator(false);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/BPSK/Modem_BPSK_fast.cpp",
"new_path": "src/Module/Modem/BPSK/Modem_BPSK_fast.cpp",
"diff": "@@ -12,11 +12,13 @@ template <typename B, typename R, typename Q>\nModem_BPSK_fast<B,R,Q>\n::Modem_BPSK_fast(const int N, const R sigma, const bool disable_sig2, const int n_frames)\n: Modem<B,R,Q>(N, sigma, n_frames),\n- disable_sig2(disable_sig2), two_on_square_sigma((R)2.0 / (sigma * sigma))\n+ disable_sig2(disable_sig2)\n{\nconst std::string name = \"Modem_BPSK_fast\";\nthis->set_name(name);\n+ if (sigma != (R)-1.0) set_sigma(sigma);\n+\nif (disable_sig2)\nthis->set_demodulator(false);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/Modem.hpp",
"new_path": "src/Module/Modem/Modem.hpp",
"diff": "@@ -106,6 +106,8 @@ public:\nR get_sigma() const;\n+ R get_sigma_c() const;\n+\nbool is_filter() const;\nbool is_demodulator() const;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/Modem.hxx",
"new_path": "src/Module/Modem/Modem.hxx",
"diff": "@@ -51,7 +51,16 @@ Modem(const int N, const int N_mod, const int N_fil, const R sigma, const int n_\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n+ if (sigma == (R)-1.0)\n+ {\n+ this->sigma = (R)-1.0;\n+ this->sigma_c = (R)-1.0;\n+ }\n+ else\n+ {\nthis->set_sigma(sigma);\n+ }\n+\nthis->init_processes();\n}\n@@ -78,7 +87,16 @@ Modem(const int N, const int N_mod, const R sigma, const int n_frames)\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n+ if (sigma == (R)-1.0)\n+ {\n+ this->sigma = (R)-1.0;\n+ this->sigma_c = (R)-1.0;\n+ }\n+ else\n+ {\nthis->set_sigma(sigma);\n+ }\n+\nthis->init_processes();\n}\n@@ -98,7 +116,16 @@ Modem(const int N, const R sigma, const int n_frames)\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n+ if (sigma == (R)-1.0)\n+ {\n+ this->sigma = (R)-1.0;\n+ this->sigma_c = (R)-1.0;\n+ }\n+ else\n+ {\nthis->set_sigma(sigma);\n+ }\n+\nthis->init_processes();\n}\n@@ -226,6 +253,13 @@ get_sigma() const\nreturn this->sigma;\n}\n+template <typename B, typename R, typename Q>\n+R Modem<B,R,Q>::\n+get_sigma_c() const\n+{\n+ return this->sigma_c;\n+}\n+\ntemplate <typename B, typename R, typename Q>\nbool Modem<B,R,Q>::\nis_filter() const\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/OOK/Modem_OOK.cpp",
"new_path": "src/Module/Modem/OOK/Modem_OOK.cpp",
"diff": "@@ -15,7 +15,8 @@ Modem_OOK<B,R,Q>\n{\nconst std::string name = \"Modem_OOK\";\nthis->set_name(name);\n- this->set_sigma(sigma);\n+\n+ if (sigma != (R)-1.0) this->set_sigma(sigma);\n}\ntemplate <typename B, typename R, typename Q>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/PAM/Modem_PAM.hxx",
"new_path": "src/Module/Modem/PAM/Modem_PAM.hxx",
"diff": "@@ -28,7 +28,8 @@ Modem_PAM<B,R,Q,MAX>\n{\nconst std::string name = \"Modem_PAM\";\nthis->set_name(name);\n- this->set_sigma(sigma);\n+\n+ if (sigma != (R)-1.0) this->set_sigma(sigma);\nstd::vector<B> bits(this->bits_per_symbol);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/PSK/Modem_PSK.hxx",
"new_path": "src/Module/Modem/PSK/Modem_PSK.hxx",
"diff": "@@ -29,7 +29,8 @@ Modem_PSK<B,R,Q,MAX>\n{\nconst std::string name = \"Modem_PSK\";\nthis->set_name(name);\n- this->set_sigma(sigma);\n+\n+ if (sigma != (R)-1.0) this->set_sigma(sigma);\nstd::vector<B> bits(this->bits_per_symbol);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/QAM/Modem_QAM.hxx",
"new_path": "src/Module/Modem/QAM/Modem_QAM.hxx",
"diff": "@@ -29,7 +29,8 @@ Modem_QAM<B,R,Q,MAX>\n{\nconst std::string name = \"Modem_QAM\";\nthis->set_name(name);\n- this->set_sigma(sigma);\n+\n+ if (sigma != (R)-1.0) this->set_sigma(sigma);\nif (this->bits_per_symbol % 2)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/SCMA/Modem_SCMA.hxx",
"new_path": "src/Module/Modem/SCMA/Modem_SCMA.hxx",
"diff": "@@ -65,7 +65,8 @@ Modem_SCMA<B,R,Q,PSI>\n{\nconst std::string name = \"Modem_SCMA\";\nthis->set_name(name);\n- this->set_sigma(sigma);\n+\n+ if (sigma != (R)-1.0) this->set_sigma(sigma);\nif (n_frames != 6)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/User/Modem_user.hxx",
"new_path": "src/Module/Modem/User/Modem_user.hxx",
"diff": "@@ -29,7 +29,8 @@ Modem_user<B,R,Q,MAX>\n{\nconst std::string name = \"Modem_user\";\nthis->set_name(name);\n- this->set_sigma(sigma);\n+\n+ if (sigma != (R)-1.0) this->set_sigma(sigma);\nif (const_path.empty())\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, \"'const_path' should not be empty.\");\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Check if sigma is diff than -1 to init it in Modem constructors; Add a sigma_c getter
|
8,483 |
06.04.2018 11:13:33
| -7,200 |
ea3c922442a02f968aa105aa6d7a6ec5474ad27d
|
Fix channel optical
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/Optical/Channel_optical.cpp",
"new_path": "src/Module/Channel/Optical/Channel_optical.cpp",
"diff": "#include <algorithm>\n#include \"Tools/Exception/exception.hpp\"\n-#include \"Tools/Perf/common/hamming_distance.h\"\n#include \"Channel_optical.hpp\"\n@@ -14,9 +13,7 @@ Channel_optical<R>\nconst R ROP, const int n_frames)\n: Channel<R>(N, ROP, n_frames),\nnoise_generator_p0(noise_generator_p0),\n- noise_generator_p1(noise_generator_p1),\n- gene_noise0(this->N),\n- gene_noise1(this->N)\n+ noise_generator_p1(noise_generator_p1)\n{\nconst std::string name = \"Channel_optical\";\nthis->set_name(name);\n@@ -48,20 +45,16 @@ template <typename R>\nvoid Channel_optical<R>\n::_add_noise(const R *X_N, R *Y_N, const int frame_id)\n{\n- auto n1 = tools::hamming_distance(X_N, this->N); // number of 1 in the frame\n-\n- noise_generator_p1->generate(this->gene_noise1.data(), n1, this->sigma);\n- noise_generator_p0->generate(this->gene_noise0.data(), this->N - n1, this->sigma);\n-\n- unsigned idx0 = 0, idx1 = 0;\nfor (auto n = 0; n < this->N; n++)\n{\n+ auto ptr_n = &this->noise[frame_id * this->N + n];\n+\nif (X_N[n])\n- this->noise[frame_id * this->N + n] = this->gene_noise1[idx1++];\n+ noise_generator_p1->generate(ptr_n, 1, this->sigma);\nelse\n- this->noise[frame_id * this->N + n] = this->gene_noise0[idx0++];\n+ noise_generator_p0->generate(ptr_n, 1, this->sigma);\n- Y_N[n] = this->noise[frame_id * this->N + n];\n+ Y_N[n] = *ptr_n;\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/Optical/Channel_optical.hpp",
"new_path": "src/Module/Channel/Optical/Channel_optical.hpp",
"diff": "@@ -22,9 +22,6 @@ protected:\ntools::Noise_generator<R> *noise_generator_p0;\ntools::Noise_generator<R> *noise_generator_p1;\n- std::vector<R> gene_noise0;\n- std::vector<R> gene_noise1;\n-\npublic:\nChannel_optical(const int N,\ntools::Noise_generator<R> *noise_generator_p0,\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix channel optical
|
8,483 |
06.04.2018 11:13:49
| -7,200 |
811dfb124014f7c79de7b20f4eae2b5098c81e8c
|
Optimize Modem optical modulation with mipp
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/Optical/Modem_optical.cpp",
"new_path": "src/Module/Modem/Optical/Modem_optical.cpp",
"diff": "#include <type_traits>\n#include <algorithm>\n+#include <mipp.h>\n#include \"Tools/Exception/exception.hpp\"\n@@ -48,11 +49,44 @@ template <typename B, typename R, typename Q>\nvoid Modem_optical<B,R,Q>\n::_modulate(const B *X_N1, R *X_N2, const int frame_id)\n{\n- auto size = (unsigned int)(this->N);\n- for (unsigned i = 0; i < size; i++)\n+ for (int i = 0; i < this->N; i++)\nX_N2[i] = X_N1[i] ? (R)1 : (R)0;\n}\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+template <>\n+void Modem_optical<int,float,float>\n+::_modulate(const int *X_N1, float *X_N2, const int frame_id)\n+{\n+ using B = int;\n+ using R = float;\n+\n+ unsigned size = (unsigned int)(this->N);\n+\n+ const auto vec_loop_size = (size / mipp::nElReg<B>()) * mipp::nElReg<B>();\n+ const mipp::Reg<R> Rone = (R)1.0;\n+ const mipp::Reg<R> Rzero = (R)0.0;\n+ const mipp::Reg<B> Bzero = (B)0;\n+\n+ for (unsigned i = 0; i < vec_loop_size; i += mipp::nElReg<B>())\n+ {\n+ const auto x1b = mipp::Reg<B>(&X_N1[i]);\n+ const auto x2r = mipp::blend(Rone, Rzero, x1b != Bzero);\n+ x2r.store(&X_N2[i]);\n+ }\n+\n+ for (unsigned i = vec_loop_size; i < size; i++)\n+ X_N2[i] = X_N1[i] ? (R)1 : (R)0;\n+}\n+}\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"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Optimize Modem optical modulation with mipp
|
8,483 |
06.04.2018 13:04:38
| -7,200 |
ed2156fb76041eb1748e111f97bf817c601107e6
|
Design the SNR range argument in BFER and EXIT simulations as a Matlab style range setter
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/EXIT/EXIT.cpp",
"new_path": "src/Factory/Simulation/EXIT/EXIT.cpp",
"diff": "#if !defined(PREC_8_BIT) && !defined(PREC_16_BIT)\n#include \"Simulation/EXIT/EXIT.hpp\"\n+#include \"Tools/general_utils.h\"\n#include \"EXIT.hpp\"\n@@ -86,6 +87,30 @@ std::vector<std::string> EXIT::parameters\nreturn p;\n}\n+struct sigma_range_D1_splitter : tools::Splitter\n+{\n+ static std::vector<std::string> split(const std::string& val)\n+ {\n+ const std::string head = \"{([\";\n+ const std::string queue = \"})]\";\n+ const std::string separator = \",\";\n+\n+ return Splitter::split(val, head, queue, separator);\n+ }\n+};\n+\n+struct sigma_range_D2_splitter : tools::Splitter\n+{\n+ static std::vector<std::string> split(const std::string& val)\n+ {\n+ const std::string head = \"\";\n+ const std::string queue = \"\";\n+ const std::string separator = \":\";\n+\n+ return Splitter::split(val, head, queue, separator);\n+ }\n+};\n+\nvoid EXIT::parameters\n::get_description(tools::Argument_map_info &args) const\n{\n@@ -94,21 +119,30 @@ void EXIT::parameters\nauto p = this->get_prefix();\nargs.add(\n- {p+\"-siga-min\", \"a\"},\n- tools::Real(tools::Positive()),\n- \"sigma min value used in EXIT charts.\",\n- tools::Argument_info::REQUIRED);\n-\n- args.add(\n- {p+\"-siga-max\", \"A\"},\n- tools::Real(tools::Positive()),\n- \"sigma max value used in EXIT charts.\",\n+ {p+\"-siga-range\", \"a\"},\n+ tools::List2D<float,sigma_range_D1_splitter,sigma_range_D2_splitter>(\n+ tools::Real(),\n+ std::make_tuple(tools::Length(1)),\n+ std::make_tuple(tools::Length(2,3))),\n+ \"sigma range used in EXIT charts (Matlab style: \\\"0.5:2.5,2.6:0.05:3\\\" with a default step of 0.1).\",\ntools::Argument_info::REQUIRED);\n- args.add(\n- {p+\"-siga-step\"},\n- tools::Real(tools::Positive(), tools::Non_zero()),\n- \"sigma step value used in EXIT charts.\");\n+ // args.add(\n+ // {p+\"-siga-min\", \"a\"},\n+ // tools::Real(tools::Positive()),\n+ // \"sigma min value used in EXIT charts.\",\n+ // tools::Argument_info::REQUIRED);\n+\n+ // args.add(\n+ // {p+\"-siga-max\", \"A\"},\n+ // tools::Real(tools::Positive()),\n+ // \"sigma max value used in EXIT charts.\",\n+ // tools::Argument_info::REQUIRED);\n+\n+ // args.add(\n+ // {p+\"-siga-step\"},\n+ // tools::Real(tools::Positive(), tools::Non_zero()),\n+ // \"sigma step value used in EXIT charts.\");\n}\nvoid EXIT::parameters\n@@ -118,9 +152,12 @@ void EXIT::parameters\nauto p = this->get_prefix();\n- if(vals.exist({p+\"-siga-min\", \"a\"})) this->sig_a_min = vals.to_float({p+\"-siga-min\", \"a\"});\n- if(vals.exist({p+\"-siga-max\", \"A\"})) this->sig_a_max = vals.to_float({p+\"-siga-max\", \"A\"});\n- if(vals.exist({p+\"-siga-step\" })) this->sig_a_step = vals.to_float({p+\"-siga-step\" });\n+ if(vals.exist({p+\"-siga-range\", \"a\"}))\n+ this->sig_a_range = tools::generate_range(vals.to_list<std::vector<float>>({p+\"-siga-range\", \"a\"}), 0.1f);\n+\n+ // if(vals.exist({p+\"-siga-min\", \"a\"})) this->sig_a_min = vals.to_float({p+\"-siga-min\", \"a\"});\n+ // if(vals.exist({p+\"-siga-max\", \"A\"})) this->sig_a_max = vals.to_float({p+\"-siga-max\", \"A\"});\n+ // if(vals.exist({p+\"-siga-step\" })) this->sig_a_step = vals.to_float({p+\"-siga-step\" });\n}\nvoid EXIT::parameters\n@@ -130,9 +167,13 @@ void EXIT::parameters\nauto p = this->get_prefix();\n- headers[p].push_back(std::make_pair(\"Sigma-A min (a)\", std::to_string(this->sig_a_min )));\n- headers[p].push_back(std::make_pair(\"Sigma-A max (A)\", std::to_string(this->sig_a_max )));\n- headers[p].push_back(std::make_pair(\"Sigma-A step\", std::to_string(this->sig_a_step)));\n+ std::stringstream sig_a_range_str;\n+ sig_a_range_str << this->sig_a_range.front() << \" -> \" << this->sig_a_range.back();\n+ headers[p].push_back(std::make_pair(\"Sigma-A range (a)\", sig_a_range_str.str()));\n+\n+ // headers[p].push_back(std::make_pair(\"Sigma-A min (a)\", std::to_string(this->sig_a_min )));\n+ // headers[p].push_back(std::make_pair(\"Sigma-A max (A)\", std::to_string(this->sig_a_max )));\n+ // headers[p].push_back(std::make_pair(\"Sigma-A step\", std::to_string(this->sig_a_step)));\nif (this->src != nullptr && this->cdc != nullptr)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/EXIT/EXIT.hpp",
"new_path": "src/Factory/Simulation/EXIT/EXIT.hpp",
"diff": "@@ -39,12 +39,13 @@ struct EXIT : Simulation\npublic:\n// ------------------------------------------------------------------------------------------------- PARAMETERS\n// required parameters\n- float sig_a_min = 0.0f;\n- float sig_a_max = 5.0f;\n+ // float sig_a_min = 0.0f;\n+ // float sig_a_max = 5.0f;\n+ std::vector<float> sig_a_range;\n// optional parameters\nstd::string snr_type = \"ES\";\n- float sig_a_step = 0.5f;\n+ // float sig_a_step = 0.5f;\n// module parameters\nSource ::parameters *src = nullptr;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/Simulation.cpp",
"new_path": "src/Factory/Simulation/Simulation.cpp",
"diff": "#include \"Tools/Exception/exception.hpp\"\n+#include \"Tools/general_utils.h\"\n#include \"Simulation.hpp\"\n@@ -25,6 +26,30 @@ Simulation::parameters\n{\n}\n+struct SNR_range_D1_splitter : tools::Splitter\n+{\n+ static std::vector<std::string> split(const std::string& val)\n+ {\n+ const std::string head = \"{([\";\n+ const std::string queue = \"})]\";\n+ const std::string separator = \",\";\n+\n+ return Splitter::split(val, head, queue, separator);\n+ }\n+};\n+\n+struct SNR_range_D2_splitter : tools::Splitter\n+{\n+ static std::vector<std::string> split(const std::string& val)\n+ {\n+ const std::string head = \"\";\n+ const std::string queue = \"\";\n+ const std::string separator = \":\";\n+\n+ return Splitter::split(val, head, queue, separator);\n+ }\n+};\n+\nvoid Simulation::parameters\n::get_description(tools::Argument_map_info &args) const\n{\n@@ -33,21 +58,30 @@ void Simulation::parameters\nauto p = this->get_prefix();\nargs.add(\n- {p+\"-snr-min\", \"m\"},\n+ {p+\"-snr-range\", \"s\"},\n+ tools::List2D<float,SNR_range_D1_splitter,SNR_range_D2_splitter>(\ntools::Real(),\n- \"minimal signal/noise ratio to simulate.\",\n+ std::make_tuple(tools::Length(1)),\n+ std::make_tuple(tools::Length(2,3))),\n+ \"signal/noise ratio range to run (Matlab style: \\\"0.5:2.5,2.6:0.05:3\\\" with a default step of 0.1).\",\ntools::Argument_info::REQUIRED);\n- args.add(\n- {p+\"-snr-max\", \"M\"},\n- tools::Real(),\n- \"maximal signal/noise ratio to simulate.\",\n- tools::Argument_info::REQUIRED);\n+ // args.add(\n+ // {p+\"-snr-min\", \"m\"},\n+ // tools::Real(),\n+ // \"minimal signal/noise ratio to simulate.\",\n+ // tools::Argument_info::REQUIRED);\n- args.add(\n- {p+\"-snr-step\", \"s\"},\n- tools::Real(tools::Positive(), tools::Non_zero()),\n- \"signal/noise ratio step between each simulation.\");\n+ // args.add(\n+ // {p+\"-snr-max\", \"M\"},\n+ // tools::Real(),\n+ // \"maximal signal/noise ratio to simulate.\",\n+ // tools::Argument_info::REQUIRED);\n+\n+ // args.add(\n+ // {p+\"-snr-step\", \"s\"},\n+ // tools::Real(tools::Positive(), tools::Non_zero()),\n+ // \"signal/noise ratio step between each simulation.\");\nargs.add(\n{p+\"-pyber\"},\n@@ -111,9 +145,13 @@ void Simulation::parameters\nauto p = this->get_prefix();\n- if(vals.exist({p+\"-snr-min\", \"m\" })) this->snr_min = vals.to_float({p+\"-snr-min\", \"m\"});\n- if(vals.exist({p+\"-snr-max\", \"M\" })) this->snr_max = vals.to_float({p+\"-snr-max\", \"M\"});\n- if(vals.exist({p+\"-snr-step\", \"s\" })) this->snr_step = vals.to_float({p+\"-snr-step\", \"s\"});\n+ if(vals.exist({p+\"-snr-range\", \"s\"}))\n+ this->snr_range = tools::generate_range(vals.to_list<std::vector<float>>({p+\"-snr-range\", \"s\"}), 0.1f);\n+\n+\n+ // if(vals.exist({p+\"-snr-min\", \"m\" })) this->snr_min = vals.to_float({p+\"-snr-min\", \"m\"});\n+ // if(vals.exist({p+\"-snr-max\", \"M\" })) this->snr_max = vals.to_float({p+\"-snr-max\", \"M\"});\n+ // if(vals.exist({p+\"-snr-step\", \"s\" })) this->snr_step = vals.to_float({p+\"-snr-step\", \"s\"});\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\" }));\nif(vals.exist({p+\"-seed\", \"S\" })) this->global_seed = vals.to_int ({p+\"-seed\", \"S\"});\n@@ -135,7 +173,7 @@ void Simulation::parameters\nthis->debug_precision = vals.to_int({p+\"-debug-prec\"});\n}\n- this->snr_max += 0.0001f; // hack to avoid the miss of the last snr\n+ // this->snr_max += 0.0001f; // hack to avoid the miss of the last snr\nif(vals.exist({p+\"-threads\", \"t\"}) && vals.to_int({p+\"-threads\", \"t\"}) > 0)\nif(vals.exist({p+\"-threads\", \"t\"})) this->n_threads = vals.to_int({p+\"-threads\", \"t\"});\n@@ -187,9 +225,14 @@ void Simulation::parameters\nauto p = this->get_prefix();\n- headers[p].push_back(std::make_pair(\"SNR min (m)\", std::to_string(this->snr_min) + \" dB\"));\n- headers[p].push_back(std::make_pair(\"SNR max (M)\", std::to_string(this->snr_max) + \" dB\"));\n- headers[p].push_back(std::make_pair(\"SNR step (s)\", std::to_string(this->snr_step) + \" dB\"));\n+ // headers[p].push_back(std::make_pair(\"SNR min (m)\", std::to_string(this->snr_min) + \" dB\"));\n+ // headers[p].push_back(std::make_pair(\"SNR max (M)\", std::to_string(this->snr_max) + \" dB\"));\n+ // headers[p].push_back(std::make_pair(\"SNR step (s)\", std::to_string(this->snr_step) + \" dB\"));\n+\n+ std::stringstream snr_range_str;\n+ snr_range_str << this->snr_range.front() << \" -> \" << this->snr_range.back() << \" dB\";\n+ headers[p].push_back(std::make_pair(\"SNR range (s)\", snr_range_str.str()));\n+\nheaders[p].push_back(std::make_pair(\"Seed\", std::to_string(this->global_seed)));\nheaders[p].push_back(std::make_pair(\"Statistics\", this->statistics ? \"on\" : \"off\"));\nheaders[p].push_back(std::make_pair(\"Debug mode\", this->debug ? \"on\" : \"off\"));\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/Simulation.hpp",
"new_path": "src/Factory/Simulation/Simulation.hpp",
"diff": "#include <chrono>\n#include <string>\n#include <sstream>\n+#include <vector>\n#include \"Tools/Display/bash_tools.h\"\n@@ -25,8 +26,9 @@ struct Simulation : Launcher\npublic:\n// ------------------------------------------------------------------------------------------------- PARAMETERS\n// required parameters\n- float snr_min = 0.f;\n- float snr_max = 0.f;\n+ // float snr_min = 0.f;\n+ // float snr_max = 0.f;\n+ std::vector<float> snr_range;\n// optional parameters\n#ifdef ENABLE_MPI\n@@ -36,7 +38,7 @@ struct Simulation : Launcher\n#endif\nstd::chrono::seconds stop_time = std::chrono::seconds(0);\nstd::string pyber = \"\";\n- float snr_step = 0.1f;\n+ // float snr_step = 0.1f;\nbool debug = false;\nbool debug_hex = false;\nbool statistics = false;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.cpp",
"new_path": "src/Simulation/BFER/BFER.cpp",
"diff": "@@ -136,8 +136,10 @@ void BFER<B,R,Q>\n}\n// for each SNR to be simulated\n- for (snr = params_BFER.snr_min; snr <= params_BFER.snr_max; snr += params_BFER.snr_step)\n+ for (unsigned snr_idx = 0; snr_idx < params_BFER.snr_range.size(); snr_idx ++)\n{\n+ snr = params_BFER.snr_range[snr_idx];\n+\nif (params_BFER.snr_type == \"EB\")\n{\nsnr_b = snr;\n@@ -192,10 +194,10 @@ void BFER<B,R,Q>\nif (params_BFER.display_legend)\n#ifdef ENABLE_MPI\n- if (((!params_BFER.ter->disabled && snr == params_BFER.snr_min && !params_BFER.debug) ||\n+ if (((!params_BFER.ter->disabled && snr_idx == 0 && !params_BFER.debug) ||\n(params_BFER.statistics && !params_BFER.debug)) && params_BFER.mpi_rank == 0)\n#else\n- if (((!params_BFER.ter->disabled && snr == params_BFER.snr_min && !params_BFER.debug) ||\n+ if (((!params_BFER.ter->disabled && snr_idx == 0 && !params_BFER.debug) ||\n(params_BFER.statistics && !params_BFER.debug)))\n#endif\nterminal->legend(std::cout);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/EXIT/EXIT.cpp",
"new_path": "src/Simulation/EXIT/EXIT.cpp",
"diff": "@@ -112,8 +112,10 @@ void EXIT<B,R>\nthis->sockets_binding();\n// for each channel SNR to be simulated\n- for (ebn0 = params_EXIT.snr_min; ebn0 <= params_EXIT.snr_max; ebn0 += params_EXIT.snr_step)\n+ for (unsigned snr_idx = 0; snr_idx < params_EXIT.snr_range.size(); snr_idx ++)\n{\n+ ebn0 = params_EXIT.snr_range[snr_idx];\n+\n// For EXIT simulation, SNR is considered as Es/N0\nconst auto bit_rate = 1.f;\nesn0 = tools::ebn0_to_esn0 (ebn0, bit_rate, params_EXIT.mdm->bps);\n@@ -128,8 +130,10 @@ void EXIT<B,R>\n// for each \"a\" standard deviation (sig_a) to be simulated\nusing namespace module;\n- for (sig_a = params_EXIT.sig_a_min; sig_a <= params_EXIT.sig_a_max; sig_a += params_EXIT.sig_a_step)\n+ for (unsigned sig_a_idx = 0; sig_a_idx < params_EXIT.sig_a_range.size(); sig_a_idx ++)\n{\n+ sig_a = params_EXIT.sig_a_range[sig_a_idx];\n+\nterminal ->set_sig_a(sig_a );\nchannel_a->set_sigma(2.f / sig_a);\nmodem_a ->set_sigma(2.f / sig_a);\n@@ -151,7 +155,7 @@ void EXIT<B,R>\n}\n}\n- if (((!params_EXIT.ter->disabled && ebn0 == params_EXIT.snr_min && sig_a == params_EXIT.sig_a_min &&\n+ if (((!params_EXIT.ter->disabled && snr_idx == 0 && sig_a_idx == 0 &&\n!params_EXIT.debug) || (params_EXIT.statistics && !params_EXIT.debug)))\nterminal->legend(std::cout);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/general_utils.cpp",
"new_path": "src/Tools/general_utils.cpp",
"diff": "@@ -126,6 +126,29 @@ R aff3ct::tools::ebn0_to_esn0(const R ebn0, const R bit_rate, const int bps)\nreturn esn0;\n}\n+template <typename R>\n+std::vector<R> aff3ct::tools::generate_range(const std::vector<std::vector<R>>& range_description, const R default_step)\n+{\n+ std::vector<R> range;\n+\n+ for (auto& s : range_description)\n+ {\n+ if (s.size() != 3 && s.size() != 2)\n+ {\n+ std::stringstream message;\n+ message << \"'s.size()' has to be 2 or 3 ('s.size()' = \" << s.size() << \").\";\n+ throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ }\n+\n+ R step = (s.size() == 3) ? s[1] : default_step;\n+\n+ for (R v = s.front(); v <= (s.back() + 0.0001f); v += step) // 0.0001f is a hack to avoid the miss of the last snr\n+ range.push_back(v);\n+ }\n+\n+ return range;\n+}\n+\n// ==================================================================================== explicit template instantiation\ntemplate float aff3ct::tools::sigma_to_esn0<float >(const float, const int);\ntemplate double aff3ct::tools::sigma_to_esn0<double>(const double, const int);\n@@ -135,4 +158,6 @@ template float aff3ct::tools::esn0_to_ebn0 <float >(const float, const float,\ntemplate double aff3ct::tools::esn0_to_ebn0 <double>(const double, const double, const int);\ntemplate float aff3ct::tools::ebn0_to_esn0 <float >(const float, const float, const int);\ntemplate double aff3ct::tools::ebn0_to_esn0 <double>(const double, const double, const int);\n+template std::vector<float > aff3ct::tools::generate_range(const std::vector<std::vector<float >>&, const float );\n+template std::vector<double> aff3ct::tools::generate_range(const std::vector<std::vector<double>>&, const double);\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/general_utils.h",
"new_path": "src/Tools/general_utils.h",
"diff": "@@ -26,6 +26,15 @@ R esn0_to_ebn0(const R esn0, const R bit_rate = 1, const int bps = 1);\ntemplate <typename R = float>\nR ebn0_to_esn0(const R ebn0, const R bit_rate = 1, const int bps = 1);\n+\n+/* Transform a Matlab style description of a range into a vector.\n+ * For ex: \"0:1.2,3.4:0.2:4.4\" gives the vector \"0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 1.1 1.2 3.4 3.6 3.8 4 4.2 4.4\"\n+ * The first dimension of 'range_description' can have any size.\n+ * The second is between 2 or 3. The first element is the min value, the last is the max value. The one between if any\n+ * is the step to use else use the step 'default_step'.\n+ */\n+template <typename R = float>\n+std::vector<R> generate_range(const std::vector<std::vector<R>>& range_description, const R default_step = (R)0.1);\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Design the SNR range argument in BFER and EXIT simulations as a Matlab style range setter
|
8,483 |
06.04.2018 13:15:53
| -7,200 |
a38485ee0cf733b64ffe0af01f0ad1045845144e
|
Add a comp_equal fonction to compare floating point numbers to an epsilon and not bitwisely
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/utils.h",
"new_path": "src/Tools/Math/utils.h",
"diff": "#include \"Tools/Exception/exception.hpp\"\n+#define REAL_COMP_PRECISION 1e-6\n+\nnamespace aff3ct\n{\nnamespace tools\n@@ -28,6 +30,11 @@ template <> inline int32_t div8(int32_t val) { return val >> 3;\ntemplate <> inline int16_t div8(int16_t val) { return val >> 3; }\ntemplate <> inline int8_t div8(int8_t val) { return val >> 3; }\n+template <typename R> inline R comp_equal(R val1, R val2) { return val1 == val2; }\n+template <> inline float comp_equal(float val1, float val2) { return std::abs(val1 - val2) < (float)REAL_COMP_PRECISION;}\n+template <> inline double comp_equal(double val1, double val2) { return std::abs(val1 - val2) < (double)REAL_COMP_PRECISION;}\n+\n+\n// init value depending on the domain\ntemplate <typename R>\nconstexpr R init_LR () { return (R)1; }\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a comp_equal fonction to compare floating point numbers to an epsilon and not bitwisely
|
8,483 |
06.04.2018 13:16:32
| -7,200 |
e65b617a7328689ac83ebd28a6e7ea5bbec031d9
|
Sort the computed range and parse it to have each SNR only once
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/general_utils.cpp",
"new_path": "src/Tools/general_utils.cpp",
"diff": "#include <sstream>\n#include <algorithm>\n-#include \"Tools/general_utils.h\"\n+#include \"Tools/Math/utils.h\"\n#include \"Tools/Exception/exception.hpp\"\n#include \"general_utils.h\"\n@@ -146,6 +146,9 @@ std::vector<R> aff3ct::tools::generate_range(const std::vector<std::vector<R>>&\nrange.push_back(v);\n}\n+ std::sort (range.begin(), range.end());\n+ std::unique(range.begin(), range.end(), comp_equal<R>);\n+\nreturn range;\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Sort the computed range and parse it to have each SNR only once
|
8,483 |
06.04.2018 15:17:42
| -7,200 |
e74386f9b90bfb2847c6503458de173a861f13be
|
Add argument link
add a ckeck when parsing command line if a required argument is needed or not according to the availablity of another one.
Add back the old snr arguments to keep retrocompatibility
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/Simulation.cpp",
"new_path": "src/Factory/Simulation/Simulation.cpp",
"diff": "@@ -58,7 +58,7 @@ void Simulation::parameters\nauto p = this->get_prefix();\nargs.add(\n- {p+\"-snr-range\", \"s\"},\n+ {p+\"-snr-range\", \"R\"},\ntools::List2D<float,SNR_range_D1_splitter,SNR_range_D2_splitter>(\ntools::Real(),\nstd::make_tuple(tools::Length(1)),\n@@ -66,22 +66,29 @@ void Simulation::parameters\n\"signal/noise ratio range to run (Matlab style: \\\"0.5:2.5,2.6:0.05:3\\\" with a default step of 0.1).\",\ntools::Argument_info::REQUIRED);\n- // args.add(\n- // {p+\"-snr-min\", \"m\"},\n- // tools::Real(),\n- // \"minimal signal/noise ratio to simulate.\",\n- // tools::Argument_info::REQUIRED);\n+ args.add(\n+ {p+\"-snr-min\", \"m\"},\n+ tools::Real(),\n+ \"minimal signal/noise ratio to simulate.\",\n+ tools::Argument_info::REQUIRED);\n+\n+ args.add(\n+ {p+\"-snr-max\", \"M\"},\n+ tools::Real(),\n+ \"maximal signal/noise ratio to simulate.\",\n+ tools::Argument_info::REQUIRED);\n+\n+ args.add(\n+ {p+\"-snr-step\", \"s\"},\n+ tools::Real(tools::Positive(), tools::Non_zero()),\n+ \"signal/noise ratio step between each simulation.\");\n+\n+\n+ args.add_link({p+\"-snr-range\", \"R\"}, {p+\"-snr-min\", \"m\"});\n+ args.add_link({p+\"-snr-range\", \"R\"}, {p+\"-snr-max\", \"M\"});\n+ args.add_link({p+\"-snr-range\", \"R\"}, {p+\"-snr-step\", \"s\"});\n- // args.add(\n- // {p+\"-snr-max\", \"M\"},\n- // tools::Real(),\n- // \"maximal signal/noise ratio to simulate.\",\n- // tools::Argument_info::REQUIRED);\n- // args.add(\n- // {p+\"-snr-step\", \"s\"},\n- // tools::Real(tools::Positive(), tools::Non_zero()),\n- // \"signal/noise ratio step between each simulation.\");\nargs.add(\n{p+\"-pyber\"},\n@@ -145,13 +152,17 @@ void Simulation::parameters\nauto p = this->get_prefix();\n- if(vals.exist({p+\"-snr-range\", \"s\"}))\n- this->snr_range = tools::generate_range(vals.to_list<std::vector<float>>({p+\"-snr-range\", \"s\"}), 0.1f);\n+ if(vals.exist({p+\"-snr-range\", \"R\"}))\n+ this->snr_range = tools::generate_range(vals.to_list<std::vector<float>>({p+\"-snr-range\", \"R\"}), this->snr_step);\n+ else\n+ {\n+ if(vals.exist({p+\"-snr-min\", \"m\"})) this->snr_min = vals.to_float({p+\"-snr-min\", \"m\"});\n+ if(vals.exist({p+\"-snr-max\", \"M\"})) this->snr_max = vals.to_float({p+\"-snr-max\", \"M\"});\n+ if(vals.exist({p+\"-snr-step\", \"s\"})) this->snr_step = vals.to_float({p+\"-snr-step\", \"s\"});\n+ this->snr_range = tools::generate_range({{this->snr_min, this->snr_max}}, this->snr_step);\n+ }\n- // if(vals.exist({p+\"-snr-min\", \"m\" })) this->snr_min = vals.to_float({p+\"-snr-min\", \"m\"});\n- // if(vals.exist({p+\"-snr-max\", \"M\" })) this->snr_max = vals.to_float({p+\"-snr-max\", \"M\"});\n- // if(vals.exist({p+\"-snr-step\", \"s\" })) this->snr_step = vals.to_float({p+\"-snr-step\", \"s\"});\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\" }));\nif(vals.exist({p+\"-seed\", \"S\" })) this->global_seed = vals.to_int ({p+\"-seed\", \"S\"});\n@@ -231,7 +242,7 @@ void Simulation::parameters\nstd::stringstream snr_range_str;\nsnr_range_str << this->snr_range.front() << \" -> \" << this->snr_range.back() << \" dB\";\n- headers[p].push_back(std::make_pair(\"SNR range (s)\", snr_range_str.str()));\n+ headers[p].push_back(std::make_pair(\"SNR range\", snr_range_str.str()));\nheaders[p].push_back(std::make_pair(\"Seed\", std::to_string(this->global_seed)));\nheaders[p].push_back(std::make_pair(\"Statistics\", this->statistics ? \"on\" : \"off\"));\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/Simulation.hpp",
"new_path": "src/Factory/Simulation/Simulation.hpp",
"diff": "@@ -25,12 +25,13 @@ struct Simulation : Launcher\n{\npublic:\n// ------------------------------------------------------------------------------------------------- PARAMETERS\n- // required parameters\n- // float snr_min = 0.f;\n- // float snr_max = 0.f;\n+ // for the snr\n+ float snr_min = 0.f;\n+ float snr_max = 0.f;\n+ float snr_step = 0.1f;\nstd::vector<float> snr_range;\n- // optional parameters\n+ // other parameters\n#ifdef ENABLE_MPI\nstd::chrono::milliseconds mpi_comm_freq = std::chrono::milliseconds(1000);\nint mpi_rank = 0;\n@@ -38,7 +39,6 @@ struct Simulation : Launcher\n#endif\nstd::chrono::seconds stop_time = std::chrono::seconds(0);\nstd::string pyber = \"\";\n- // float snr_step = 0.1f;\nbool debug = false;\nbool debug_hex = false;\nbool statistics = false;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Arguments/Argument_handler.cpp",
"new_path": "src/Tools/Arguments/Argument_handler.cpp",
"diff": "#include <type_traits>\n#include \"Tools/Display/bash_tools.h\"\n-#include \"Tools/Exception/exception.hpp\"\n#include \"Tools/general_utils.h\"\n#include \"Argument_handler.hpp\"\n@@ -18,7 +17,7 @@ Argument_handler\n{\nstd::stringstream message;\nmessage << \"'argc' has to be greater than 0 ('argc' = \" << argc << \").\";\n- throw invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ throw std::invalid_argument(message.str());\n}\nthis->m_program_name = argv[0];\n@@ -34,6 +33,26 @@ Argument_handler\n{\n}\n+bool Argument_handler\n+::is_linked(const Argument_map_info &args, const Argument_map_value& arg_v, const Argument_tag &tag) const\n+{\n+ auto& links = args.get_links();\n+\n+ size_t tag_link_pos = 0;\n+ while((tag_link_pos = links.find(tag, tag_link_pos)) < links.size())\n+ {\n+ auto tag_pair = links[tag_link_pos];\n+ auto other_tag = (tag_pair.first == tag) ? tag_pair.second : tag_pair.first;\n+\n+ if (arg_v.exist(other_tag)) // the other argument has been given\n+ return true;\n+\n+ tag_link_pos++;\n+ }\n+\n+ return false; // no link found\n+}\n+\nArgument_map_value Argument_handler\n::parse_arguments(const Argument_map_info &args,\nstd::vector<std::string> &warnings, std::vector<std::string> &errors)\n@@ -46,7 +65,9 @@ Argument_map_value Argument_handler\nauto it_arg = args.begin();\nfor (unsigned i = 0; i < args_found_pos.size(); i++, it_arg++)\n{\n- if (!args_found_pos[i] && it_arg->second->rank == Argument_info::REQUIRED)\n+ if (!args_found_pos[i]\n+ && it_arg->second->rank == Argument_info::REQUIRED\n+ && !is_linked(args, m_arg_v, it_arg->first)) // check if any linked arguments, has been given\n{\nstd::string message = \"The \\\"\" + print_tag(it_arg->first) + \"\\\" argument is required.\";\nerrors.push_back(message);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Arguments/Argument_handler.hpp",
"new_path": "src/Tools/Arguments/Argument_handler.hpp",
"diff": "@@ -129,6 +129,8 @@ private:\nvoid print_help_title(const std::string& title) const;\nsize_t find_longest_tags(const Argument_map_info &args) const;\n+\n+ bool is_linked(const Argument_map_info &args, const Argument_map_value& arg_v, const Argument_tag &tag) const;\n};\n}\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Arguments/Maps/Argument_links.cpp",
"diff": "+#include <stdexcept>\n+#include <algorithm>\n+#include \"Argument_links.hpp\"\n+\n+using namespace aff3ct::tools;\n+\n+\n+Argument_links\n+::Argument_links()\n+{\n+}\n+\n+Argument_links\n+::~Argument_links()\n+{\n+}\n+\n+void Argument_links\n+::add(const Argument_tag& tag1, const Argument_tag& tag2)\n+{\n+ add(std::make_pair(tag1, tag2));\n+}\n+\n+void Argument_links\n+::add(const std::pair<Argument_tag, Argument_tag>& tags)\n+{\n+ if (!find(tags))\n+ this->push_back(tags);\n+}\n+\n+bool Argument_links\n+::find(const Argument_tag& tag1, const Argument_tag& tag2) const\n+{\n+ return find(std::make_pair(tag1, tag2));\n+}\n+\n+bool Argument_links\n+::find(const std::pair<Argument_tag, Argument_tag>& tags) const\n+{\n+ if (tags.first.size() == 0)\n+ throw std::invalid_argument(\"No tags.first has been given ('tags.first.size()' == 0).\");\n+\n+ if (tags.second.size() == 0)\n+ throw std::invalid_argument(\"No tags.second has been given ('tags.second.size()' == 0).\");\n+\n+ if (tags.first == tags.second)\n+ throw std::invalid_argument(\"tags can't be identical.\");\n+\n+ auto it = std::find(this->begin(), this->end(), tags);\n+\n+ if (it == this->end())\n+ it = std::find(this->begin(), this->end(), std::make_pair(tags.second, tags.first));\n+\n+ return it != this->end();\n+}\n+\n+size_t Argument_links\n+::find(const Argument_tag& tag, const size_t first_pos) const\n+{\n+ size_t i = first_pos;\n+\n+ while (i < this->size())\n+ {\n+ auto val = *(this->data() + i);\n+\n+ if (val.first == tag || val.second == tag)\n+ break;\n+\n+ i++;\n+ }\n+\n+ return i;\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Tools/Arguments/Maps/Argument_links.hpp",
"diff": "+#ifndef ARGUMENT_LINKS_HPP_\n+#define ARGUMENT_LINKS_HPP_\n+\n+#include <string>\n+#include <vector>\n+\n+#include \"Argument_tag.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace tools\n+{\n+\n+class Argument_links : public std::vector<std::pair<Argument_tag, Argument_tag>>\n+{\n+public:\n+ using mother_t = std::vector<value_type>;\n+\n+public:\n+ Argument_links();\n+\n+ virtual ~Argument_links();\n+\n+ void add(const Argument_tag& tag1, const Argument_tag& tag2);\n+ void add(const std::pair<Argument_tag, Argument_tag>& tags);\n+\n+ bool find(const Argument_tag& tag1, const Argument_tag& tag2) const;\n+ bool find(const std::pair<Argument_tag, Argument_tag>& tags) const;\n+\n+ size_t find(const Argument_tag& tag, const size_t first_pos = 0) const;\n+};\n+\n+}\n+}\n+\n+#endif /* ARGUMENT_LINKS_HPP_ */\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Arguments/Maps/Argument_map_info.cpp",
"new_path": "src/Tools/Arguments/Maps/Argument_map_info.cpp",
"diff": "@@ -43,6 +43,24 @@ void Argument_map_info\n(*this)[tags] = new Argument_info(arg_t, doc, rank);\n}\n+void Argument_map_info\n+::add_link(const Argument_tag& tag1, const Argument_tag& tag2)\n+{\n+ links.add(tag1,tag2);\n+}\n+\n+bool Argument_map_info\n+::has_link(const Argument_tag& tag) const\n+{\n+ return links.find(tag) != links.size();\n+}\n+\n+const Argument_links& Argument_map_info\n+::get_links() const\n+{\n+ return links;\n+}\n+\nvoid Argument_map_info\n::erase(const Argument_tag& tags)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Arguments/Maps/Argument_map_info.hpp",
"new_path": "src/Tools/Arguments/Maps/Argument_map_info.hpp",
"diff": "#include \"Argument_info.hpp\"\n#include \"Argument_tag.hpp\"\n+#include \"Argument_links.hpp\"\nnamespace aff3ct\n{\n@@ -18,6 +19,9 @@ class Argument_map_info : public std::map<Argument_tag, Argument_info*>\npublic:\nusing mother_t = std::map<Argument_tag, Argument_info*>;\n+protected:\n+ Argument_links links;\n+\npublic:\nArgument_map_info();\n@@ -30,6 +34,10 @@ public:\nvoid add(const Argument_tag& tags, Argument_type* arg_t, const std::string& doc,\nconst Argument_info::Rank rank = Argument_info::OPTIONAL);\n+ void add_link(const Argument_tag& tag1, const Argument_tag& tag2);\n+ bool has_link(const Argument_tag& tag) const;\n+ const Argument_links& get_links() const;\n+\nvoid erase(const Argument_tag& tags);\nvoid clear();\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add argument link
add a ckeck when parsing command line if a required argument is needed or not according to the availablity of another one.
Add back the old snr arguments to keep retrocompatibility
|
8,483 |
06.04.2018 15:33:15
| -7,200 |
b3cd9a834f78ac45725680dc67a5d3ea22da0b94
|
Cosmetics; Add the possibility to have only one value in the SNR range; Add linked arguments in EXIT siga
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/EXIT/EXIT.cpp",
"new_path": "src/Factory/Simulation/EXIT/EXIT.cpp",
"diff": "@@ -119,30 +119,34 @@ void EXIT::parameters\nauto p = this->get_prefix();\nargs.add(\n- {p+\"-siga-range\", \"a\"},\n+ {p+\"-siga-range\"},\ntools::List2D<float,sigma_range_D1_splitter,sigma_range_D2_splitter>(\ntools::Real(),\nstd::make_tuple(tools::Length(1)),\n- std::make_tuple(tools::Length(2,3))),\n- \"sigma range used in EXIT charts (Matlab style: \\\"0.5:2.5,2.6:0.05:3\\\" with a default step of 0.1).\",\n+ std::make_tuple(tools::Length(1,3))),\n+ \"sigma range used in EXIT charts (Matlab style: \\\"0.5:2.5,2.55,2.6:0.05:3\\\" with a default step of 0.1).\",\ntools::Argument_info::REQUIRED);\n- // args.add(\n- // {p+\"-siga-min\", \"a\"},\n- // tools::Real(tools::Positive()),\n- // \"sigma min value used in EXIT charts.\",\n- // tools::Argument_info::REQUIRED);\n-\n- // args.add(\n- // {p+\"-siga-max\", \"A\"},\n- // tools::Real(tools::Positive()),\n- // \"sigma max value used in EXIT charts.\",\n- // tools::Argument_info::REQUIRED);\n-\n- // args.add(\n- // {p+\"-siga-step\"},\n- // tools::Real(tools::Positive(), tools::Non_zero()),\n- // \"sigma step value used in EXIT charts.\");\n+ args.add(\n+ {p+\"-siga-min\", \"a\"},\n+ tools::Real(tools::Positive()),\n+ \"sigma min value used in EXIT charts.\",\n+ tools::Argument_info::REQUIRED);\n+\n+ args.add(\n+ {p+\"-siga-max\", \"A\"},\n+ tools::Real(tools::Positive()),\n+ \"sigma max value used in EXIT charts.\",\n+ tools::Argument_info::REQUIRED);\n+\n+ args.add(\n+ {p+\"-siga-step\"},\n+ tools::Real(tools::Positive(), tools::Non_zero()),\n+ \"sigma step value used in EXIT charts.\");\n+\n+ args.add_link({p+\"-siga-range\"}, {p+\"-siga-min\", \"a\"});\n+ args.add_link({p+\"-siga-range\"}, {p+\"-siga-max\", \"A\"});\n+ args.add_link({p+\"-siga-range\"}, {p+\"-siga-step\" });\n}\nvoid EXIT::parameters\n@@ -152,12 +156,17 @@ void EXIT::parameters\nauto p = this->get_prefix();\n- if(vals.exist({p+\"-siga-range\", \"a\"}))\n- this->sig_a_range = tools::generate_range(vals.to_list<std::vector<float>>({p+\"-siga-range\", \"a\"}), 0.1f);\n+ if(vals.exist({p+\"-siga-range\"}))\n+ this->sig_a_range = tools::generate_range(vals.to_list<std::vector<float>>({p+\"-siga-range\"}), 0.1f);\n+ else\n+ {\n+ float snr_min = 0.f, snr_max = 0.f, snr_step = 0.1f;\n+ if(vals.exist({p+\"-siga-min\", \"m\"})) snr_min = vals.to_float({p+\"-siga-min\", \"m\"});\n+ if(vals.exist({p+\"-siga-max\", \"M\"})) snr_max = vals.to_float({p+\"-siga-max\", \"M\"});\n+ if(vals.exist({p+\"-siga-step\" })) snr_step = vals.to_float({p+\"-siga-step\" });\n- // if(vals.exist({p+\"-siga-min\", \"a\"})) this->sig_a_min = vals.to_float({p+\"-siga-min\", \"a\"});\n- // if(vals.exist({p+\"-siga-max\", \"A\"})) this->sig_a_max = vals.to_float({p+\"-siga-max\", \"A\"});\n- // if(vals.exist({p+\"-siga-step\" })) this->sig_a_step = vals.to_float({p+\"-siga-step\" });\n+ this->snr_range = tools::generate_range({{snr_min, snr_max}}, snr_step);\n+ }\n}\nvoid EXIT::parameters\n@@ -171,10 +180,6 @@ void EXIT::parameters\nsig_a_range_str << this->sig_a_range.front() << \" -> \" << this->sig_a_range.back();\nheaders[p].push_back(std::make_pair(\"Sigma-A range (a)\", sig_a_range_str.str()));\n- // headers[p].push_back(std::make_pair(\"Sigma-A min (a)\", std::to_string(this->sig_a_min )));\n- // headers[p].push_back(std::make_pair(\"Sigma-A max (A)\", std::to_string(this->sig_a_max )));\n- // headers[p].push_back(std::make_pair(\"Sigma-A step\", std::to_string(this->sig_a_step)));\n-\nif (this->src != nullptr && this->cdc != nullptr)\n{\nconst auto bit_rate = (float)this->src->K / (float)this->cdc->N_cw;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/Simulation.cpp",
"new_path": "src/Factory/Simulation/Simulation.cpp",
"diff": "@@ -62,8 +62,8 @@ void Simulation::parameters\ntools::List2D<float,SNR_range_D1_splitter,SNR_range_D2_splitter>(\ntools::Real(),\nstd::make_tuple(tools::Length(1)),\n- std::make_tuple(tools::Length(2,3))),\n- \"signal/noise ratio range to run (Matlab style: \\\"0.5:2.5,2.6:0.05:3\\\" with a default step of 0.1).\",\n+ std::make_tuple(tools::Length(1,3))),\n+ \"signal/noise ratio range to run (Matlab style: \\\"0.5:2.5,2.55,2.6:0.05:3\\\" with a default step of 0.1).\",\ntools::Argument_info::REQUIRED);\nargs.add(\n@@ -153,14 +153,15 @@ void Simulation::parameters\nauto p = this->get_prefix();\nif(vals.exist({p+\"-snr-range\", \"R\"}))\n- this->snr_range = tools::generate_range(vals.to_list<std::vector<float>>({p+\"-snr-range\", \"R\"}), this->snr_step);\n+ this->snr_range = tools::generate_range(vals.to_list<std::vector<float>>({p+\"-snr-range\", \"R\"}), 0.1f);\nelse\n{\n- if(vals.exist({p+\"-snr-min\", \"m\"})) this->snr_min = vals.to_float({p+\"-snr-min\", \"m\"});\n- if(vals.exist({p+\"-snr-max\", \"M\"})) this->snr_max = vals.to_float({p+\"-snr-max\", \"M\"});\n- if(vals.exist({p+\"-snr-step\", \"s\"})) this->snr_step = vals.to_float({p+\"-snr-step\", \"s\"});\n+ float snr_min = 0.f, snr_max = 0.f, snr_step = 0.1f;\n+ if(vals.exist({p+\"-snr-min\", \"m\"})) snr_min = vals.to_float({p+\"-snr-min\", \"m\"});\n+ if(vals.exist({p+\"-snr-max\", \"M\"})) snr_max = vals.to_float({p+\"-snr-max\", \"M\"});\n+ if(vals.exist({p+\"-snr-step\", \"s\"})) snr_step = vals.to_float({p+\"-snr-step\", \"s\"});\n- this->snr_range = tools::generate_range({{this->snr_min, this->snr_max}}, this->snr_step);\n+ this->snr_range = tools::generate_range({{snr_min, snr_max}}, snr_step);\n}\nif(vals.exist({p+\"-pyber\" })) this->pyber = vals.at ({p+\"-pyber\" });\n@@ -236,13 +237,12 @@ void Simulation::parameters\nauto p = this->get_prefix();\n- // headers[p].push_back(std::make_pair(\"SNR min (m)\", std::to_string(this->snr_min) + \" dB\"));\n- // headers[p].push_back(std::make_pair(\"SNR max (M)\", std::to_string(this->snr_max) + \" dB\"));\n- // headers[p].push_back(std::make_pair(\"SNR step (s)\", std::to_string(this->snr_step) + \" dB\"));\n-\n+ if (this->snr_range.size())\n+ {\nstd::stringstream snr_range_str;\nsnr_range_str << this->snr_range.front() << \" -> \" << this->snr_range.back() << \" dB\";\nheaders[p].push_back(std::make_pair(\"SNR range\", snr_range_str.str()));\n+ }\nheaders[p].push_back(std::make_pair(\"Seed\", std::to_string(this->global_seed)));\nheaders[p].push_back(std::make_pair(\"Statistics\", this->statistics ? \"on\" : \"off\"));\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/Simulation.hpp",
"new_path": "src/Factory/Simulation/Simulation.hpp",
"diff": "@@ -26,9 +26,6 @@ struct Simulation : Launcher\npublic:\n// ------------------------------------------------------------------------------------------------- PARAMETERS\n// for the snr\n- float snr_min = 0.f;\n- float snr_max = 0.f;\n- float snr_step = 0.1f;\nstd::vector<float> snr_range;\n// other parameters\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/general_utils.cpp",
"new_path": "src/Tools/general_utils.cpp",
"diff": "@@ -133,10 +133,16 @@ std::vector<R> aff3ct::tools::generate_range(const std::vector<std::vector<R>>&\nfor (auto& s : range_description)\n{\n+ if (s.size() == 1)\n+ {\n+ range.push_back(s.front());\n+ continue;\n+ }\n+\nif (s.size() != 3 && s.size() != 2)\n{\nstd::stringstream message;\n- message << \"'s.size()' has to be 2 or 3 ('s.size()' = \" << s.size() << \").\";\n+ message << \"'s.size()' has to be 1, 2 or 3 ('s.size()' = \" << s.size() << \").\";\nthrow invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/general_utils.h",
"new_path": "src/Tools/general_utils.h",
"diff": "@@ -30,7 +30,7 @@ R ebn0_to_esn0(const R ebn0, const R bit_rate = 1, const int bps = 1);\n/* Transform a Matlab style description of a range into a vector.\n* For ex: \"0:1.2,3.4:0.2:4.4\" gives the vector \"0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 1.1 1.2 3.4 3.6 3.8 4 4.2 4.4\"\n* The first dimension of 'range_description' can have any size.\n- * The second is between 2 or 3. The first element is the min value, the last is the max value. The one between if any\n+ * The second is between 1 to 3. If 1, then a value alone, else the first element is the min value, the last is the max value. The one between if any\n* is the step to use else use the step 'default_step'.\n*/\ntemplate <typename R = float>\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Cosmetics; Add the possibility to have only one value in the SNR range; Add linked arguments in EXIT siga
|
8,483 |
06.04.2018 15:36:53
| -7,200 |
9931bb7bdd91e40027428323209b04121429e3c5
|
Remove the step as link to snr-range
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/EXIT/EXIT.cpp",
"new_path": "src/Factory/Simulation/EXIT/EXIT.cpp",
"diff": "@@ -146,7 +146,6 @@ void EXIT::parameters\nargs.add_link({p+\"-siga-range\"}, {p+\"-siga-min\", \"a\"});\nargs.add_link({p+\"-siga-range\"}, {p+\"-siga-max\", \"A\"});\n- args.add_link({p+\"-siga-range\"}, {p+\"-siga-step\" });\n}\nvoid EXIT::parameters\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/EXIT/EXIT.hpp",
"new_path": "src/Factory/Simulation/EXIT/EXIT.hpp",
"diff": "@@ -39,13 +39,10 @@ struct EXIT : Simulation\npublic:\n// ------------------------------------------------------------------------------------------------- PARAMETERS\n// required parameters\n- // float sig_a_min = 0.0f;\n- // float sig_a_max = 5.0f;\nstd::vector<float> sig_a_range;\n// optional parameters\nstd::string snr_type = \"ES\";\n- // float sig_a_step = 0.5f;\n// module parameters\nSource ::parameters *src = nullptr;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/Simulation.cpp",
"new_path": "src/Factory/Simulation/Simulation.cpp",
"diff": "@@ -86,8 +86,6 @@ void Simulation::parameters\nargs.add_link({p+\"-snr-range\", \"R\"}, {p+\"-snr-min\", \"m\"});\nargs.add_link({p+\"-snr-range\", \"R\"}, {p+\"-snr-max\", \"M\"});\n- args.add_link({p+\"-snr-range\", \"R\"}, {p+\"-snr-step\", \"s\"});\n-\nargs.add(\n@@ -185,8 +183,6 @@ void Simulation::parameters\nthis->debug_precision = vals.to_int({p+\"-debug-prec\"});\n}\n- // this->snr_max += 0.0001f; // hack to avoid the miss of the last snr\n-\nif(vals.exist({p+\"-threads\", \"t\"}) && vals.to_int({p+\"-threads\", \"t\"}) > 0)\nif(vals.exist({p+\"-threads\", \"t\"})) this->n_threads = vals.to_int({p+\"-threads\", \"t\"});\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/Simulation.hpp",
"new_path": "src/Factory/Simulation/Simulation.hpp",
"diff": "@@ -25,10 +25,10 @@ struct Simulation : Launcher\n{\npublic:\n// ------------------------------------------------------------------------------------------------- PARAMETERS\n- // for the snr\n+ // required arg\nstd::vector<float> snr_range;\n- // other parameters\n+ // optional parameters\n#ifdef ENABLE_MPI\nstd::chrono::milliseconds mpi_comm_freq = std::chrono::milliseconds(1000);\nint mpi_rank = 0;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Remove the step as link to snr-range
|
8,483 |
06.04.2018 16:28:11
| -7,200 |
05f70b0f1e3bb06d7a7dbd1f0a46b966c29a631c
|
Create a Matlab_vector list argument type as a 2D list with specific splitters; Use it in Simulation and Exit factories
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/EXIT/EXIT.cpp",
"new_path": "src/Factory/Simulation/EXIT/EXIT.cpp",
"diff": "@@ -120,10 +120,7 @@ void EXIT::parameters\nargs.add(\n{p+\"-siga-range\"},\n- tools::List2D<float,sigma_range_D1_splitter,sigma_range_D2_splitter>(\n- tools::Real(),\n- std::make_tuple(tools::Length(1)),\n- std::make_tuple(tools::Length(1,3))),\n+ tools::Matlab_vector<float>(tools::Real(), std::make_tuple(tools::Length(1)), std::make_tuple(tools::Length(1,3))),\n\"sigma range used in EXIT charts (Matlab style: \\\"0.5:2.5,2.55,2.6:0.05:3\\\" with a default step of 0.1).\",\ntools::Argument_info::REQUIRED);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/Simulation.cpp",
"new_path": "src/Factory/Simulation/Simulation.cpp",
"diff": "@@ -59,10 +59,7 @@ void Simulation::parameters\nargs.add(\n{p+\"-snr-range\", \"R\"},\n- tools::List2D<float,SNR_range_D1_splitter,SNR_range_D2_splitter>(\n- tools::Real(),\n- std::make_tuple(tools::Length(1)),\n- std::make_tuple(tools::Length(1,3))),\n+ tools::Matlab_vector<float>(tools::Real(), std::make_tuple(tools::Length(1)), std::make_tuple(tools::Length(1,3))),\n\"signal/noise ratio range to run (Matlab style: \\\"0.5:2.5,2.55,2.6:0.05:3\\\" with a default step of 0.1).\",\ntools::Argument_info::REQUIRED);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Arguments/Splitter/Splitter.hpp",
"new_path": "src/Tools/Arguments/Splitter/Splitter.hpp",
"diff": "@@ -54,7 +54,7 @@ struct Splitter\n}\n};\n-struct Generic_splitter : Splitter\n+struct Generic_splitter\n{\nstatic std::vector<std::string> split(const std::string& val)\n{\n@@ -79,6 +79,34 @@ struct String_splitter\n}\n};\n+struct Matlab_style_splitter\n+{\n+ struct D1\n+ {\n+ static std::vector<std::string> split(const std::string& val)\n+ {\n+ const std::string head = \"{([\";\n+ const std::string queue = \"})]\";\n+ const std::string separator = \",;\";\n+\n+ return Splitter::split(val, head, queue, separator);\n+ }\n+ };\n+\n+ struct D2\n+ {\n+ static std::vector<std::string> split(const std::string& val)\n+ {\n+ const std::string head = \"\";\n+ const std::string queue = \"\";\n+ const std::string separator = \":\";\n+\n+ return Splitter::split(val, head, queue, separator);\n+ }\n+ };\n+};\n+\n+\n}\n}\n#endif /* ARGUMENT_SPLITTER_HPP_ */\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Arguments/Types/Container/List.hpp",
"new_path": "src/Tools/Arguments/Types/Container/List.hpp",
"diff": "@@ -140,12 +140,24 @@ List_type<T,S,Ranges...>* List(Argument_type* val_type, Ranges*... ranges)\ntemplate <typename T = std::string,\nclass S1 = Generic_splitter, class S2 = String_splitter,\ntypename... Ranges1, typename... Ranges2>\n-List_type<std::vector<T>,S1,Ranges1...>* List2D(Argument_type* val_type, std::tuple<Ranges1*...>&& ranges1 = std::tuple<>(), std::tuple<Ranges2*...>&& ranges2 = std::tuple<>())\n+List_type<std::vector<T>, S1, Ranges1...>*\n+List2D(Argument_type* val_type,\n+ const std::tuple<Ranges1*...>& ranges1 = std::tuple<>(),\n+ const std::tuple<Ranges2*...>& ranges2 = std::tuple<>())\n{\nArgument_type* listD2 = apply_tuple(List<T,S2,Ranges2...>, std::tuple_cat(std::make_tuple(val_type), ranges2));\nreturn apply_tuple(List<std::vector<T>,S1,Ranges1...>, std::tuple_cat(std::make_tuple(listD2), ranges1));\n}\n+template <typename T = std::string, typename... Ranges1, typename... Ranges2>\n+List_type<std::vector<T>, Matlab_style_splitter::D1, Ranges1...>*\n+Matlab_vector(Argument_type* val_type,\n+ const std::tuple<Ranges1*...>& ranges1 = std::tuple<>(),\n+ const std::tuple<Ranges2*...>& ranges2 = std::tuple<>())\n+{\n+ return List2D<T, Matlab_style_splitter::D1, Matlab_style_splitter::D2>(val_type, ranges1, ranges2);\n+}\n+\n}\n}\n#endif /* ARGUMENT_TYPE_LIST_HPP_ */\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Create a Matlab_vector list argument type as a 2D list with specific splitters; Use it in Simulation and Exit factories
|
8,483 |
06.04.2018 17:32:26
| -7,200 |
52df72cebc7a23d8add18980a2d508695825b3f2
|
Create an argument_link struct to contain the tags and a callback; Add a conditional link to dec-h-path with ent-type LDPC_DVBS2
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.cpp",
"new_path": "src/Factory/Module/Decoder/LDPC/Decoder_LDPC.cpp",
"diff": "@@ -49,7 +49,8 @@ void Decoder_LDPC::parameters\nargs.add(\n{p+\"-h-path\"},\ntools::File(tools::openmode::read),\n- \"path to the H matrix (AList or QC formated file).\");\n+ \"path to the H matrix (AList or QC formated file).\",\n+ tools::Argument_info::REQUIRED);\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"
},
{
"change_type": "MODIFY",
"old_path": "src/Launcher/Code/LDPC/LDPC.cpp",
"new_path": "src/Launcher/Code/LDPC/LDPC.cpp",
"diff": "@@ -27,6 +27,14 @@ LDPC<L,B,R,Q>\n{\n}\n+bool enc_dvb_no_h_matrix(const void*, const void* enc_type)\n+{\n+ if (enc_type == nullptr)\n+ return false;\n+\n+ return *(const std::string*)enc_type == \"LDPC_DVBS2\";\n+}\n+\ntemplate <class L, typename B, typename R, typename Q>\nvoid LDPC<L,B,R,Q>\n::get_description_args()\n@@ -34,10 +42,14 @@ void LDPC<L,B,R,Q>\nparams_cdc->get_description(this->args);\nauto penc = params_cdc->enc->get_prefix();\n+ auto pdec = params_cdc->dec->get_prefix();\nthis->args.erase({penc+\"-fra\", \"F\"});\nthis->args.erase({penc+\"-seed\", \"S\"});\n+ this->args.add_link({pdec+\"-h-path\"}, {penc+\"-type\"}, enc_dvb_no_h_matrix);\n+\n+\nL::get_description_args();\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Arguments/Argument_handler.cpp",
"new_path": "src/Tools/Arguments/Argument_handler.cpp",
"diff": "@@ -41,12 +41,22 @@ bool Argument_handler\nsize_t tag_link_pos = 0;\nwhile((tag_link_pos = links.find(tag, tag_link_pos)) < links.size())\n{\n- auto tag_pair = links[tag_link_pos];\n- auto other_tag = (tag_pair.first == tag) ? tag_pair.second : tag_pair.first;\n+ const auto& link = links[tag_link_pos];\n+ auto other_tag = link.other_tag(tag);\n- if (arg_v.exist(other_tag)) // the other argument has been given\n+ if (arg_v.exist(other_tag))\n+ { // the other argument has been given\n+ if (link.callback == nullptr)\nreturn true;\n+ auto val = arg_v.at(other_tag);\n+\n+ if (link.is_first_tag(tag))\n+ return link.callback(nullptr, (const void*)&val);\n+ else\n+ return link.callback((const void*)&val, nullptr);\n+ }\n+\ntag_link_pos++;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Arguments/Maps/Argument_links.cpp",
"new_path": "src/Tools/Arguments/Maps/Argument_links.cpp",
"diff": "#include <stdexcept>\n+#include <utility>\n#include <algorithm>\n#include \"Argument_links.hpp\"\nusing namespace aff3ct::tools;\n+Argument_link\n+::Argument_link(const Argument_tag& first, const Argument_tag& second, bool (*callback)(const void*, const void*))\n+: first(first), second(second), callback(callback)\n+{\n+ if (first.size() == 0)\n+ throw std::invalid_argument(\"No tag has been given ('first.size()' == 0).\");\n+\n+ if (second.size() == 0)\n+ throw std::invalid_argument(\"No second has been given ('second.size()' == 0).\");\n+\n+ if (first == second)\n+ throw std::invalid_argument(\"first can't be identical to second.\");\n+\n+}\n+\n+Argument_link\n+::Argument_link(Argument_link&& other)\n+: first(other.first), second(other.second), callback(other.callback)\n+{\n+\n+}\n+\n+bool Argument_link\n+::operator==(const Argument_link& link) const\n+{\n+ return (first == link.first && second == link.second) || (first == link.second && second == link.first);\n+}\n+\n+bool Argument_link\n+::operator==(const Argument_tag& tag) const\n+{\n+ return (first == tag) || (second == tag);\n+}\n+\n+const Argument_tag& Argument_link\n+::other_tag(const Argument_tag& tag) const\n+{\n+ return (first == tag) ? second : first;\n+}\n+\n+bool Argument_link\n+::is_first_tag(const Argument_tag& tag) const\n+{\n+ return first == tag;\n+}\n+\nArgument_links\n::Argument_links()\n@@ -16,42 +63,26 @@ Argument_links\n}\nvoid Argument_links\n-::add(const Argument_tag& tag1, const Argument_tag& tag2)\n+::add(const Argument_tag& tag1, const Argument_tag& tag2, bool (*callback)(const void*, const void*))\n{\n- add(std::make_pair(tag1, tag2));\n-}\n+ Argument_link new_link(tag1, tag2, callback);\n-void Argument_links\n-::add(const std::pair<Argument_tag, Argument_tag>& tags)\n-{\n- if (!find(tags))\n- this->push_back(tags);\n+ if (!find(new_link))\n+ this->push_back(std::move(new_link));\n}\nbool Argument_links\n::find(const Argument_tag& tag1, const Argument_tag& tag2) const\n{\n- return find(std::make_pair(tag1, tag2));\n+ Argument_link link(tag1, tag2);\n+\n+ return find(link);\n}\nbool Argument_links\n-::find(const std::pair<Argument_tag, Argument_tag>& tags) const\n+::find(const Argument_link& link) const\n{\n- if (tags.first.size() == 0)\n- throw std::invalid_argument(\"No tags.first has been given ('tags.first.size()' == 0).\");\n-\n- if (tags.second.size() == 0)\n- throw std::invalid_argument(\"No tags.second has been given ('tags.second.size()' == 0).\");\n-\n- if (tags.first == tags.second)\n- throw std::invalid_argument(\"tags can't be identical.\");\n-\n- auto it = std::find(this->begin(), this->end(), tags);\n-\n- if (it == this->end())\n- it = std::find(this->begin(), this->end(), std::make_pair(tags.second, tags.first));\n-\n- return it != this->end();\n+ return std::find(this->begin(), this->end(), link) != this->end();\n}\nsize_t Argument_links\n@@ -61,9 +92,9 @@ size_t Argument_links\nwhile (i < this->size())\n{\n- auto val = *(this->data() + i);\n+ const auto& link = *(this->data() + i);\n- if (val.first == tag || val.second == tag)\n+ if (link == tag)\nbreak;\ni++;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Arguments/Maps/Argument_links.hpp",
"new_path": "src/Tools/Arguments/Maps/Argument_links.hpp",
"diff": "@@ -11,7 +11,24 @@ namespace aff3ct\nnamespace tools\n{\n-class Argument_links : public std::vector<std::pair<Argument_tag, Argument_tag>>\n+struct Argument_link\n+{\n+ Argument_tag first;\n+ Argument_tag second;\n+ bool (*callback)(const void*, const void*);\n+\n+ Argument_link(const Argument_tag& first, const Argument_tag& second, bool (*callback)(const void*, const void*) = nullptr);\n+ Argument_link(Argument_link&& other);\n+\n+ bool operator==(const Argument_link& link) const;\n+ bool operator==(const Argument_tag& tag) const;\n+\n+ const Argument_tag& other_tag(const Argument_tag& tag) const;\n+ bool is_first_tag(const Argument_tag& tag) const;\n+};\n+\n+\n+class Argument_links : public std::vector<Argument_link>\n{\npublic:\nusing mother_t = std::vector<value_type>;\n@@ -21,11 +38,11 @@ public:\nvirtual ~Argument_links();\n- void add(const Argument_tag& tag1, const Argument_tag& tag2);\n- void add(const std::pair<Argument_tag, Argument_tag>& tags);\n+ void add(const Argument_tag& tag1, const Argument_tag& tag2, bool (*callback)(const void*, const void*) = nullptr);\nbool find(const Argument_tag& tag1, const Argument_tag& tag2) const;\n- bool find(const std::pair<Argument_tag, Argument_tag>& tags) const;\n+\n+ bool find(const Argument_link& link) const;\nsize_t find(const Argument_tag& tag, const size_t first_pos = 0) const;\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Arguments/Maps/Argument_map_info.cpp",
"new_path": "src/Tools/Arguments/Maps/Argument_map_info.cpp",
"diff": "@@ -44,9 +44,9 @@ void Argument_map_info\n}\nvoid Argument_map_info\n-::add_link(const Argument_tag& tag1, const Argument_tag& tag2)\n+::add_link(const Argument_tag& tag1, const Argument_tag& tag2, bool (*callback)(const void*, const void*))\n{\n- links.add(tag1,tag2);\n+ links.add(tag1, tag2, callback);\n}\nbool Argument_map_info\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Arguments/Maps/Argument_map_info.hpp",
"new_path": "src/Tools/Arguments/Maps/Argument_map_info.hpp",
"diff": "@@ -34,7 +34,7 @@ public:\nvoid add(const Argument_tag& tags, Argument_type* arg_t, const std::string& doc,\nconst Argument_info::Rank rank = Argument_info::OPTIONAL);\n- void add_link(const Argument_tag& tag1, const Argument_tag& tag2);\n+ void add_link(const Argument_tag& tag1, const Argument_tag& tag2, bool (*callback)(const void*, const void*) = nullptr);\nbool has_link(const Argument_tag& tag) const;\nconst Argument_links& get_links() const;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Create an argument_link struct to contain the tags and a callback; Add a conditional link to dec-h-path with ent-type LDPC_DVBS2
|
8,483 |
09.04.2018 09:26:40
| -7,200 |
68ae69c87f1e8b75febad50ec85620d4d68c11dd
|
Fix return type error of clone method and add tools namespace call for apply_tuple
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Arguments/Types/Container/List.hpp",
"new_path": "src/Tools/Arguments/Types/Container/List.hpp",
"diff": "@@ -47,7 +47,7 @@ public:\n}\ntemplate <typename... NewRanges>\n- Integer_type<T, S, Ranges..., NewRanges...>*\n+ List_type<T, S, Ranges..., NewRanges...>*\nclone(NewRanges*... new_ranges)\n{\nauto* clone = new List_type<T, S, Ranges..., NewRanges...>(val_type);\n@@ -145,8 +145,8 @@ List2D(Argument_type* val_type,\nconst std::tuple<Ranges1*...>& ranges1 = std::tuple<>(),\nconst std::tuple<Ranges2*...>& ranges2 = std::tuple<>())\n{\n- Argument_type* listD2 = apply_tuple(List<T,S2,Ranges2...>, std::tuple_cat(std::make_tuple(val_type), ranges2));\n- return apply_tuple(List<std::vector<T>,S1,Ranges1...>, std::tuple_cat(std::make_tuple(listD2), ranges1));\n+ Argument_type* listD2 = tools::apply_tuple(List<T,S2,Ranges2...>, std::tuple_cat(std::make_tuple(val_type), ranges2));\n+ return tools::apply_tuple(List<std::vector<T>,S1,Ranges1...>, std::tuple_cat(std::make_tuple(listD2), ranges1));\n}\ntemplate <typename T = std::string, typename... Ranges1, typename... Ranges2>\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix return type error of clone method and add tools namespace call for apply_tuple
|
8,483 |
09.04.2018 10:31:59
| -7,200 |
4d8b5287b274c40078f1c8fa64fbb5896e202d54
|
Add a semantic move List2D fonction
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Arguments/Types/Container/List.hpp",
"new_path": "src/Tools/Arguments/Types/Container/List.hpp",
"diff": "@@ -149,6 +149,18 @@ List2D(Argument_type* val_type,\nreturn tools::apply_tuple(List<std::vector<T>,S1,Ranges1...>, std::tuple_cat(std::make_tuple(listD2), ranges1));\n}\n+template <typename T = std::string,\n+ class S1 = Generic_splitter, class S2 = String_splitter,\n+ typename... Ranges1, typename... Ranges2>\n+List_type<std::vector<T>, S1, Ranges1...>*\n+List2D(Argument_type* val_type,\n+ std::tuple<Ranges1*...>&& ranges1 = std::tuple<>(),\n+ std::tuple<Ranges2*...>&& ranges2 = std::tuple<>())\n+{\n+ Argument_type* listD2 = tools::apply_tuple(List<T,S2,Ranges2...>, std::tuple_cat(std::make_tuple(val_type), std::forward(ranges2)));\n+ return tools::apply_tuple(List<std::vector<T>,S1,Ranges1...>, std::tuple_cat(std::make_tuple(listD2), std::forward(ranges1)));\n+}\n+\ntemplate <typename T = std::string, typename... Ranges1, typename... Ranges2>\nList_type<std::vector<T>, Matlab_style_splitter::D1, Ranges1...>*\nMatlab_vector(Argument_type* val_type,\n@@ -158,6 +170,15 @@ Matlab_vector(Argument_type* val_type,\nreturn List2D<T, Matlab_style_splitter::D1, Matlab_style_splitter::D2>(val_type, ranges1, ranges2);\n}\n+template <typename T = std::string, typename... Ranges1, typename... Ranges2>\n+List_type<std::vector<T>, Matlab_style_splitter::D1, Ranges1...>*\n+Matlab_vector(Argument_type* val_type,\n+ std::tuple<Ranges1*...>&& ranges1 = std::tuple<>(),\n+ std::tuple<Ranges2*...>&& ranges2 = std::tuple<>())\n+{\n+ return List2D<T, Matlab_style_splitter::D1, Matlab_style_splitter::D2>(val_type, std::forward(ranges1), std::forward(ranges2));\n+}\n+\n}\n}\n#endif /* ARGUMENT_TYPE_LIST_HPP_ */\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a semantic move List2D fonction
|
8,483 |
09.04.2018 10:41:26
| -7,200 |
81a9f2c2ba514810db870d050b4dd199b83c884e
|
Add template to forward calls
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Arguments/Types/Container/List.hpp",
"new_path": "src/Tools/Arguments/Types/Container/List.hpp",
"diff": "@@ -157,8 +157,8 @@ List2D(Argument_type* val_type,\nstd::tuple<Ranges1*...>&& ranges1 = std::tuple<>(),\nstd::tuple<Ranges2*...>&& ranges2 = std::tuple<>())\n{\n- Argument_type* listD2 = tools::apply_tuple(List<T,S2,Ranges2...>, std::tuple_cat(std::make_tuple(val_type), std::forward(ranges2)));\n- return tools::apply_tuple(List<std::vector<T>,S1,Ranges1...>, std::tuple_cat(std::make_tuple(listD2), std::forward(ranges1)));\n+ Argument_type* listD2 = tools::apply_tuple(List<T,S2,Ranges2...>, std::tuple_cat(std::make_tuple(val_type), std::forward<std::tuple<Ranges2*...>>(ranges2)));\n+ return tools::apply_tuple(List<std::vector<T>,S1,Ranges1...>, std::tuple_cat(std::make_tuple(listD2), std::forward<std::tuple<Ranges1*...>>(ranges1)));\n}\ntemplate <typename T = std::string, typename... Ranges1, typename... Ranges2>\n@@ -176,7 +176,7 @@ Matlab_vector(Argument_type* val_type,\nstd::tuple<Ranges1*...>&& ranges1 = std::tuple<>(),\nstd::tuple<Ranges2*...>&& ranges2 = std::tuple<>())\n{\n- return List2D<T, Matlab_style_splitter::D1, Matlab_style_splitter::D2>(val_type, std::forward(ranges1), std::forward(ranges2));\n+ return List2D<T, Matlab_style_splitter::D1, Matlab_style_splitter::D2>(val_type, std::forward<std::tuple<Ranges1*...>>(ranges1), std::forward<std::tuple<Ranges2*...>>(ranges2));\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add template to forward calls
|
8,483 |
09.04.2018 18:31:38
| -7,200 |
4d82060c629fdaf5b3df01a40569c4e09ce74f0b
|
Fix modem optical and User_pdf_noise_generator_std for MSVC
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/Optical/Modem_optical.cpp",
"new_path": "src/Module/Modem/Optical/Modem_optical.cpp",
"diff": "@@ -23,7 +23,7 @@ Modem_optical<B,R,Q>\nconst std::string name = \"Modem_optical\";\nthis->set_name(name);\n- this->set_sigma(ROP);\n+ this->set_noise(0,0,ROP);\n}\ntemplate <typename B, typename R, typename Q>\n"
},
{
"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": "#include \"Tools/Math/interpolation.h\"\n#include \"User_pdf_noise_generator_std.hpp\"\n+using namespace aff3ct;\nusing namespace aff3ct::tools;\ntemplate <typename R>\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix modem optical and User_pdf_noise_generator_std for MSVC
|
8,483 |
09.04.2018 18:36:12
| -7,200 |
747d3c6385838c40f779735d9d4cb6b8d551793e
|
Fix set noise in Modem Optical
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/Optical/Modem_optical.cpp",
"new_path": "src/Module/Modem/Optical/Modem_optical.cpp",
"diff": "@@ -23,8 +23,15 @@ Modem_optical<B,R,Q>\nconst std::string name = \"Modem_optical\";\nthis->set_name(name);\n+ try\n+ {\nthis->set_noise(0,0,ROP);\n}\n+ catch(tools::invalid_argument&)\n+ {\n+\n+ }\n+}\ntemplate <typename B, typename R, typename Q>\nModem_optical<B,R,Q>\n@@ -112,6 +119,9 @@ void Modem_optical<B,R,Q>\nconst Q min_value = 1e-10; // when prob_1 ou prob_0 = 0;\n+ if (current_dist == nullptr)\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, \"No valid noise has been set.\");\n+\nconst auto& pdf_x = current_dist->get_pdf_x();\nconst auto& pdf_y0 = current_dist->get_pdf_y()[0];\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix set noise in Modem Optical
|
8,483 |
10.04.2018 08:57:54
| -7,200 |
2cfbdd5672bc9d8343b42d55116cee106281b167
|
Do not display the path anymore when OPTICAL channel
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Channel/Channel.cpp",
"new_path": "src/Factory/Module/Channel/Channel.cpp",
"diff": "@@ -143,7 +143,7 @@ void Channel::parameters\nif (this->sigma != -1.f)\nheaders[p].push_back(std::make_pair(\"Sigma value\", std::to_string(this->sigma)));\n- if (this->type == \"USER\" || this->type == \"OPTICAL\" || this->type == \"RAYLEIGH_USER\")\n+ if (this->type == \"USER\" || this->type == \"RAYLEIGH_USER\")\nheaders[p].push_back(std::make_pair(\"Path\", this->path));\nif (this->type == \"RAYLEIGH_USER\")\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Do not display the path anymore when OPTICAL channel
|
8,483 |
10.04.2018 10:04:28
| -7,200 |
d7ab02d351df1488df52b7331a18e44df4400a8a
|
Remove string splitters from factories
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/EXIT/EXIT.cpp",
"new_path": "src/Factory/Simulation/EXIT/EXIT.cpp",
"diff": "@@ -87,30 +87,6 @@ std::vector<std::string> EXIT::parameters\nreturn p;\n}\n-struct sigma_range_D1_splitter : tools::Splitter\n-{\n- static std::vector<std::string> split(const std::string& val)\n- {\n- const std::string head = \"{([\";\n- const std::string queue = \"})]\";\n- const std::string separator = \",\";\n-\n- return Splitter::split(val, head, queue, separator);\n- }\n-};\n-\n-struct sigma_range_D2_splitter : tools::Splitter\n-{\n- static std::vector<std::string> split(const std::string& val)\n- {\n- const std::string head = \"\";\n- const std::string queue = \"\";\n- const std::string separator = \":\";\n-\n- return Splitter::split(val, head, queue, separator);\n- }\n-};\n-\nvoid EXIT::parameters\n::get_description(tools::Argument_map_info &args) const\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/Simulation.cpp",
"new_path": "src/Factory/Simulation/Simulation.cpp",
"diff": "@@ -26,30 +26,6 @@ Simulation::parameters\n{\n}\n-struct SNR_range_D1_splitter : tools::Splitter\n-{\n- static std::vector<std::string> split(const std::string& val)\n- {\n- const std::string head = \"{([\";\n- const std::string queue = \"})]\";\n- const std::string separator = \",\";\n-\n- return Splitter::split(val, head, queue, separator);\n- }\n-};\n-\n-struct SNR_range_D2_splitter : tools::Splitter\n-{\n- static std::vector<std::string> split(const std::string& val)\n- {\n- const std::string head = \"\";\n- const std::string queue = \"\";\n- const std::string separator = \":\";\n-\n- return Splitter::split(val, head, queue, separator);\n- }\n-};\n-\nvoid Simulation::parameters\n::get_description(tools::Argument_map_info &args) const\n{\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Remove string splitters from factories
|
8,483 |
11.04.2018 13:10:41
| -7,200 |
183ac9e314b553f314a7feedfcc1bd85edfea42a
|
Change noise type EB/ES to EBN0/ESN0; Use get_sigma instead of checking if it is the right type in Channel and Modem
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/BFER/BFER.cpp",
"new_path": "src/Factory/Simulation/BFER/BFER.cpp",
"diff": "@@ -99,8 +99,8 @@ void BFER::parameters\nargs.add(\n{p+\"-noise-type\", \"E\"},\n- tools::Text(tools::Including_set(\"ES\", \"EB\", \"ROP\", \"EP\")),\n- \"select the type of NOISE: Energy per Symbol / Energy per information Bit\"\n+ tools::Text(tools::Including_set(\"ESN0\", \"EBN0\", \"ROP\", \"EP\")),\n+ \"select the type of NOISE: SNR per Symbol / SNR per information Bit\"\n\" / Received Optical Power / Erasure Probability.\");\nargs.add(\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/AWGN/Channel_AWGN_LLR.cpp",
"new_path": "src/Module/Channel/AWGN/Channel_AWGN_LLR.cpp",
"diff": "@@ -44,14 +44,6 @@ template <typename R>\nvoid Channel_AWGN_LLR<R>\n::add_noise(const R *X_N, R *Y_N, const int frame_id)\n{\n- if (this->n.get_type() != tools::Noise_type::SIGMA)\n- {\n- std::stringstream message;\n- message << \"The given noise does not represent a 'SIGMA' type ('n.get_type()' = \"\n- << this->n.type2str(this->n.get_type()) << \").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\nif (add_users && this->n_frames > 1)\n{\nif (frame_id != -1)\n@@ -61,7 +53,7 @@ void Channel_AWGN_LLR<R>\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- noise_generator->generate(this->noise.data(), this->N, this->n.get_noise());\n+ noise_generator->generate(this->noise.data(), this->N, this->n.get_sigma()); // trow if noise is not SIGMA type\nstd::fill(Y_N, Y_N + this->N, (R)0);\nfor (auto f = 0; f < this->n_frames; f++)\n@@ -77,9 +69,9 @@ void Channel_AWGN_LLR<R>\nconst auto f_stop = (frame_id < 0) ? this->n_frames : f_start +1;\nif (frame_id < 0)\n- noise_generator->generate(this->noise, this->n.get_noise());\n+ noise_generator->generate(this->noise, this->n.get_sigma());// trow if noise is not SIGMA type\nelse\n- noise_generator->generate(this->noise.data() + f_start * this->N, this->N, this->n.get_noise());\n+ noise_generator->generate(this->noise.data() + f_start * this->N, this->N, this->n.get_sigma());// trow if noise is not SIGMA type\nfor (auto f = f_start; f < f_stop; f++)\nfor (auto n = 0; n < this->N; n++)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/Rayleigh/Channel_Rayleigh_LLR.cpp",
"new_path": "src/Module/Channel/Rayleigh/Channel_Rayleigh_LLR.cpp",
"diff": "@@ -64,14 +64,6 @@ template <typename R>\nvoid Channel_Rayleigh_LLR<R>\n::add_noise_wg(const R *X_N, R *H_N, R *Y_N, const int frame_id)\n{\n- if (this->n.get_type() != tools::Noise_type::SIGMA)\n- {\n- std::stringstream message;\n- message << \"The given noise does not represent a 'SIGMA' type ('n.get_type()' = \"\n- << this->n.type2str(this->n.get_type()) << \").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\nif (add_users && this->n_frames > 1)\n{\nif (frame_id != -1)\n@@ -82,7 +74,7 @@ void Channel_Rayleigh_LLR<R>\n}\nnoise_generator->generate(this->gains, (R)1 / (R)std::sqrt((R)2));\n- noise_generator->generate(this->noise.data(), this->N, this->n.get_noise());\n+ noise_generator->generate(this->noise.data(), this->N, this->n.get_sigma()); // trow if noise is not SIGMA type\nstd::fill(Y_N, Y_N + this->N, (R)0);\n@@ -125,12 +117,12 @@ void Channel_Rayleigh_LLR<R>\nif (frame_id < 0)\n{\nnoise_generator->generate(this->gains, (R)1 / (R)std::sqrt((R)2));\n- noise_generator->generate(this->noise, this->n.get_noise());\n+ noise_generator->generate(this->noise, this->n.get_sigma()); // trow if noise is not SIGMA type\n}\nelse\n{\nnoise_generator->generate(this->gains.data() + f_start * this->N, this->N, (R)1 / (R)std::sqrt((R)2));\n- noise_generator->generate(this->noise.data() + f_start * this->N, this->N, this->n.get_noise());\n+ noise_generator->generate(this->noise.data() + f_start * this->N, this->N, this->n.get_sigma()); // trow if noise is not SIGMA type\n}\nif (this->complex)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/Rayleigh/Channel_Rayleigh_LLR_user.cpp",
"new_path": "src/Module/Channel/Rayleigh/Channel_Rayleigh_LLR_user.cpp",
"diff": "@@ -102,14 +102,6 @@ template <typename R>\nvoid Channel_Rayleigh_LLR_user<R>\n::add_noise_wg(const R *X_N, R *H_N, R *Y_N, const int frame_id)\n{\n- if (this->n.get_type() != tools::Noise_type::SIGMA)\n- {\n- std::stringstream message;\n- message << \"The given noise does not represent a 'SIGMA' type ('n.get_type()' = \"\n- << this->n.type2str(this->n.get_type()) << \").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\nif (frame_id != -1)\n{\nstd::stringstream message;\n@@ -134,7 +126,7 @@ void Channel_Rayleigh_LLR_user<R>\n}\n// generate the noise\n- noise_generator->generate(this->noise, this->n.get_noise());\n+ noise_generator->generate(this->noise, this->n.get_sigma()); // trow if noise is not SIGMA type\n// use the noise and the gain to modify the signal\nfor (auto i = 0; i < this->N * this->n_frames; i++)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/BPSK/Modem_BPSK.cpp",
"new_path": "src/Module/Modem/BPSK/Modem_BPSK.cpp",
"diff": "@@ -33,15 +33,7 @@ void Modem_BPSK<B,R,Q>\n{\nModem<B,R,Q>::set_noise(noise);\n- if (this->n.get_type() != tools::Noise_type::SIGMA)\n- {\n- std::stringstream message;\n- message << \"The given noise does not represent a 'SIGMA' type ('n.get_type()' = \"\n- << this->n.type2str(this->n.get_type()) << \").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- two_on_square_sigma = (R)2.0 / (this->n.get_noise() * this->n.get_noise());\n+ two_on_square_sigma = (R)2.0 / (this->n.get_sigma() * this->n.get_sigma()); // trow if noise is not SIGMA type\n}\ntemplate <typename B, typename R, typename Q>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/BPSK/Modem_BPSK_fast.cpp",
"new_path": "src/Module/Modem/BPSK/Modem_BPSK_fast.cpp",
"diff": "@@ -34,15 +34,7 @@ void Modem_BPSK_fast<B,R,Q>\n{\nModem<B,R,Q>::set_noise(noise);\n- if (this->n.get_type() != tools::Noise_type::SIGMA)\n- {\n- std::stringstream message;\n- message << \"The given noise does not represent a 'SIGMA' type ('n.get_type()' = \"\n- << this->n.type2str(this->n.get_type()) << \").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- two_on_square_sigma = (R)2.0 / (this->n.get_noise() * this->n.get_noise());\n+ two_on_square_sigma = (R)2.0 / (this->n.get_sigma() * this->n.get_sigma()); // trow if noise is not SIGMA type\n}\n"
},
{
"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.is_set())\ngenerate_projection();\n}\n@@ -103,14 +103,6 @@ void Modem_CPM<B,R,Q,MAX>\n{\nModem<B,R,Q>::set_noise(noise);\n- if (this->n.get_type() != tools::Noise_type::SIGMA)\n- {\n- std::stringstream message;\n- message << \"The given noise does not represent a 'SIGMA' type ('n.get_type()' = \"\n- << this->n.type2str(this->n.get_type()) << \").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\nif (!no_sig2) this->generate_projection();\n}\n@@ -295,7 +287,7 @@ void Modem_CPM<B,R,Q,MAX>\nif (!this->n.is_set())\nthrow tools::runtime_error(__FILE__, __LINE__, __func__, \"No noise has been set\");\n- factor = (R)1 / (this->n.get_noise() * this->n.get_noise()); // 2 / sigma_complex^2\n+ factor = (R)1 / (this->n.get_sigma() * this->n.get_sigma()); // 2 / sigma_complex^2, trow if noise is not SIGMA type\n}\nif (cpm.filters_type == \"TOTAL\")\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/OOK/Modem_OOK.cpp",
"new_path": "src/Module/Modem/OOK/Modem_OOK.cpp",
"diff": "@@ -30,15 +30,7 @@ void Modem_OOK<B,R,Q>\n{\nModem<B,R,Q>::set_noise(noise);\n- if (this->n.get_type() != tools::Noise_type::SIGMA)\n- {\n- std::stringstream message;\n- message << \"The given noise does not represent a 'SIGMA' type ('n.get_type()' = \"\n- << this->n.type2str(this->n.get_type()) << \").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- this->sigma_factor = (R)2.0 * this->n.get_noise() * this->n.get_noise();\n+ this->sigma_factor = (R)2.0 * this->n.get_sigma() * this->n.get_sigma(); // trow if noise is not SIGMA type\n}\ntemplate <typename B, typename R, typename Q>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/PAM/Modem_PAM.hxx",
"new_path": "src/Module/Modem/PAM/Modem_PAM.hxx",
"diff": "@@ -54,15 +54,9 @@ void Modem_PAM<B,R,Q,MAX>\n{\nModem<B,R,Q>::set_noise(noise);\n- if (this->n.get_type() != tools::Noise_type::SIGMA)\n- {\n- std::stringstream message;\n- message << \"The given noise does not represent a 'SIGMA' type ('n.get_type()' = \"\n- << this->n.type2str(this->n.get_type()) << \").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- this->inv_sigma2 = this->disable_sig2 ? (R)1.0 : (R)((R)1.0 / ((R)2.0 * this->n.get_noise() * this->n.get_noise()));\n+ this->inv_sigma2 = this->disable_sig2 ?\n+ (R)1.0 :\n+ (R)((R)1.0 / ((R)2.0 * this->n.get_sigma() * this->n.get_sigma())); // trow if noise is not SIGMA type\n}\ntemplate <typename B, typename R, typename Q, tools::proto_max<Q> MAX>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/PSK/Modem_PSK.hxx",
"new_path": "src/Module/Modem/PSK/Modem_PSK.hxx",
"diff": "@@ -56,15 +56,9 @@ void Modem_PSK<B,R,Q,MAX>\n{\nModem<B,R,Q>::set_noise(noise);\n- if (this->n.get_type() != tools::Noise_type::SIGMA)\n- {\n- std::stringstream message;\n- message << \"The given noise does not represent a 'SIGMA' type ('n.get_type()' = \"\n- << this->n.type2str(this->n.get_type()) << \").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- this->inv_sigma2 = this->disable_sig2 ? (R)1.0 : (R)((R)1.0 / (2 * this->n.get_noise() * this->n.get_noise()));\n+ this->inv_sigma2 = this->disable_sig2 ?\n+ (R)1.0 :\n+ (R)((R)1.0 / (2 * this->n.get_sigma() * this->n.get_sigma())); // trow if noise is not SIGMA type\n}\ntemplate <typename B, typename R, typename Q, tools::proto_max<Q> MAX>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/QAM/Modem_QAM.hxx",
"new_path": "src/Module/Modem/QAM/Modem_QAM.hxx",
"diff": "@@ -79,15 +79,9 @@ void Modem_QAM<B,R,Q,MAX>\n{\nModem<B,R,Q>::set_noise(noise);\n- if (this->n.get_type() != tools::Noise_type::SIGMA)\n- {\n- std::stringstream message;\n- message << \"The given noise does not represent a 'SIGMA' type ('n.get_type()' = \"\n- << this->n.type2str(this->n.get_type()) << \").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- this->inv_sigma2 = this->disable_sig2 ? (R)1.0 : (R)((R)1.0 / (2 * this->n.get_noise() * this->n.get_noise()));\n+ this->inv_sigma2 = this->disable_sig2 ?\n+ (R)1.0 :\n+ (R)((R)1.0 / (2 * this->n.get_sigma() * this->n.get_sigma())); // trow if noise is not SIGMA type\n}\ntemplate <typename B,typename R, typename Q, tools::proto_max<Q> MAX>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/SCMA/Modem_SCMA.hxx",
"new_path": "src/Module/Modem/SCMA/Modem_SCMA.hxx",
"diff": "@@ -101,15 +101,9 @@ void Modem_SCMA<B,R,Q,PSI>\n{\nModem<B,R,Q>::set_noise(noise);\n- if (this->n.get_type() != tools::Noise_type::SIGMA)\n- {\n- std::stringstream message;\n- message << \"The given noise does not represent a 'SIGMA' type ('n.get_type()' = \"\n- << this->n.type2str(this->n.get_type()) << \").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n- this->n0 = this->disable_sig2 ? (R)1.0 : (R)((R)1.0 / ((R)4.0 * this->n.get_noise() * this->n.get_noise()));\n+ this->n0 = this->disable_sig2 ?\n+ (R)1.0 :\n+ (R)((R)1.0 / ((R)4.0 * this->n.get_sigma() * this->n.get_sigma())); // trow if noise is not SIGMA type\n}\ntemplate <typename B, typename R, typename Q, tools::proto_psi<Q> PSI>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/User/Modem_user.hxx",
"new_path": "src/Module/Modem/User/Modem_user.hxx",
"diff": "@@ -85,16 +85,11 @@ void Modem_user<B,R,Q,MAX>\n{\nModem<B,R,Q>::set_noise(noise);\n- if (this->n.get_type() != tools::Noise_type::SIGMA)\n- {\n- std::stringstream message;\n- message << \"The given noise does not represent a 'SIGMA' type ('n.get_type()' = \"\n- << this->n.type2str(this->n.get_type()) << \").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n+ this->inv_sigma2 = this->disable_sig2 ?\n+ (R)1.0 :\n+ (R)((R)1.0 / (2 * this->n.get_sigma() * this->n.get_sigma())); // trow if noise is not SIGMA type\n}\n- this->inv_sigma2 = this->disable_sig2 ? (R)1.0 : (R)((R)1.0 / (2 * this->n.get_noise() * this->n.get_noise()));\n-}\ntemplate <typename B,typename R, typename Q, tools::proto_max<Q> MAX>\nvoid Modem_user<B,R,Q,MAX>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.cpp",
"new_path": "src/Simulation/BFER/BFER.cpp",
"diff": "@@ -135,15 +135,15 @@ void BFER<B,R,Q>\n{\nauto n = params_BFER.noise_range[noise_idx];\n- if (params_BFER.noise_type == \"EB\" || params_BFER.noise_type == \"EB\")\n+ if (params_BFER.noise_type == \"EBN0\" || params_BFER.noise_type == \"EBN0\")\n{\nfloat esn0, ebn0;\n- if (params_BFER.noise_type == \"EB\")\n+ if (params_BFER.noise_type == \"EBN0\")\n{\nebn0 = n;\nesn0 = tools::ebn0_to_esn0(ebn0, bit_rate, params_BFER.mdm->bps);\n}\n- else // if (params_BFER.sim->noise_type == \"ES\")\n+ else // if (params_BFER.sim->noise_type == \"ESN0\")\n{\nesn0 = n;\nebn0 = tools::esn0_to_ebn0(esn0, bit_rate, params_BFER.mdm->bps);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Change noise type EB/ES to EBN0/ESN0; Use get_sigma instead of checking if it is the right type in Channel and Modem
|
8,483 |
11.04.2018 13:56:26
| -7,200 |
66943b4c390df8523ffdcc42eaff80b20054ff09
|
Update references; Change default noise_type to EBN0; Always instantiate Noise in float and double
|
[
{
"change_type": "MODIFY",
"old_path": "refs",
"new_path": "refs",
"diff": "-Subproject commit 1458f0418bcbae4b54be0de82b9806d30eed8e79\n+Subproject commit 27c289b4c3826ff773a32f70ceb571c70f597188\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/BFER/BFER.hpp",
"new_path": "src/Factory/Simulation/BFER/BFER.hpp",
"diff": "@@ -27,7 +27,7 @@ struct BFER : Simulation\npublic:\n// ------------------------------------------------------------------------------------------------- PARAMETERS\n// optional parameters\n- std::string noise_type = \"EB\";\n+ std::string noise_type = \"EBN0\";\nstd::string err_track_path = \"error_tracker\";\nint err_track_threshold = 0;\nbool err_track_revert = false;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Noise.cpp",
"new_path": "src/Tools/Noise.cpp",
"diff": "@@ -376,11 +376,6 @@ init()\n}\n// ==================================================================================== explicit template instantiation\n-#include \"Tools/types.h\"\n-#ifdef MULTI_PREC\n-template class aff3ct::tools::Noise<R_32>;\n-template class aff3ct::tools::Noise<R_64>;\n-#else\n-template class aff3ct::tools::Noise<R>;\n-#endif\n+template class aff3ct::tools::Noise<float>;\n+template class aff3ct::tools::Noise<double>;\n// ==================================================================================== explicit template instantiation\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Update references; Change default noise_type to EBN0; Always instantiate Noise in float and double
|
8,490 |
11.04.2018 14:55:08
| -7,200 |
aedf01242a2bd1e4871bf4c604395ed3e6339d24
|
Add CLI11 and rang header only libs.
|
[
{
"change_type": "MODIFY",
"old_path": ".gitmodules",
"new_path": ".gitmodules",
"diff": "[submodule \"refs\"]\npath = refs\nurl = ../error_rate_references\n+[submodule \"lib/CLI11\"]\n+ path = lib/CLI11\n+ url = https://github.com/CLIUtils/CLI11.git\n+[submodule \"lib/rang\"]\n+ path = lib/rang\n+ url = https://github.com/agauniyal/rang.git\n"
},
{
"change_type": "MODIFY",
"old_path": "CMakeLists.txt",
"new_path": "CMakeLists.txt",
"diff": "# CMake entry point\n-cmake_minimum_required (VERSION 3.0.2)\n+cmake_minimum_required (VERSION 3.4.0)\ncmake_policy(SET CMP0054 NEW)\nproject (aff3ct)\n@@ -70,6 +70,26 @@ else ()\n\"$ git submodule update --init -- ../lib/MIPP/\")\nendif ()\n+# rang header\n+if (EXISTS \"${CMAKE_CURRENT_SOURCE_DIR}/lib/rang/include/rang.hpp\")\n+ include_directories (\"${CMAKE_CURRENT_SOURCE_DIR}/lib/rang/include/\")\n+ message(STATUS \"rang found\")\n+else ()\n+ message(FATAL_ERROR \"rang can't be found, try to init the submodules with the following cmd:\\n\"\n+ \"$ git submodule update --init -- ../lib/rang/\")\n+endif ()\n+\n+# CLI11 header\n+if (EXISTS \"${CMAKE_CURRENT_SOURCE_DIR}/lib/CLI11/include/CLI/CLI.hpp\")\n+ include_directories (\"${CMAKE_CURRENT_SOURCE_DIR}/lib/CLI11/include/CLI/\")\n+ message(STATUS \"CLI11 found\")\n+ #add_subdirectory(lib/CLI11)\n+ #aff3ct_link_libraries(CLI11::CLI11)\n+else ()\n+ message(FATAL_ERROR \"CLI11 can't be found, try to init the submodules with the following cmd:\\n\"\n+ \"$ git submodule update --init -- ../lib/CLI11/\")\n+endif ()\n+\n# Object\nadd_library (aff3ct-obj OBJECT ${source_files})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/CLI11",
"diff": "+Subproject commit b519a13119358fc0cde28b070bf8984e814f8c4a\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/rang",
"diff": "+Subproject commit 49505595c6941ad58788ade0ecdff26aeb5b7a9a\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add CLI11 and rang header only libs.
|
8,483 |
11.04.2018 15:18:22
| -7,200 |
bf430b7bf53ef6060972ceadde4ba99e8611b188
|
Add copy/move constructors and =operator
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Noise.cpp",
"new_path": "src/Tools/Noise.cpp",
"diff": "@@ -9,59 +9,62 @@ using namespace tools;\ntemplate <typename R>\nNoise<R>::\nNoise()\n+: _t(Noise_type::SIGMA, false), _n((R)0., false), _ebn0((R)0., false), _esn0((R)0., false)\n{\n- init();\n+ // init();\n}\ntemplate <typename R>\nNoise<R>::\nNoise(const R noise, const Noise_type t)\n+: Noise()\n+// : _t(Noise_type::SIGMA, false), _n((R)0, false), _ebn0((R)0, false), _esn0((R)0, false)\n{\n- init();\n+ // init();\nset_noise(noise, t);\n}\n-// template <typename R>\n-// Noise<R>::\n-// Noise(const Noise& other)\n-// : _t (other._t ),\n-// _n (other._n ),\n-// _ebn0(other._ebn0),\n-// _esn0(other._esn0)\n-// {\n-// }\n-\n-// template <typename R>\n-// Noise<R>::\n-// Noise(Noise&& other)\n-// : _t (std::move(other._t )),\n-// _n (std::move(other._n )),\n-// _ebn0(std::move(other._ebn0)),\n-// _esn0(std::move(other._esn0))\n-// {\n-// }\n-\n-// template <typename R>\n-// Noise<R>& Noise<R>::\n-// operator=(const Noise& other)\n-// {\n-// _t = other._t ;\n-// _n = other._n ;\n-// _ebn0 = other._ebn0;\n-// _esn0 = other._esn0;\n-// return *this;\n-// }\n-\n-// template <typename R>\n-// Noise<R>& Noise<R>::\n-// operator=(Noise&& other)\n-// {\n-// _t = std::move(other._t );\n-// _n = std::move(other._n );\n-// _ebn0 = std::move(other._ebn0);\n-// _esn0 = std::move(other._esn0);\n-// return *this;\n-// }\n+template <typename R>\n+Noise<R>::\n+Noise(const Noise<R>& other)\n+: _t (other._t ),\n+ _n (other._n ),\n+ _ebn0(other._ebn0),\n+ _esn0(other._esn0)\n+{\n+}\n+\n+template <typename R>\n+Noise<R>::\n+Noise(Noise<R>&& other)\n+: _t (std::move(other._t )),\n+ _n (std::move(other._n )),\n+ _ebn0(std::move(other._ebn0)),\n+ _esn0(std::move(other._esn0))\n+{\n+}\n+\n+template <typename R>\n+Noise<R>& Noise<R>::\n+operator=(const Noise<R>& other)\n+{\n+ _t = other._t ;\n+ _n = other._n ;\n+ _ebn0 = other._ebn0;\n+ _esn0 = other._esn0;\n+ return *this;\n+}\n+\n+template <typename R>\n+Noise<R>& Noise<R>::\n+operator=(Noise<R>&& other)\n+{\n+ _t = std::move(other._t );\n+ _n = std::move(other._n );\n+ _ebn0 = std::move(other._ebn0);\n+ _esn0 = std::move(other._esn0);\n+ return *this;\n+}\ntemplate <typename R>\nNoise<R>::\n@@ -368,7 +371,6 @@ template <typename R>\nvoid Noise<R>::\ninit()\n{\n-\n_t.second = false;\n_n.second = false;\n_ebn0.second = false;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Noise.hpp",
"new_path": "src/Tools/Noise.hpp",
"diff": "@@ -18,8 +18,8 @@ class Noise\npublic:\nNoise();\nexplicit Noise(const R noise, const Noise_type t = Noise_type::SIGMA);\n- // Noise(const Noise& other);\n- // Noise(Noise&& other);\n+ Noise(const Noise<R>& other);\n+ Noise(Noise<R>&& other);\n~Noise();\nbool is_set () const throw();\n@@ -45,8 +45,8 @@ public:\nstatic Noise_type str2type(const std::string& str);\nstatic std::string type2str(const Noise_type& t);\n- // Noise& operator=(const Noise& other);\n- // Noise& operator=(Noise&& other);\n+ Noise& operator=(const Noise<R>& other);\n+ Noise& operator=(Noise<R>&& other);\nprotected:\nstd::pair<Noise_type, bool> _t;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add copy/move constructors and =operator
|
8,483 |
11.04.2018 16:59:33
| -7,200 |
2c65948b0e155bf694b5ec1ddbe61e8ada7064e3
|
init all values in Noise constructors
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Noise.cpp",
"new_path": "src/Tools/Noise.cpp",
"diff": "@@ -9,18 +9,15 @@ using namespace tools;\ntemplate <typename R>\nNoise<R>::\nNoise()\n-: _t(Noise_type::SIGMA, false), _n((R)0., false), _ebn0((R)0., false), _esn0((R)0., false)\n{\n- // init();\n+ init();\n}\ntemplate <typename R>\nNoise<R>::\nNoise(const R noise, const Noise_type t)\n-: Noise()\n-// : _t(Noise_type::SIGMA, false), _n((R)0, false), _ebn0((R)0, false), _esn0((R)0, false)\n{\n- // init();\n+ init();\nset_noise(noise, t);\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
init all values in Noise constructors
|
8,483 |
11.04.2018 17:00:01
| -7,200 |
c7e97de876703f12b4fd6ab97e542d23fdcf824a
|
Fix same values comparaisons EBN0 || ESN0
|
[
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.cpp",
"new_path": "src/Simulation/BFER/BFER.cpp",
"diff": "@@ -135,7 +135,7 @@ void BFER<B,R,Q>\n{\nauto n = params_BFER.noise_range[noise_idx];\n- if (params_BFER.noise_type == \"EBN0\" || params_BFER.noise_type == \"EBN0\")\n+ if (params_BFER.noise_type == \"EBN0\" || params_BFER.noise_type == \"ESN0\")\n{\nfloat esn0, ebn0;\nif (params_BFER.noise_type == \"EBN0\")\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix same values comparaisons EBN0 || ESN0
|
8,483 |
11.04.2018 17:00:32
| -7,200 |
6b977dd950099cbd123cf5b3ac9b6022597e55de
|
use is_set instead of has_type
|
[
{
"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.has_type()) this->set_noise(noise);\n+ if (noise.is_set()) 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.has_type()) this->set_noise(noise);\n+ if (noise.is_set()) 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.has_type()) this->set_noise(noise);\n+ if (noise.is_set()) this->set_noise(noise);\nthis->init_processes();\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
use is_set instead of has_type
|
8,483 |
11.04.2018 17:00:50
| -7,200 |
c0a96571ab516b4add8e71333b21b18111375a06
|
Instantiate the Noise object in Codec_polar instead of Codec
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/Codec.hpp",
"new_path": "src/Module/Codec/Codec.hpp",
"diff": "@@ -48,7 +48,7 @@ protected :\nconst int N_cw;\nconst int N;\nconst int tail_length;\n- tools::Noise<float> n;\n+ // tools::Noise<float> n;\npublic:\nCodec(const int K, const int N_cw, const int N, const int tail_length = 0, const int n_frames = 1);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/Codec.hxx",
"new_path": "src/Module/Codec/Codec.hxx",
"diff": "@@ -172,16 +172,16 @@ get_noise()\ntemplate <typename B, typename Q>\nvoid Codec<B,Q>\n-::set_noise(const tools::Noise<float>& n)\n+::set_noise(const tools::Noise<float>& noise)\n{\n- this->n = n;\n+ // this->n = noise;\n}\ntemplate <typename B, typename Q>\nvoid Codec<B,Q>\n-::set_noise(const tools::Noise<double>& n)\n+::set_noise(const tools::Noise<double>& noise)\n{\n- this->set_noise(tools::Noise<float>(n.get_noise(), n.get_type()));\n+ this->set_noise(tools::Noise<float>(noise.get_noise(), noise.get_type()));\n}\ntemplate <typename B, typename Q>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/Polar/Codec_polar.cpp",
"new_path": "src/Module/Codec/Polar/Codec_polar.cpp",
"diff": "@@ -164,14 +164,15 @@ void Codec_polar<B,Q>\ntemplate <typename B, typename Q>\nvoid Codec_polar<B,Q>\n-::set_noise(const tools::Noise<float>& n)\n+::set_noise(const tools::Noise<float>& noise)\n{\n- Codec_SISO_SIHO<B,Q>::set_noise(n);\n+ Codec_SISO_SIHO<B,Q>::set_noise(noise);\n+ this->n = noise;\n// adaptive frozen bits generation\nif (adaptive_fb && !generated_decoder)\n{\n- fb_generator->set_sigma(n.get_sigma()); // throw if noise is not of SIGMA type\n+ fb_generator->set_sigma(this->n.get_sigma()); // throw if noise is not of SIGMA type\nfb_generator->generate(frozen_bits);\nthis->notify_frozenbits_update();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/Polar/Codec_polar.hpp",
"new_path": "src/Module/Codec/Polar/Codec_polar.hpp",
"diff": "@@ -28,6 +28,7 @@ protected:\nPuncturer_polar_wangliu<B,Q> *puncturer_wangliu;\ntools::Frozenbits_notifier *fb_decoder;\ntools::Frozenbits_notifier *fb_encoder;\n+ tools::Noise<float> n;\npublic:\nCodec_polar(const factory::Frozenbits_generator::parameters &fb_par,\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Instantiate the Noise object in Codec_polar instead of Codec
|
8,483 |
12.04.2018 08:46:40
| -7,200 |
d573f77a34d0fd0c86b78981cea45832e74395be
|
Add Channel BEC. Fix channel.hxx constructor without noise. Add Modem OOK BEC demodulation
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Channel/Channel.cpp",
"new_path": "src/Factory/Module/Channel/Channel.cpp",
"diff": "#include \"Module/Channel/AWGN/Channel_AWGN_LLR.hpp\"\n#include \"Module/Channel/Rayleigh/Channel_Rayleigh_LLR.hpp\"\n#include \"Module/Channel/Rayleigh/Channel_Rayleigh_LLR_user.hpp\"\n+#include \"Module/Channel/BEC/Channel_BEC.hpp\"\n#include \"Tools/Algo/Gaussian_noise_generator/Standard/Gaussian_noise_generator_std.hpp\"\n#include \"Tools/Algo/Gaussian_noise_generator/Fast/Gaussian_noise_generator_fast.hpp\"\n@@ -58,7 +59,7 @@ void Channel::parameters\nargs.add(\n{p+\"-type\"},\n- tools::Text(tools::Including_set(\"NO\", \"USER\", \"AWGN\", \"RAYLEIGH\", \"RAYLEIGH_USER\")),\n+ tools::Text(tools::Including_set(\"NO\", \"USER\", \"AWGN\", \"RAYLEIGH\", \"RAYLEIGH_USER\", \"BEC\")),\n\"type of the channel to use in the simulation.\");\nargs.add(\n@@ -185,6 +186,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, noise, n_frames);\ndelete n;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Channel/BEC/Channel_BEC.cpp",
"diff": "+#include <type_traits>\n+#include \"Channel_BEC.hpp\"\n+\n+using namespace aff3ct::module;\n+\n+template <typename R>\n+Channel_BEC<R>\n+::Channel_BEC(const int N, const int seed, const tools::Noise<R>& noise, const int n_frames)\n+: Channel<R>(N, noise, n_frames), uni_dist((R)0, (R)1)\n+{\n+ const std::string name = \"Channel_BEC\";\n+ this->set_name(name);\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+ rd_engine.seed(seed);\n+}\n+\n+template <typename R>\n+Channel_BEC<R>\n+::~Channel_BEC()\n+{\n+}\n+\n+\n+template <typename R>\n+mipp::Reg<R> Channel_BEC<R>\n+::get_random_simd()\n+{\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, \"The MT19937 random generator does not support this type.\");\n+}\n+\n+template <typename R>\n+R Channel_BEC<R>\n+::get_random()\n+{\n+ return this->uni_dist(this->rd_engine);\n+}\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+template <>\n+mipp::Reg<float> Channel_BEC<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 module\n+{\n+template <>\n+float Channel_BEC<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 Channel_BEC<R>\n+::_add_noise(const R *X_N, R *Y_N, const int frame_id)\n+{\n+ const auto erasure_probability = this->n.get_ep();\n+ const auto erased_value = std::numeric_limits<R>::infinity();\n+\n+\n+ const mipp::Reg<R> r_erased = erased_value;\n+ const mipp::Reg<R> r_ep = erasure_probability;\n+\n+ const auto vec_loop_size = (std::is_same<R,float>::value) ? ((this->N / mipp::nElReg<R>()) * mipp::nElReg<R>()) : 0;\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_draw = get_random_simd();\n+ const auto r_out = mipp::blend(r_erased, r_in, r_draw <= r_ep);\n+ r_out.store(Y_N + i);\n+ }\n+\n+ for (auto i = vec_loop_size; i < this->N; i++)\n+ Y_N[i] = get_random() <= erasure_probability ? erased_value : X_N[i];\n+}\n+\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+#else\n+template class aff3ct::module::Channel_BEC<R>;\n+#endif\n+// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Module/Channel/BEC/Channel_BEC.hpp",
"diff": "+#ifndef CHANNEL_BEC_HPP_\n+#define CHANNEL_BEC_HPP_\n+\n+#include <vector>\n+#include <mipp.h>\n+\n+#include <random>\n+\n+#include \"Tools/Algo/PRNG/PRNG_MT19937.hpp\"\n+#include \"Tools/Algo/PRNG/PRNG_MT19937_simd.hpp\"\n+\n+#include \"../Channel.hpp\"\n+\n+namespace aff3ct\n+{\n+namespace module\n+{\n+template <typename R = float>\n+class Channel_BEC : public Channel<R>\n+{\n+protected:\n+ // for float type\n+ tools::PRNG_MT19937 mt19937; // Mersenne Twister 19937 (scalar)\n+ tools::PRNG_MT19937_simd mt19937_simd; // Mersenne Twister 19937 (SIMD)\n+\n+ // for double type\n+ std::mt19937 rd_engine; // Mersenne Twister 19937\n+ std::uniform_real_distribution<R> uni_dist;\n+\n+public:\n+ Channel_BEC(const int N, const int seed = 0, const tools::Noise<R>& noise = tools::Noise<R>(), const int n_frames = 1);\n+ virtual ~Channel_BEC();\n+\n+protected:\n+ void _add_noise(const R *X_N, R *Y_N, const int frame_id = -1);\n+\n+ inline mipp::Reg<R> get_random_simd();\n+ inline R get_random ();\n+};\n+}\n+}\n+\n+#endif /* CHANNEL_BEC_HPP_ */\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/Channel.hxx",
"new_path": "src/Module/Channel/Channel.hxx",
"diff": "@@ -63,7 +63,7 @@ Channel(const int N, const tools::Noise<R>& n, const int n_frames)\ntemplate <typename R>\nChannel<R>::\nChannel(const int N, const int n_frames)\n-: Channel(N, tools::Noise<R>(), this->n_frames)\n+: Channel(N, tools::Noise<R>(), n_frames)\n{\n}\n@@ -80,13 +80,6 @@ get_N() const\nreturn this->N;\n}\n-// template <typename R>\n-// R Channel<R>::\n-// get_sigma() const\n-// {\n-// return this->sigma;\n-// }\n-\ntemplate <typename R>\nconst std::vector<R>& Channel<R>::\nget_noise() const\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/OOK/Modem_OOK.cpp",
"new_path": "src/Module/Modem/OOK/Modem_OOK.cpp",
"diff": "@@ -30,7 +30,7 @@ void Modem_OOK<B,R,Q>\n{\nModem<B,R,Q>::set_noise(noise);\n- this->sigma_factor = (R)2.0 * this->n.get_sigma() * this->n.get_sigma(); // trow if noise is not SIGMA type\n+ this->sigma_factor = (R)2.0 * this->n.get_noise() * this->n.get_noise(); // trow if noise is set\n}\ntemplate <typename B, typename R, typename Q>\n@@ -63,11 +63,12 @@ void Modem_OOK<B,R,Q>\nif (!std::is_floating_point<Q>::value)\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, \"Type 'Q' has to be float or double.\");\n- if (!this->n.is_set())\n- throw tools::runtime_error(__FILE__, __LINE__, __func__, \"No noise has been set\");\n-\n+ if (this->n.get_type() == tools::Noise_type::SIGMA)\nfor (auto i = 0; i < this->N_fil; i++)\nY_N2[i] = -((Q)2.0 * Y_N1[i] - (Q)1) * (Q)sigma_factor;\n+ else if (this->n.get_type() == tools::Noise_type::EP)\n+ for (auto i = 0; i < this->N_fil; i++)\n+ std::copy(Y_N1, Y_N1 + this->N_fil, Y_N2);\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add Channel BEC. Fix channel.hxx constructor without noise. Add Modem OOK BEC demodulation
|
8,490 |
12.04.2018 09:43:31
| -7,200 |
f426aae0bbed96bed70656bf535fc2e3ed00976d
|
Try to fix compilation issues on Windows.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Factory.cpp",
"new_path": "src/Factory/Factory.cpp",
"diff": "+#include <rang.hpp>\n#include <algorithm>\n#include <iostream>\n#include <utility>\n#include <sstream>\n#include <vector>\n#include <map>\n-#include <rang.hpp>\n#include \"Tools/general_utils.h\"\n#include \"Tools/Exception/exception.hpp\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Launcher/Launcher.cpp",
"new_path": "src/Factory/Launcher/Launcher.cpp",
"diff": "+#include <rang.hpp>\n#include <vector>\n#include <cstdint>\n#include <sstream>\n#include <typeinfo>\n#include <typeindex>\n#include <unordered_map>\n-#include <rang.hpp>\n#include \"Tools/general_utils.h\"\n#include \"Tools/Exception/exception.hpp\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Launcher/Launcher.cpp",
"new_path": "src/Launcher/Launcher.cpp",
"diff": "+#include <rang.hpp>\n#include <cstdlib>\n#include <sstream>\n#include <iostream>\n#include <algorithm>\n#include <functional>\n-#include <rang.hpp>\n#ifdef ENABLE_MPI\n#include <mpi.h>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Task.cpp",
"new_path": "src/Module/Task.cpp",
"diff": "+#include <rang.hpp>\n#include <iostream>\n#include <iomanip>\n#include <ios>\n-#include <rang.hpp>\n#include \"Tools/Display/Frame_trace/Frame_trace.hpp\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Arguments/Argument_handler.cpp",
"new_path": "src/Tools/Arguments/Argument_handler.cpp",
"diff": "+#include <rang.hpp>\n#include <sstream>\n#include <algorithm>\n#include <type_traits>\n-#include <rang.hpp>\n#include \"Tools/general_utils.h\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Frame_trace/Frame_trace.hxx",
"new_path": "src/Tools/Display/Frame_trace/Frame_trace.hxx",
"diff": "+#include <rang.hpp>\n#include <sstream>\n#include <iomanip>\n-#include <rang.hpp>\n#include \"Tools/Exception/exception.hpp\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Statistics/Statistics.cpp",
"new_path": "src/Tools/Display/Statistics/Statistics.cpp",
"diff": "+#include <rang.hpp>\n#include <algorithm>\n#include <iomanip>\n-#include <rang.hpp>\n#include \"Tools/Display/bash_tools.h\"\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": "+#include <rang.hpp>\n#include <iostream>\n#include <iomanip>\n#include <sstream>\n#include <ios>\n-#include <rang.hpp>\n#include \"Tools/Exception/exception.hpp\"\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": "+#include <rang.hpp>\n#include <iostream>\n#include <iomanip>\n#include <sstream>\n#include <ios>\n-#include <rang.hpp>\n#include \"Terminal_EXIT.hpp\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/bash_tools.cpp",
"new_path": "src/Tools/Display/bash_tools.cpp",
"diff": "-#include <sstream>\n#include <rang.hpp>\n+#include <sstream>\n#include \"bash_tools.h\"\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Try to fix compilation issues on Windows.
|
8,483 |
12.04.2018 10:52:17
| -7,200 |
68baff36829d709aff37d2fc036cafc644962f65
|
Set correctly Noise as Codec attribute
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/Codec.hpp",
"new_path": "src/Module/Codec/Codec.hpp",
"diff": "@@ -48,7 +48,7 @@ protected :\nconst int N_cw;\nconst int N;\nconst int tail_length;\n- // tools::Noise<float> n;\n+ tools::Noise<float> n;\npublic:\nCodec(const int K, const int N_cw, const int N, const int tail_length = 0, const int n_frames = 1);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/Codec.hxx",
"new_path": "src/Module/Codec/Codec.hxx",
"diff": "@@ -21,7 +21,7 @@ Codec(const int K, const int N_cw, const int N, const int tail_length, const int\ninterleaver_llr (nullptr),\nencoder (nullptr),\npuncturer (nullptr),\n- K(K), N_cw(N_cw), N(N), tail_length(tail_length)\n+ K(K), N_cw(N_cw), N(N), tail_length(tail_length), n(tools::Noise<float>())\n{\nconst std::string name = \"Codec\";\nthis->set_name(name);\n@@ -174,7 +174,7 @@ template <typename B, typename Q>\nvoid Codec<B,Q>\n::set_noise(const tools::Noise<float>& noise)\n{\n- // this->n = noise;\n+ this->n = noise;\n}\ntemplate <typename B, typename Q>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/Polar/Codec_polar.cpp",
"new_path": "src/Module/Codec/Polar/Codec_polar.cpp",
"diff": "@@ -167,7 +167,6 @@ void Codec_polar<B,Q>\n::set_noise(const tools::Noise<float>& noise)\n{\nCodec_SISO_SIHO<B,Q>::set_noise(noise);\n- this->n = noise;\n// adaptive frozen bits generation\nif (adaptive_fb && !generated_decoder)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/Polar/Codec_polar.hpp",
"new_path": "src/Module/Codec/Polar/Codec_polar.hpp",
"diff": "@@ -28,7 +28,6 @@ protected:\nPuncturer_polar_wangliu<B,Q> *puncturer_wangliu;\ntools::Frozenbits_notifier *fb_decoder;\ntools::Frozenbits_notifier *fb_encoder;\n- tools::Noise<float> n;\npublic:\nCodec_polar(const factory::Frozenbits_generator::parameters &fb_par,\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Set correctly Noise as Codec attribute
|
8,483 |
12.04.2018 10:53:22
| -7,200 |
2ea25d7b6bb07310a603966cb2db74c8e07012df
|
Add extra unchecked range over each EP bounds
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Noise.cpp",
"new_path": "src/Tools/Noise.cpp",
"diff": "@@ -297,7 +297,7 @@ check()\nbreak;\ncase EP:\n- if (n < (R)0 || n > (R)1)\n+ if (n < (R)-0.00001 || n > (R)1.00001)\n{\nstd::stringstream message;\nmessage << \"The EP noise '_n' has to be between [0,1] ('_n' = \" << n << \").\";\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add extra unchecked range over each EP bounds
|
8,483 |
12.04.2018 11:00:10
| -7,200 |
82a7cf920a52509df260071f9d2c7a539b511b45
|
Remove init of Noise in Codec constructor
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/Codec.hxx",
"new_path": "src/Module/Codec/Codec.hxx",
"diff": "@@ -21,7 +21,7 @@ Codec(const int K, const int N_cw, const int N, const int tail_length, const int\ninterleaver_llr (nullptr),\nencoder (nullptr),\npuncturer (nullptr),\n- K(K), N_cw(N_cw), N(N), tail_length(tail_length), n(tools::Noise<float>())\n+ K(K), N_cw(N_cw), N(N), tail_length(tail_length)\n{\nconst std::string name = \"Codec\";\nthis->set_name(name);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Remove init of Noise in Codec constructor
|
8,483 |
12.04.2018 11:41:01
| -7,200 |
578196aee7283ac59de65a061d5728ff5e3372b2
|
Simulate EP in reverse order; Add a noise type check else throw
|
[
{
"change_type": "MODIFY",
"old_path": "src/Simulation/BFER/BFER.cpp",
"new_path": "src/Simulation/BFER/BFER.cpp",
"diff": "@@ -157,9 +157,17 @@ void BFER<B,R,Q>\n{\nthis->noise.set_rop(n);\n}\n- else // if (params_BFER.noise_type == \"EP\")\n+ else if (params_BFER.noise_type == \"EP\")\n{\n+ n = params_BFER.noise_range[params_BFER.noise_range.size() - noise_idx -1];\n+\nthis->noise.set_ep(n);\n+ }\n+ else\n+ {\n+ std::stringstream message;\n+ message << \"Unknown noise type ('noise_type' = \" << params_BFER.noise_type << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n}\nthis->terminal->set_noise(this->noise);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Simulate EP in reverse order; Add a noise type check else throw
|
8,483 |
12.04.2018 11:42:40
| -7,200 |
711e72013a6bfeab2fac9927006904d520226ae6
|
Modem OOk return llr when noise is EP, return llr = 0 when erased
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/OOK/Modem_OOK.cpp",
"new_path": "src/Module/Modem/OOK/Modem_OOK.cpp",
"diff": "@@ -55,20 +55,29 @@ void Modem_OOK<B,R,Q>\nif (disable_sig2)\nfor (auto i = 0; i < this->N_fil; i++)\nY_N2[i] = (Q)0.5 - Y_N1[i];\n- else\n- {\n+ else {\nif (!std::is_same<R, Q>::value)\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, \"Type 'R' and 'Q' have to be the same.\");\nif (!std::is_floating_point<Q>::value)\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, \"Type 'Q' has to be float or double.\");\n- if (this->n.get_type() == tools::Noise_type::SIGMA)\n+ switch (this->n.get_type()) {\n+ case tools::Noise_type::SIGMA:\nfor (auto i = 0; i < this->N_fil; i++)\nY_N2[i] = -((Q) 2.0 * Y_N1[i] - (Q) 1) * (Q) sigma_factor;\n- else if (this->n.get_type() == tools::Noise_type::EP)\n+ break;\n+ case tools::Noise_type::EP:\nfor (auto i = 0; i < this->N_fil; i++)\n- std::copy(Y_N1, Y_N1 + this->N_fil, Y_N2);\n+ Y_N2[i] = std::isinf(Y_N1[i]) ? (Q) 0 : ((Q) 1 - (Q) 2.0 * Y_N1[i]);\n+ break;\n+ default: {\n+ std::stringstream message;\n+ message << \"The noise has a type other than SIGMA or EP ('this->n.get_type()' = \"\n+ << this->n.type2str(this->n.get_type()) << \").\";\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, message.str());\n+ }\n+ }\n}\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Modem OOk return llr when noise is EP, return llr = 0 when erased
|
8,483 |
12.04.2018 12:36:35
| -7,200 |
f5ac1190303cdcf318ac7ae665871c7639900238
|
Change isinf() check by == num_limits<Q>::infinity()
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/OOK/Modem_OOK.cpp",
"new_path": "src/Module/Modem/OOK/Modem_OOK.cpp",
"diff": "@@ -55,23 +55,26 @@ void Modem_OOK<B,R,Q>\nif (disable_sig2)\nfor (auto i = 0; i < this->N_fil; i++)\nY_N2[i] = (Q)0.5 - Y_N1[i];\n- else {\n+ else\n+ {\nif (!std::is_same<R, Q>::value)\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, \"Type 'R' and 'Q' have to be the same.\");\nif (!std::is_floating_point<Q>::value)\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, \"Type 'Q' has to be float or double.\");\n- switch (this->n.get_type()) {\n+ switch (this->n.get_type())\n+ {\ncase tools::Noise_type::SIGMA:\nfor (auto i = 0; i < this->N_fil; i++)\nY_N2[i] = -((Q) 2.0 * Y_N1[i] - (Q) 1) * (Q) sigma_factor;\nbreak;\ncase tools::Noise_type::EP:\nfor (auto i = 0; i < this->N_fil; i++)\n- Y_N2[i] = std::isinf(Y_N1[i]) ? (Q) 0 : ((Q) 1 - (Q) 2.0 * Y_N1[i]);\n+ Y_N2[i] = Y_N1[i] == std::numeric_limits<Q>::infinity() ? (Q) 0 : ((Q) 1 - (Q) 2.0 * Y_N1[i]);\nbreak;\n- default: {\n+ default:\n+ {\nstd::stringstream message;\nmessage << \"The noise has a type other than SIGMA or EP ('this->n.get_type()' = \"\n<< this->n.type2str(this->n.get_type()) << \").\";\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Change isinf() check by == num_limits<Q>::infinity()
|
8,483 |
12.04.2018 15:03:29
| -7,200 |
d6cdb237634d74041a6f518533037bb448d09df5
|
Fix n0 computation
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/SCMA/Modem_SCMA.hxx",
"new_path": "src/Module/Modem/SCMA/Modem_SCMA.hxx",
"diff": "@@ -103,7 +103,7 @@ void Modem_SCMA<B,R,Q,PSI>\nthis->n0 = this->disable_sig2 ?\n(R)1.0 :\n- (R)((R)1.0 / ((R)4.0 * this->n.get_sigma() * this->n.get_sigma())); // trow if noise is not SIGMA type\n+ ((R)4.0 * this->n.get_sigma() * this->n.get_sigma()); // trow if noise is not SIGMA type\n}\ntemplate <typename B, typename R, typename Q, tools::proto_psi<Q> PSI>\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix n0 computation
|
8,490 |
12.04.2018 17:45:32
| -7,200 |
92f27f725ee54625c7f837510268cb7bdd1cb417
|
Try to fix MSVC compilation error.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Factory.cpp",
"new_path": "src/Factory/Factory.cpp",
"diff": "@@ -217,6 +217,7 @@ void aff3ct::factory::Header::print_parameters(const std::vector<Factory::parame\n}\n}\n+#undef max\nvoid aff3ct::factory::Header::compute_max_n_chars(const header_list& header, int& max_n_chars)\n{\nfor (unsigned i = 0; i < header.size(); i++)\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Try to fix MSVC compilation error.
|
8,490 |
12.04.2018 17:56:17
| -7,200 |
6cbf7a996191e91b702aac35b6b8ba1706eec9e9
|
Rename enum vals.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Task.cpp",
"new_path": "src/Module/Task.cpp",
"diff": "@@ -53,13 +53,13 @@ void Task::set_autoalloc(const bool autoalloc)\n{\nthis->out_buffers.clear();\nfor (auto *s : sockets)\n- if (get_socket_type(*s) == socket_t::OUT)\n+ if (get_socket_type(*s) == socket_t::SOUT)\ns->dataptr = nullptr;\n}\nelse\n{\nfor (auto *s : sockets)\n- if (get_socket_type(*s) == socket_t::OUT)\n+ if (get_socket_type(*s) == socket_t::SOUT)\n{\nout_buffers.push_back(mipp::vector<uint8_t>(s->databytes));\ns->dataptr = out_buffers.back().data();\n@@ -201,7 +201,7 @@ int Task::exec()\nauto &s = *sockets[i];\nauto s_type = get_socket_type(s);\nauto n_elmts = s.get_databytes() / (size_t)s.get_datatype_size();\n- std::cout << rang::style::bold << rang::fg::blue << (s_type == socket_t::IN ? \"const \" : \"\")\n+ std::cout << rang::style::bold << rang::fg::blue << (s_type == socket_t::SIN ? \"const \" : \"\")\n<< s.get_datatype_string() << rang::style::reset\n<< \" \" << s.get_name() << \"[\" << (n_fra > 1 ? std::to_string(n_fra) + \"x\" : \"\")\n<< (n_elmts / n_fra) << \"]\"\n@@ -214,7 +214,7 @@ int Task::exec()\nfor (auto *s : sockets)\n{\nauto s_type = get_socket_type(*s);\n- if (s_type == socket_t::IN || s_type == socket_t::IN_OUT)\n+ if (s_type == socket_t::SIN || s_type == socket_t::SIN_SOUT)\n{\nstd::string spaces; for (size_t ss = 0; ss < max_n_chars - s->get_name().size(); ss++) spaces += \" \";\n@@ -264,7 +264,7 @@ int Task::exec()\nfor (auto *s : sockets)\n{\nauto s_type = get_socket_type(*s);\n- if (s_type == socket_t::OUT || s_type == socket_t::IN_OUT)\n+ if (s_type == socket_t::SOUT || s_type == socket_t::SIN_SOUT)\n{\nstd::string spaces; for (size_t ss = 0; ss < max_n_chars - s->get_name().size(); ss++) spaces += \" \";\n@@ -331,7 +331,7 @@ Socket& Task::create_socket_in(const std::string &name, const size_t n_elmts)\n{\nauto &s = create_socket<T>(name, n_elmts);\n- socket_type.push_back(socket_t::IN);\n+ socket_type.push_back(socket_t::SIN);\nlast_input_socket = &s;\nreturn s;\n@@ -342,7 +342,7 @@ Socket& Task::create_socket_in_out(const std::string &name, const size_t n_elmts\n{\nauto &s = create_socket<T>(name, n_elmts);\n- socket_type.push_back(socket_t::IN_OUT);\n+ socket_type.push_back(socket_t::SIN_SOUT);\nlast_input_socket = &s;\nreturn s;\n@@ -353,7 +353,7 @@ Socket& Task::create_socket_out(const std::string &name, const size_t n_elmts)\n{\nauto &s = create_socket<T>(name, n_elmts);\n- socket_type.push_back(socket_t::OUT);\n+ socket_type.push_back(socket_t::SOUT);\n// memory allocation\nif (is_autoalloc())\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Task.hpp",
"new_path": "src/Module/Task.hpp",
"diff": "@@ -24,7 +24,7 @@ namespace module\nclass Module;\nclass Socket;\n-enum class socket_t : uint8_t { IN, IN_OUT, OUT };\n+enum class socket_t : uint8_t { SIN, SIN_SOUT, SOUT };\nclass Task\n{\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Rename enum vals.
|
8,490 |
12.04.2018 21:11:26
| -7,200 |
24bdccabdb36a810e427ad1775ed64de9e3c6821
|
Try to fix compilation errors.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/SC_Module.cpp",
"new_path": "src/Module/SC_Module.cpp",
"diff": "@@ -21,7 +21,7 @@ SC_Module::SC_Module(Task &task, sc_core::sc_module_name sc_name)\nauto is_inputs = false;\nfor (auto *s : task.sockets)\n- if (task.get_socket_type(*s) == IN || task.get_socket_type(*s) == IN_OUT)\n+ if (task.get_socket_type(*s) == socket_t::SIN || task.get_socket_type(*s) == socket_t::SIN_SOUT)\n{\nis_inputs = true;\nbreak;\n@@ -36,7 +36,7 @@ SC_Module::SC_Module(Task &task, sc_core::sc_module_name sc_name)\nconst auto id_out = (int)sockets_out.size();\nswitch (task.get_socket_type(*s))\n{\n- case IN:\n+ case socket_t::SIN:\nindirect_sockets_in[i] = id_in;\nindirect_sockets_in_rev.push_back(i);\nsockets_in.push_back(new tlm_utils::simple_target_socket<SC_Module>(name.c_str()));\n@@ -51,11 +51,13 @@ SC_Module::SC_Module(Task &task, sc_core::sc_module_name sc_name)\ncase 6: sockets_in[id_in]->register_b_transport(this, &SC_Module::b_transport6); break;\ncase 7: sockets_in[id_in]->register_b_transport(this, &SC_Module::b_transport7); break;\ncase 8: sockets_in[id_in]->register_b_transport(this, &SC_Module::b_transport8); break;\n- default: throw tools::runtime_error(__FILE__, __LINE__, __func__, \"This should never happen.\"); break;\n+ default:\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, \"This should never happen.\");\n+ break;\n}\nbreak;\n- case OUT:\n+ case socket_t::SOUT:\nindirect_sockets_out[i] = id_out;\nindirect_sockets_out_rev.push_back(i);\nsockets_out.push_back(new tlm_utils::simple_initiator_socket<SC_Module>(name.c_str()));\n@@ -63,7 +65,7 @@ SC_Module::SC_Module(Task &task, sc_core::sc_module_name sc_name)\nSC_THREAD(start_sc_thread);\nbreak;\n- case IN_OUT:\n+ case socket_t::SIN_SOUT:\nindirect_sockets_in[i] = id_in;\nindirect_sockets_in_rev.push_back(i);\nsockets_in.push_back(new tlm_utils::simple_target_socket<SC_Module>(name.c_str()));\n@@ -78,7 +80,9 @@ SC_Module::SC_Module(Task &task, sc_core::sc_module_name sc_name)\ncase 6: sockets_in[id_in]->register_b_transport(this, &SC_Module::b_transport6); break;\ncase 7: sockets_in[id_in]->register_b_transport(this, &SC_Module::b_transport7); break;\ncase 8: sockets_in[id_in]->register_b_transport(this, &SC_Module::b_transport8); break;\n- default: throw tools::runtime_error(__FILE__, __LINE__, __func__, \"This should never happen.\"); break;\n+ default:\n+ throw tools::runtime_error(__FILE__, __LINE__, __func__, \"This should never happen.\");\n+ break;\n}\nindirect_sockets_out[i] = id_out;\nindirect_sockets_out_rev.push_back(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": "+#include <rang.hpp>\n#include <cstring>\n#include <string>\n#include <vector>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Arguments/Argument_handler.cpp",
"new_path": "src/Tools/Arguments/Argument_handler.cpp",
"diff": "@@ -208,6 +208,7 @@ void Argument_handler\nhelp_os << \" [optional args...]\" << std::endl;\n}\n+#undef max\nsize_t Argument_handler\n::find_longest_tags(const Argument_map_info &args) const\n{\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Try to fix compilation errors.
|
8,490 |
13.04.2018 09:46:09
| -7,200 |
f8a898508bd062d9ea86fc4b1816559dbc2b74be
|
Try to fix compilation errors on Windows.
|
[
{
"change_type": "MODIFY",
"old_path": "CMakeLists.txt",
"new_path": "CMakeLists.txt",
"diff": "@@ -218,5 +218,11 @@ if (UNIX)\nadd_definitions (-fPIC)\nendif()\n+# mandatory for rang on Windows\n+if (WIN32)\n+ add_definitions (-D_WIN32_WINNT)\n+ add_definitions (-DNOMINMAX)\n+endif (WIN32)\n+\n# Specific options\nadd_definitions (-DENABLE_BIT_PACKING)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Factory.cpp",
"new_path": "src/Factory/Factory.cpp",
"diff": "-#include <rang.hpp>\n#include <algorithm>\n#include <iostream>\n#include <utility>\n#include <sstream>\n#include <vector>\n#include <map>\n+#include <rang.hpp>\n#include \"Tools/general_utils.h\"\n#include \"Tools/Exception/exception.hpp\"\n@@ -217,7 +217,6 @@ void aff3ct::factory::Header::print_parameters(const std::vector<Factory::parame\n}\n}\n-#undef max\nvoid aff3ct::factory::Header::compute_max_n_chars(const header_list& header, int& max_n_chars)\n{\nfor (unsigned i = 0; i < header.size(); i++)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Launcher/Launcher.cpp",
"new_path": "src/Factory/Launcher/Launcher.cpp",
"diff": "-#include <rang.hpp>\n#include <vector>\n#include <cstdint>\n#include <sstream>\n#include <typeinfo>\n#include <typeindex>\n#include <unordered_map>\n+#include <rang.hpp>\n#include \"Tools/general_utils.h\"\n#include \"Tools/Exception/exception.hpp\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Task.cpp",
"new_path": "src/Module/Task.cpp",
"diff": "-#include <rang.hpp>\n#include <iostream>\n#include <iomanip>\n#include <ios>\n+#include <rang.hpp>\n+\n#include \"Tools/Display/Frame_trace/Frame_trace.hpp\"\n#include \"Module.hpp\"\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": "-#include <rang.hpp>\n#include <cstring>\n#include <string>\n#include <vector>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Arguments/Argument_handler.cpp",
"new_path": "src/Tools/Arguments/Argument_handler.cpp",
"diff": "-#include <rang.hpp>\n#include <sstream>\n#include <algorithm>\n#include <type_traits>\n+#include <rang.hpp>\n+\n#include \"Tools/general_utils.h\"\n#include \"Argument_handler.hpp\"\n@@ -208,7 +209,6 @@ void Argument_handler\nhelp_os << \" [optional args...]\" << std::endl;\n}\n-#undef max\nsize_t Argument_handler\n::find_longest_tags(const Argument_map_info &args) const\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Frame_trace/Frame_trace.hxx",
"new_path": "src/Tools/Display/Frame_trace/Frame_trace.hxx",
"diff": "-#include <rang.hpp>\n#include <sstream>\n#include <iomanip>\n+#include <rang.hpp>\n+\n#include \"Tools/Exception/exception.hpp\"\n#include \"Frame_trace.hpp\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Statistics/Statistics.cpp",
"new_path": "src/Tools/Display/Statistics/Statistics.cpp",
"diff": "-#include <rang.hpp>\n#include <algorithm>\n#include <iomanip>\n+#include <rang.hpp>\n+\n#include \"Tools/Display/bash_tools.h\"\n#include \"Statistics.hpp\"\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": "-#include <rang.hpp>\n#include <iostream>\n#include <iomanip>\n#include <sstream>\n#include <ios>\n+#include <rang.hpp>\n+\n#include \"Tools/Exception/exception.hpp\"\n#include \"Terminal_BFER.hpp\"\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": "-#include <rang.hpp>\n#include <iostream>\n#include <iomanip>\n#include <sstream>\n#include <ios>\n+#include <rang.hpp>\n+\n#include \"Terminal_EXIT.hpp\"\nusing namespace aff3ct;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/bash_tools.cpp",
"new_path": "src/Tools/Display/bash_tools.cpp",
"diff": "-#include <rang.hpp>\n#include <sstream>\n+#include <rang.hpp>\n+\n#include \"bash_tools.h\"\nstd::string aff3ct::tools::format_error(const std::string &str)\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Try to fix compilation errors on Windows.
|
8,490 |
13.04.2018 10:25:42
| -7,200 |
15cfe4bc7fcf983300273ebd227a9e49fa5043b1
|
Try to fix errors...
|
[
{
"change_type": "MODIFY",
"old_path": "CMakeLists.txt",
"new_path": "CMakeLists.txt",
"diff": "@@ -214,15 +214,17 @@ elseif (\"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"Intel\")\naff3ct_link_libraries (-pthread)\nendif()\n-if (UNIX)\n- add_definitions (-fPIC)\n-endif()\n-\n# mandatory for rang on Windows\nif (WIN32)\nadd_definitions (-D_WIN32_WINNT=_WIN32_WINNT_VISTA)\nadd_definitions (-DNOMINMAX)\n-endif (WIN32)\n+ message(STATUS \"System: Windows\")\n+elseif (UNIX)\n+ add_definitions (-fPIC)\n+ message(STATUS \"System: Unix\")\n+elseif (APPLE)\n+ message(STATUS \"System: MacOS\")\n+endif()\n# Specific options\nadd_definitions (-DENABLE_BIT_PACKING)\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Try to fix errors...
|
8,490 |
13.04.2018 11:37:48
| -7,200 |
31605ef62e99a5de346cf800b46b268bff0fca5c
|
Fix the fix of the fix... :-(
|
[
{
"change_type": "MODIFY",
"old_path": "CMakeLists.txt",
"new_path": "CMakeLists.txt",
"diff": "@@ -73,7 +73,8 @@ endif()\n# by system\nif (WIN32) # for Windows operating system in general\n- add_definitions (-D_WIN32_WINNT=_WIN32_WINNT_VISTA)\n+ set (WINDOWS_VISTA 0x0600)\n+ add_definitions (-D_WIN32_WINNT=${WINDOWS_VISTA})\nadd_definitions (-DNOMINMAX)\nmessage(STATUS \"AFF3CT - System: Windows\")\nelseif (APPLE) # for MacOS X\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix the fix of the fix... :-(
|
8,483 |
13.04.2018 13:06:39
| -7,200 |
6e672c9a159bf28b220e0bfcb8a71a7268df6ea2
|
Set Noisetype as a strong enum type
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Noise.cpp",
"new_path": "src/Tools/Noise.cpp",
"diff": "@@ -225,15 +225,15 @@ set_noise(const R noise, const Noise_type t)\n{\nswitch(t)\n{\n- case SIGMA:\n+ case Noise_type::SIGMA:\nset_sigma(noise);\nbreak;\n- case EP:\n+ case Noise_type::EP:\nset_ep(noise);\nbreak;\n- case ROP:\n+ case Noise_type::ROP:\nset_rop(noise);\nbreak;\n}\n@@ -287,7 +287,7 @@ check()\nswitch(get_type())\n{\n- case SIGMA:\n+ case Noise_type::SIGMA:\nif (n <= (R)0)\n{\nstd::stringstream message;\n@@ -296,7 +296,7 @@ check()\n}\nbreak;\n- case EP:\n+ case Noise_type::EP:\nif (n < (R)-0.00001 || n > (R)1.00001)\n{\nstd::stringstream message;\n@@ -305,7 +305,7 @@ check()\n}\nbreak;\n- case ROP:\n+ case Noise_type::ROP:\n// nothing to check\nbreak;\n}\n@@ -342,13 +342,13 @@ type2str(const Noise_type& t)\nswitch(t)\n{\n- case SIGMA:\n+ case Noise_type::SIGMA:\nstr = \"SIGMA\";\nbreak;\n- case EP:\n+ case Noise_type::EP:\nstr = \"EP\";\nbreak;\n- case ROP:\n+ case Noise_type::ROP:\nstr = \"ROP\";\nbreak;\n}\n@@ -357,7 +357,7 @@ type2str(const Noise_type& t)\n// cases of 'Noise_type' are well represented.\n{\nstd::stringstream message;\n- message << \"The type 't' does not represent a noise type ('t' = \" << t << \").\";\n+ message << \"The type 't' does not represent a noise type ('t' = \" << (int8_t)t << \").\";\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Noise.hpp",
"new_path": "src/Tools/Noise.hpp",
"diff": "@@ -9,7 +9,7 @@ namespace aff3ct\nnamespace tools\n{\n-enum Noise_type{ SIGMA, ROP, EP }; // Sigma (SNR variance), Received optical power, Erasure Probability\n+enum class Noise_type : uint8_t{ SIGMA, ROP, EP }; // Sigma (SNR variance), Received optical power, Erasure Probability\ntemplate <typename R = float>\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Set Noisetype as a strong enum type
|
8,483 |
13.04.2018 15:14:24
| -7,200 |
891a77a2baf0248c8258d1cf1c3bddfb8bcf2839
|
Add a link between BCH T and BCH K to automaticaly find K from T and N
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Codec/BCH/Codec_BCH.cpp",
"new_path": "src/Factory/Module/Codec/BCH/Codec_BCH.cpp",
"diff": "@@ -50,11 +50,14 @@ void Codec_BCH::parameters\ndec->get_description(args);\nauto pdec = dec->get_prefix();\n+ auto penc = enc->get_prefix();\nargs.erase({pdec+\"-cw-size\", \"N\"});\nargs.erase({pdec+\"-info-bits\", \"K\"});\nargs.erase({pdec+\"-fra\", \"F\"});\nargs.erase({pdec+\"-no-sys\" });\n+\n+ args.add_link({pdec+\"-corr-pow\", \"T\"}, {penc+\"-info-bits\", \"K\"});\n}\nvoid Codec_BCH::parameters\n@@ -70,6 +73,9 @@ void Codec_BCH::parameters\ndec->store(vals);\n+ if(this->dec->K != this->enc->K) // when -T has been given but not -K\n+ this->enc->K = this->dec->K;\n+\nthis->K = this->enc->K;\nthis->N_cw = this->enc->N_cw;\nthis->N = this->enc->N_cw;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Decoder/BCH/Decoder_BCH.cpp",
"new_path": "src/Factory/Module/Decoder/BCH/Decoder_BCH.cpp",
"diff": "@@ -44,6 +44,8 @@ void Decoder_BCH::parameters\ntools::Integer(tools::Positive(), tools::Non_zero()),\n\"correction power of the BCH code.\");\n+ args.add_link({p+\"-corr-pow\", \"T\"}, {p+\"-info-bits\", \"K\"});\n+\ntools::add_options(args.at({p+\"-type\", \"D\"}), 0, \"ALGEBRAIC\");\ntools::add_options(args.at({p+\"-implem\" }), 0, \"GENIUS\");\n}\n@@ -65,6 +67,8 @@ void Decoder_BCH::parameters\nif (vals.exist({p+\"-corr-pow\", \"T\"}))\nthis->t = vals.to_int({p+\"-corr-pow\", \"T\"});\n+ if (!vals.exist({p+\"-info-bits\", \"K\"}))\n+ this->K = this->N_cw - this->t * this->m;\nelse\nthis->t = (this->N_cw - this->K) / this->m;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Factory/Simulation/BFER/BFER.cpp",
"new_path": "src/Factory/Simulation/BFER/BFER.cpp",
"diff": "@@ -171,7 +171,7 @@ void BFER::parameters\nauto p = this->get_prefix();\n- headers[p].push_back(std::make_pair(\"NOISE type\", this->noise_type));\n+ headers[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"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add a link between BCH T and BCH K to automaticaly find K from T and N
|
8,490 |
13.04.2018 17:00:43
| -7,200 |
5ce9579ae8e1c794606e37cd3915f96001e758b6
|
Fix multi-line.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/rang_format/rang_format.cpp",
"new_path": "src/Tools/Display/rang_format/rang_format.cpp",
"diff": "@@ -47,7 +47,6 @@ void rang::format_on_each_line(std::ostream& os, const std::string& str, const r\nos << f << str.substr(old_pos, pos-old_pos) << format::reset << std::endl;\nold_pos = pos+1;\n}\n-\n- if (!(str.substr(old_pos, pos-old_pos).length() == 1 && str.substr(old_pos, pos-old_pos)[0] == '\\n'))\n+ if (!str.substr(old_pos, pos-old_pos).empty())\nos << f << str.substr(old_pos, pos-old_pos) << format::reset;\n}\n\\ No newline at end of file\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix multi-line.
|
8,490 |
13.04.2018 17:16:48
| -7,200 |
ccc54277cad58d46de19ae41bb81d1e76856f042
|
Fix missing color issues.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Arguments/Argument_handler.cpp",
"new_path": "src/Tools/Arguments/Argument_handler.cpp",
"diff": "@@ -267,27 +267,25 @@ void Argument_handler\n{\nconst std::string tab = \" \";\n- std::stringstream tabr;\n-\nswitch (info.rank)\n{\ncase arg_rank::OPT :\n- tabr << tab;\n+ help_os << tab;\nbreak;\ncase arg_rank::REQ :\n- tabr << rang::style::bold << rang::fg::red << \"{R} \" << rang::style::reset;\n+ help_os << rang::style::bold << rang::fg::red << \"{R} \" << rang::style::reset;\nbreak;\ncase arg_rank::ADV :\n- tabr << rang::style::bold << rang::fg::blue << \"{A} \" << rang::style::reset;\n+ help_os << rang::style::bold << rang::fg::blue << \"{A} \" << rang::style::reset;\nbreak;\n}\nstd::string tags_str = this->print_tag(tags);\ntags_str.append(longest_tag - tags_str.size(), ' ');\n- help_os << tabr.str() << rang::style::bold << tags_str << rang::style::reset;\n+ help_os << rang::style::bold << tags_str << rang::style::reset;\nif (info.type->get_title().size())\nhelp_os << rang::fg::gray << \" <\" << info.type->get_title() << \">\" << rang::style::reset;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Statistics/Statistics.cpp",
"new_path": "src/Tools/Display/Statistics/Statistics.cpp",
"diff": "@@ -96,19 +96,20 @@ void Statistics\nssmin_lat << std::setprecision(min_lat > l1 ? P : 2) << (min_lat > l2 ? std::scientific : std::fixed) << std::setw( 8) << min_lat;\nssmax_lat << std::setprecision(max_lat > l1 ? P : 2) << (max_lat > l2 ? std::scientific : std::fixed) << std::setw( 8) << max_lat;\n- std::stringstream spercent;\n- if (percent > 50.0f) spercent << rang::fg::red << sspercent.str() << rang::style::reset;\n- else if (percent > 25.0f) spercent << rang::fg::yellow << sspercent.str() << rang::style::reset;\n- else if (percent > 12.5f) spercent << rang::fg::green << sspercent.str() << rang::style::reset;\n- else if (percent < 5.0f) spercent << rang::fg::gray << sspercent.str() << rang::style::reset;\n-\nstream << \"# \";\nstream << ssmodule .str() << rang::style::bold << \" | \" << rang::style::reset\n<< ssprocess.str() << rang::style::bold << \" | \" << rang::style::reset\n<< sssp .str() << rang::style::bold << \" || \" << rang::style::reset\n<< ssn_calls.str() << rang::style::bold << \" | \" << rang::style::reset\n- << sstot_dur.str() << rang::style::bold << \" | \" << rang::style::reset\n- << spercent .str() << rang::style::bold << \" || \" << rang::style::reset\n+ << sstot_dur.str() << rang::style::bold << \" | \" << rang::style::reset;\n+\n+ if (percent > 50.0f) stream << rang::fg::red << sspercent.str() << rang::style::reset;\n+ else if (percent > 25.0f) stream << rang::fg::yellow << sspercent.str() << rang::style::reset;\n+ else if (percent > 12.5f) stream << rang::fg::green << sspercent.str() << rang::style::reset;\n+ else if (percent < 5.0f) stream << rang::fg::gray << sspercent.str() << rang::style::reset;\n+ else stream << sspercent.str();\n+\n+ stream << rang::style::bold << \" || \" << rang::style::reset\n<< ssavg_thr.str() << rang::style::bold << \" | \" << rang::style::reset\n<< ssmin_thr.str() << rang::style::bold << \" | \" << rang::style::reset\n<< ssmax_thr.str() << rang::style::bold << \" || \" << rang::style::reset\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix missing color issues.
|
8,483 |
13.04.2018 18:01:34
| -7,200 |
ad98ea20d6034ab49a8d9486a0aef50de4c8d63e
|
Fix the generate range function to handle decreasing ranges and weird float precisions; Cosmetics
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/BFER/Terminal_BFER.cpp",
"new_path": "src/Tools/Display/Terminal/BFER/Terminal_BFER.cpp",
"diff": "@@ -275,12 +275,12 @@ void Terminal_BFER<B>\nstream << setprecision(2) << fixed << setw(column_width-1) << this->noise.get_ebn0() << format(spaced_scol_separator, Style::BOLD);\nbreak;\ncase Noise_type::ROP :\n+ stream << setprecision(2) << fixed << setw(column_width-1) << this->noise.get_rop() << format(spaced_scol_separator, Style::BOLD);\n+ break;\ncase Noise_type::EP :\n- stream << setprecision(2) << fixed << setw(column_width-1) << this->noise.get_noise() << format(spaced_scol_separator, Style::BOLD);\n+ stream << setprecision(4) << fixed << setw(column_width-1) << this->noise.get_ep() << format(spaced_scol_separator, Style::BOLD);\nbreak;\n}\n- // stream << get_spaces_left(undefined_noise_tag, column_width) << \" \";\n-\nstringstream str_ber, str_fer;\nstr_ber << setprecision(2) << scientific << setw(column_width-1) << ber;\n@@ -288,11 +288,10 @@ void Terminal_BFER<B>\nconst unsigned long long l0 = 99999999; // limit 0\nconst unsigned long long l1 = 99999999; // limit 1\n- //const auto l2 = 99999.99f; // limit 2\n- stream << setprecision((fra > l0) ? 2 : 0) << ((fra > l0) ? scientific : fixed) << setw(column_width-1) << ((fra > l0) ? (float)fra : fra) << format(spaced_scol_separator, Style::BOLD);\n- stream << setprecision(( be > l1) ? 2 : 0) << ((be > l1) ? scientific : fixed) << setw(column_width-1) << (( be > l1) ? (float) be : be) << format(spaced_scol_separator, Style::BOLD);\n- stream << setprecision(( fe > l1) ? 2 : 0) << ((fe > l1) ? scientific : fixed) << setw(column_width-1) << (( fe > l1) ? (float) fe : fe) << format(spaced_scol_separator, Style::BOLD);\n+ stream << setprecision((fra > l) ? 2 : 0) << ((fra > l) ? scientific : fixed) << setw(column_width-1) << ((fra > l) ? (float)fra : fra) << format(spaced_scol_separator, Style::BOLD);\n+ stream << setprecision(( be > l) ? 2 : 0) << ((be > l) ? scientific : fixed) << setw(column_width-1) << (( be > l) ? (float) be : be) << format(spaced_scol_separator, Style::BOLD);\n+ stream << setprecision(( fe > l) ? 2 : 0) << ((fe > l) ? scientific : fixed) << setw(column_width-1) << (( fe > l) ? (float) fe : fe) << format(spaced_scol_separator, Style::BOLD);\nstream << str_ber.str() << format(spaced_scol_separator, Style::BOLD);\nstream << str_fer.str() << format(spaced_dcol_separator, Style::BOLD);\nstream << setprecision( 2) << fixed << setw(column_width-1) << simu_cthr;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/general_utils.cpp",
"new_path": "src/Tools/general_utils.cpp",
"diff": "@@ -129,7 +129,9 @@ R aff3ct::tools::ebn0_to_esn0(const R ebn0, const R bit_rate, const int bps)\ntemplate <typename R>\nstd::vector<R> aff3ct::tools::generate_range(const std::vector<std::vector<R>>& range_description, const R default_step)\n{\n- std::vector<R> range;\n+ const R float_precision = 1e5;\n+\n+ std::vector<int> range;\nfor (auto& s : range_description)\n{\n@@ -146,16 +148,31 @@ std::vector<R> aff3ct::tools::generate_range(const std::vector<std::vector<R>>&\nthrow invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- R step = (s.size() == 3) ? s[1] : default_step;\n+ int min = (int)(s.front() * float_precision);\n+ int max = (int)(s.back () * float_precision);\n+ int step = (int)(((s.size() == 3) ? s[1] : default_step) * float_precision);\n+\n+ if (min > max && step < 0)\n+ {\n+ std::swap(min, max);\n+ step *= -1;\n+ }\n- for (R v = s.front(); v <= (s.back() + 0.0001f); v += step) // 0.0001f is a hack to avoid the miss of the last snr\n+ for (R v = min; v <= max; v += step)\nrange.push_back(v);\n}\nstd::sort(range.begin(), range.end());\n- std::unique(range.begin(), range.end(), comp_equal<R>);\n- return range;\n+ auto last = std::unique(range.begin(), range.end());\n+ auto new_length = std::distance(range.begin(), last);\n+\n+ std::vector<R> rangeR(new_length);\n+\n+ for (unsigned i = 0; i < new_length; i++)\n+ rangeR[i] = ((R)range[i])/float_precision;\n+\n+ return rangeR;\n}\n// ==================================================================================== explicit template instantiation\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix the generate range function to handle decreasing ranges and weird float precisions; Cosmetics
|
8,483 |
13.04.2018 18:02:52
| -7,200 |
b2581f09bf7e1ece8ae98f08d6e203c5206f6930
|
Create an 'erased value' function; Alternate with a positive and negative sign on the 0 llr of the erased bits
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/BEC/Channel_BEC.cpp",
"new_path": "src/Module/Channel/BEC/Channel_BEC.cpp",
"diff": "@@ -74,10 +74,9 @@ void Channel_BEC<R>\n::_add_noise(const R *X_N, R *Y_N, const int frame_id)\n{\nconst auto erasure_probability = this->n.get_ep();\n- const auto erased_value = std::numeric_limits<R>::infinity();\n- const mipp::Reg<R> r_erased = erased_value;\n+ const mipp::Reg<R> r_erased = tools::erased_value<R>();\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@@ -91,7 +90,7 @@ void Channel_BEC<R>\n}\nfor (auto i = vec_loop_size; i < this->N; i++)\n- Y_N[i] = get_random() <= erasure_probability ? erased_value : X_N[i];\n+ Y_N[i] = get_random() <= erasure_probability ? tools::erased_value<R>() : X_N[i];\n}\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/OOK/Modem_OOK.cpp",
"new_path": "src/Module/Modem/OOK/Modem_OOK.cpp",
"diff": "@@ -70,9 +70,18 @@ void Modem_OOK<B,R,Q>\nY_N2[i] = -((Q) 2.0 * Y_N1[i] - (Q) 1) * (Q) sigma_factor;\nbreak;\ncase tools::Noise_type::EP:\n+ {\n+ auto sign = (Q)0.00001;\nfor (auto i = 0; i < this->N_fil; i++)\n- Y_N2[i] = Y_N1[i] == std::numeric_limits<Q>::infinity() ? (Q) 0 : ((Q) 1 - (Q) 2.0 * Y_N1[i]);\n+ if (Y_N1[i] == tools::erased_value<Q>())\n+ {\n+ Y_N2[i] = sign;\n+ sign *= (Q) -1;\n+ }\n+ else\n+ Y_N2[i] = ((Q) 1 - (Q) 2.0 * Y_N1[i]);\nbreak;\n+ }\ndefault:\n{\nstd::stringstream message;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Noise.hpp",
"new_path": "src/Tools/Noise.hpp",
"diff": "#include <utility>\n#include <string>\n+#include <limits>\nnamespace aff3ct\n{\n@@ -11,6 +12,12 @@ namespace tools\nenum class Noise_type : uint8_t{ SIGMA, ROP, EP }; // Sigma (SNR variance), Received optical power, Erasure Probability\n+template <typename R = float>\n+extern constexpr R erased_value() // return a predefined value that represents an Erased Value in a Binary Erasure Channel\n+{\n+ return std::numeric_limits<R>::infinity();\n+}\n+\ntemplate <typename R = float>\nclass Noise\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Create an 'erased value' function; Alternate with a positive and negative sign on the 0 llr of the erased bits
|
8,483 |
16.04.2018 11:19:18
| -7,200 |
19b3894b07af8a90cb0dd66069af9792c6633303
|
Fix the K existing check in the BCH decoder factory
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Decoder/BCH/Decoder_BCH.cpp",
"new_path": "src/Factory/Module/Decoder/BCH/Decoder_BCH.cpp",
"diff": "@@ -66,9 +66,11 @@ void Decoder_BCH::parameters\n}\nif (vals.exist({p+\"-corr-pow\", \"T\"}))\n+ {\nthis->t = vals.to_int({p + \"-corr-pow\", \"T\"});\n- if (!vals.exist({p+\"-info-bits\", \"K\"}))\n+ if (K == 0)\nthis->K = this->N_cw - this->t * this->m;\n+ }\nelse\nthis->t = (this->N_cw - this->K) / this->m;\n}\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Fix the K existing check in the BCH decoder factory
|
8,483 |
16.04.2018 11:25:33
| -7,200 |
a5809a783d0edfc6588e82c06f0bcf5c828cf5af
|
Remove K in the Gallois field generator, then can compute automatically the number of redundancy bits and then K when giving N and T to a BCH code
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Decoder/BCH/Decoder_BCH.cpp",
"new_path": "src/Factory/Module/Decoder/BCH/Decoder_BCH.cpp",
"diff": "@@ -69,7 +69,7 @@ void Decoder_BCH::parameters\n{\nthis->t = vals.to_int({p + \"-corr-pow\", \"T\"});\nif (K == 0)\n- this->K = this->N_cw - this->t * this->m;\n+ this->K = this->N_cw - tools::BCH_polynomial_generator(this->N_cw, this->t).get_n_rdncy();\n}\nelse\nthis->t = (this->N_cw - this->K) / this->m;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Codec/BCH/Codec_BCH.cpp",
"new_path": "src/Module/Codec/BCH/Codec_BCH.cpp",
"diff": "@@ -16,7 +16,7 @@ Codec_BCH<B,Q>\nconst factory::Decoder_BCH::parameters &dec_params)\n: Codec <B,Q>(enc_params.K, enc_params.N_cw, enc_params.N_cw, enc_params.tail_length, enc_params.n_frames),\nCodec_SIHO_HIHO<B,Q>(enc_params.K, enc_params.N_cw, enc_params.N_cw, enc_params.tail_length, enc_params.n_frames),\n- GF_poly(dec_params.K, tools::next_power_of_2(dec_params.N_cw) -1, dec_params.t)\n+ GF_poly(tools::next_power_of_2(dec_params.N_cw) -1, dec_params.t)\n{\nconst std::string name = \"Codec_BCH\";\nthis->set_name(name);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/BCH/BCH_polynomial_generator.cpp",
"new_path": "src/Tools/Code/BCH/BCH_polynomial_generator.cpp",
"diff": "using namespace aff3ct::tools;\nBCH_polynomial_generator\n-::BCH_polynomial_generator(const int& K, const int& N, const int& t)\n- : Galois(K, N), t(t), d(2 * t + 1)\n+::BCH_polynomial_generator(const int& N, const int& t)\n+ : Galois(N), t(t), d(2 * t + 1)\n{\nif (t < 1)\n{\n@@ -113,16 +113,6 @@ void BCH_polynomial_generator\n}\n}\n-\n- if (this->K > this->N - rdncy)\n- {\n- std::stringstream message;\n- message << \"'K' seems to be too big for this correction power 't' ('K' = \" << this->K << \", 't' = \" << t\n- << \", 'N' = \" << this->N << \", 'rdncy' = \" << rdncy << \").\";\n- throw runtime_error(__FILE__, __LINE__, __func__, message.str());\n- }\n-\n-\nzeros.resize(rdncy+1);\nint kaux = 1;\ntest = true;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Code/BCH/BCH_polynomial_generator.hpp",
"new_path": "src/Tools/Code/BCH/BCH_polynomial_generator.hpp",
"diff": "@@ -18,7 +18,7 @@ protected:\nstd::vector<int> g; // coefficients of the generator polynomial, g(x)\npublic:\n- BCH_polynomial_generator(const int& K, const int& N, const int& t);\n+ BCH_polynomial_generator(const int& N, const int& t);\nvirtual ~BCH_polynomial_generator();\nint get_d () const;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/Galois.cpp",
"new_path": "src/Tools/Math/Galois.cpp",
"diff": "using namespace aff3ct::tools;\nGalois\n-::Galois(const int& K, const int& N)\n- : K(K), N(N), m((int)std::ceil(std::log2(N))), alpha_to(N +1), index_of(N +1), p(m +1, 0)\n+::Galois(const int& N)\n+ : N(N), m((int)std::ceil(std::log2(N))), alpha_to(N +1), index_of(N +1), p(m +1, 0)\n{\n- if (K <= 0)\n- {\n- std::stringstream message;\n- message << \"'K' has to be greater than 0 ('K' = \" << K << \").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\nif (N <= 0)\n{\nstd::stringstream message;\n@@ -27,13 +20,6 @@ Galois\nthrow tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n}\n- if (K > N)\n- {\n- std::stringstream message;\n- message << \"'K' has to be smaller or equal to 'N' ('K' = \" << K << \", 'N' = \" << N << \").\";\n- throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());\n- }\n-\nif (m != (int)std::ceil(std::log2(N +1)))\n{\nstd::stringstream message;\n@@ -64,12 +50,6 @@ Galois\n{\n}\n-int Galois\n-::get_K() const\n-{\n- return K;\n-}\n-\nint Galois\n::get_N() const\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Math/Galois.hpp",
"new_path": "src/Tools/Math/Galois.hpp",
"diff": "@@ -10,7 +10,6 @@ namespace tools\nclass Galois\n{\nprotected:\n- const int K;\nconst int N; // number of non-nul elements in the field : N = 2^m - 1\nconst int m; // order of the Galois Field\n@@ -19,10 +18,9 @@ protected:\nstd::vector<int> p; // coefficients of a primitive polynomial used to generate GF(2**m)\npublic:\n- Galois(const int& K, const int& N);\n+ Galois(const int& N);\nvirtual ~Galois();\n- int get_K() const;\nint get_N() const;\nint get_m() const;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Remove K in the Gallois field generator, then can compute automatically the number of redundancy bits and then K when giving N and T to a BCH code
|
8,483 |
16.04.2018 11:32:42
| -7,200 |
30e8ca57d71f0a1fbe4c7ea846f69cecc4aff837
|
Recalculate the code rate after setting K from T and N
|
[
{
"change_type": "MODIFY",
"old_path": "src/Factory/Module/Decoder/BCH/Decoder_BCH.cpp",
"new_path": "src/Factory/Module/Decoder/BCH/Decoder_BCH.cpp",
"diff": "@@ -69,7 +69,10 @@ void Decoder_BCH::parameters\n{\nthis->t = vals.to_int({p + \"-corr-pow\", \"T\"});\nif (K == 0)\n+ {\nthis->K = this->N_cw - tools::BCH_polynomial_generator(this->N_cw, this->t).get_n_rdncy();\n+ this->R = (float) this->K / (float) this->N_cw;\n+ }\n}\nelse\nthis->t = (this->N_cw - this->K) / this->m;\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Recalculate the code rate after setting K from T and N
|
8,483 |
16.04.2018 14:25:05
| -7,200 |
b2b6daadbc2e946e22b49663e2812b44f1adae75
|
Enhance the Terminals with the Noise type and by adding general tools in Terminal interface
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/BFER/Terminal_BFER.cpp",
"new_path": "src/Tools/Display/Terminal/BFER/Terminal_BFER.cpp",
"diff": "#include <iostream>\n#include <iomanip>\n#include <sstream>\n-#include <utility>\n#include <ios>\n-\n#include <rang.hpp>\n#include \"Tools/Exception/exception.hpp\"\nusing namespace aff3ct;\nusing namespace aff3ct::tools;\n-const char comment_tag = '#';\n-const char col_separator = '|';\n-const char line_separator = '-';\n-const std::string spaced_scol_separator = \" |\" ;\n-const std::string spaced_dcol_separator = \" ||\";\n-\n-#ifdef _WIN32\n-const int column_width = 11;\n-#else\n-const int column_width = 10;\n-#endif\ntemplate <typename B>\nTerminal_BFER<B>\n@@ -55,42 +42,16 @@ void Terminal_BFER<B>\nthis->noise.set_noise(n.get_noise(), n.get_type());\n}\n-template <typename B>\n-std::string Terminal_BFER<B>\n-::get_time_format(float secondes)\n-{\n- auto ss = (int)secondes % 60;\n- auto mm = ((int)(secondes / 60.f) % 60);\n- auto hh = (int)(secondes / 3600.f);\n-\n- // TODO: this is not a C++ style code\n- char time_format[256];\n-#ifdef _MSC_VER\n- sprintf_s(time_format, 32, \"%2.2dh%2.2d'%2.2d\", hh, mm, ss);\n-#else\n- sprintf(time_format, \"%2.2dh%2.2d'%2.2d\", hh, mm, ss);\n-#endif\n- std::string time_format2(time_format);\n-\n- return time_format2;\n-}\n-\ntemplate <typename B>\nvoid Terminal_BFER<B>\n::legend(std::ostream &stream)\n{\n- std::ios::fmtflags f(stream.flags());\n-\n- // vector of pairs {group title, columns titles}\n- // group title is a pair {first line, second line}\n- // columns titles is a vector of pair {first line, second line}\n- std::vector<std::pair<std::pair<std::string, std::string>, std::vector<std::pair<std::string, std::string>>>> cols_groups(2);\n-\n+ this->cols_groups.resize(2);\n- auto& bfer_title = cols_groups[0].first;\n- auto& bfer_cols = cols_groups[0].second;\n- auto& throughput_title = cols_groups[1].first;\n- auto& throughput_cols = cols_groups[1].second;\n+ auto& bfer_title = this->cols_groups[0].first;\n+ auto& bfer_cols = this->cols_groups[0].second;\n+ auto& throughput_title = this->cols_groups[1].first;\n+ auto& throughput_cols = this->cols_groups[1].second;\nbfer_title = std::make_pair(\"Bit Error Rate (BER) and Frame Error Rate (FER)\", \"\");\n@@ -130,112 +91,7 @@ void Terminal_BFER<B>\n// stream << \"# \" << \" | | | | | || (Mb/s) | (hhmmss) \" << std::endl;\n// stream << \"# \" << \"---------|-----------|-----------|-----------|-----------|-----------||----------|----------\" << std::endl;\n-\n- const auto legend_style = rang::style::bold;\n-\n- // print first line of the table\n- stream << comment_tag << \" \";\n- for (unsigned i = 0; i < cols_groups.size(); i++)\n- {\n- const unsigned group_width = cols_groups[i].second.size()*(column_width+1)-1; // add a col separator between each exept for the last\n- stream << legend_style << std::string(group_width, line_separator) << rang::style::reset ;\n-\n- if (i < (cols_groups.size() -1)) // print group separator except for last\n- stream << legend_style << std::string(2, col_separator) << rang::style::reset ;\n- }\n- stream << std::endl;\n-\n- // print line 2 and 3 of the table (group title lines)\n- for (auto l = 0; l < 2; l++)\n- {\n- stream << comment_tag << \" \";\n- for (unsigned i = 0; i < cols_groups.size(); i++)\n- {\n- const auto& text = l == 0 ? cols_groups[i].first.first : cols_groups[i].first.second;\n-\n- const unsigned group_width = cols_groups[i].second.size()*(column_width+1)-1; // add a col separator between each exept for the last\n- const int n_spaces = (int)group_width - (int)text.size();\n- const int n_spaces_left = n_spaces/2;\n- const int n_spaces_right = n_spaces - n_spaces_left; // can be different than n_spaces/2 if odd size\n- stream << legend_style << std::string(n_spaces_left, ' ') << rang::style::reset ;\n- stream << legend_style << text << rang::style::reset ;\n- stream << legend_style << std::string(n_spaces_right, ' ') << rang::style::reset ;\n-\n- if (i < (cols_groups.size() -1)) // print group separator except for last\n- stream << legend_style << std::string(2, col_separator) << rang::style::reset;\n- }\n- stream << std::endl;\n- }\n-\n- // print line 4 of the table\n- stream << comment_tag << \" \";\n- for (unsigned i = 0; i < cols_groups.size(); i++)\n- {\n- const unsigned group_width = cols_groups[i].second.size()*(column_width+1)-1; // add a col separator between each exept for the last\n- stream << legend_style << std::string(group_width, line_separator) << rang::style::reset;\n-\n- if (i < (cols_groups.size() -1)) // print group separator except for last\n- stream << legend_style << std::string(2, col_separator) << rang::style::reset;\n- }\n- stream << std::endl;\n-\n- // print line 5 of the table\n- stream << comment_tag << \" \";\n- for (unsigned i = 0; i < cols_groups.size(); i++)\n- {\n- for (unsigned j = 0; j < cols_groups[i].second.size(); j++)\n- {\n- stream << legend_style << std::string(column_width, line_separator) << rang::style::reset;\n- if (j < (cols_groups[i].second.size() -1)) // print column separator except for last\n- stream << legend_style << std::string(1, col_separator) << rang::style::reset;\n- }\n-\n- if (i < (cols_groups.size() -1)) // print group separator except for last\n- stream << legend_style << std::string(2, col_separator) << rang::style::reset;\n- }\n- stream << std::endl;\n-\n- // print line 6 and 7 of the table (column title lines)\n- for (auto l = 0; l < 2; l++)\n- {\n- stream << comment_tag << \" \";\n- for (unsigned i = 0; i < cols_groups.size(); i++)\n- {\n-\n- for (unsigned j = 0; j < cols_groups[i].second.size(); j++)\n- {\n- const auto& text = l == 0 ? cols_groups[i].second[j].first : cols_groups[i].second[j].second;\n- const int n_spaces = (int)column_width - (int)text.size() -1;\n- stream << legend_style << std::string(n_spaces, ' ') << rang::style::reset;\n- stream << legend_style << text + \" \" << rang::style::reset;\n-\n- if (j < (cols_groups[i].second.size() -1)) // print column separator except for last\n- stream << legend_style << std::string(1, col_separator) << rang::style::reset;\n- }\n-\n- if (i < (cols_groups.size() -1)) // print group separator except for last\n- stream << legend_style << std::string(2, col_separator) << rang::style::reset;\n- }\n- stream << std::endl;\n- }\n-\n- // print line 8 of the table\n- stream << comment_tag << \" \";\n- for (unsigned i = 0; i < cols_groups.size(); i++)\n- {\n- for (unsigned j = 0; j < cols_groups[i].second.size(); j++)\n- {\n- stream << legend_style << std::string(column_width, line_separator) << rang::style::reset;\n- if (j < (cols_groups[i].second.size() -1)) // print column separator except for last\n- stream << legend_style << std::string(1, col_separator) << rang::style::reset;\n- }\n-\n- if (i < (cols_groups.size() -1)) // print group separator except for last\n- stream << legend_style << std::string(2, col_separator) << rang::style::reset;\n- }\n- stream << std::endl;\n-\n- stream.flags(f);\n+ Terminal::legend(stream); // print effectively the legend\n}\nstd::string get_spaces_left(const std::string& str, const int total_width)\n@@ -263,13 +119,10 @@ void Terminal_BFER<B>\nif (module::Monitor::is_interrupt()) stream << \"\\r\";\n- stream << \" \" ; // left offset\n-\n- const std::string undefined_noise_tag = \"- \";\n+ stream << data_tag;\nconst auto report_style = rang::style::bold;\n-\nswitch (this->noise.get_type())\n{\ncase Noise_type::SIGMA :\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": "@@ -35,7 +35,6 @@ public:\nvoid final_report(std::ostream &stream = std::cout);\nprotected:\n- static std::string get_time_format(float secondes);\nvoid _report(std::ostream &stream);\n};\n}\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": "@@ -15,60 +15,24 @@ Terminal_EXIT<B,R>\n::Terminal_EXIT(const module::Monitor_EXIT<B,R> &monitor)\n: Terminal(),\nmonitor(monitor),\n- esn0(0.f),\n- ebn0(0.f),\n- sig_a(0.f),\nt_snr(std::chrono::steady_clock::now()),\n- real_time_state(0)\n+ real_time_state(0),\n+ sig_a(0.f)\n{\n}\n-template <typename B, typename R>\n-std::string Terminal_EXIT<B,R>\n-::get_time_format(float secondes)\n-{\n- auto ss = (int)secondes % 60;\n- auto mm = ((int)(secondes / 60.f) % 60);\n- auto hh = (int)(secondes / 3600.f);\n-\n- // TODO: this is not a C++ style code\n- char time_format[256];\n-#ifdef _MSC_VER\n- sprintf_s(time_format, 32, \"%2.2dh%2.2d'%2.2d\", hh, mm, ss);\n-#else\n- sprintf(time_format, \"%2.2dh%2.2d'%2.2d\", hh, mm, ss);\n-#endif\n- std::string time_format2(time_format);\n-\n- return time_format2;\n-}\n-\n-template <typename B, typename R>\n-void Terminal_EXIT<B,R>\n-::set_esn0(const float esn0)\n-{\n- this->esn0 = esn0;\n-}\n-\n-template <typename B, typename R>\n-void Terminal_EXIT<B,R>\n-::set_ebn0(const float ebn0)\n-{\n- this->ebn0 = ebn0;\n-}\n-\ntemplate <typename B, typename R>\nvoid Terminal_EXIT<B,R>\n::set_noise(const Noise<float>& n)\n{\n- // this->noise = n;\n+ this->noise = n;\n}\ntemplate <typename B, typename R>\nvoid Terminal_EXIT<B,R>\n::set_noise(const Noise<double>& n)\n{\n- // this->noise.set_noise(n.get_noise(), n.get_type());\n+ this->noise.set_noise(n.get_noise(), n.get_type());\n}\ntemplate <typename B, typename R>\n@@ -82,18 +46,54 @@ template <typename B, typename R>\nvoid Terminal_EXIT<B,R>\n::legend(std::ostream &stream)\n{\n- std::ios::fmtflags f(stream.flags());\n+ this->cols_groups.resize(2);\n- stream << \"# \" << rang::style::bold << \"----------------------------------------------------------||---------------------\" << rang::style::reset << std::endl;\n- stream << \"# \" << rang::style::bold << \" EXIT chart depending on the Signal Noise Ratio (SNR) || Global throughput \" << rang::style::reset << std::endl;\n- stream << \"# \" << rang::style::bold << \" and the channel A noise || and elapsed time \" << rang::style::reset << std::endl;\n- stream << \"# \" << rang::style::bold << \"----------------------------------------------------------||---------------------\" << rang::style::reset << std::endl;\n- stream << \"# \" << rang::style::bold << \"-------|-------|-------|----------|-----------|-----------||----------|----------\" << rang::style::reset << std::endl;\n- stream << \"# \" << rang::style::bold << \" Es/N0 | Eb/N0 | SIG_A | FRA | A_PRIORI | EXTRINSIC || SIM_THR | ET/RT \" << rang::style::reset << std::endl;\n- stream << \"# \" << rang::style::bold << \" (dB) | (dB) | (dB) | | (I_A) | (I_E) || (Mb/s) | (hhmmss) \" << rang::style::reset << std::endl;\n- stream << \"# \" << rang::style::bold << \"-------|-------|-------|----------|-----------|-----------||----------|----------\" << rang::style::reset << std::endl;\n+ auto& bfer_title = this->cols_groups[0].first;\n+ auto& bfer_cols = this->cols_groups[0].second;\n+ auto& throughput_title = this->cols_groups[1].first;\n+ auto& throughput_cols = this->cols_groups[1].second;\n- stream.flags(f);\n+ bfer_title = std::make_pair(\"EXIT chart depending on the\", \"\");\n+\n+ switch (this->noise.get_type())\n+ {\n+ case Noise_type::SIGMA :\n+ bfer_title.second = \"Signal Noise Ratio (SNR)\";\n+ bfer_cols.push_back(std::make_pair(\"Es/N0\", \"(dB)\"));\n+ bfer_cols.push_back(std::make_pair(\"Eb/N0\", \"(dB)\"));\n+ break;\n+ case Noise_type::ROP :\n+ bfer_title.second = \"Received Optical Power (ROP)\";\n+ bfer_cols.push_back(std::make_pair(\"ROP\", \"(dB)\"));\n+ break;\n+ case Noise_type::EP :\n+ bfer_title.second = \"Erasure Probability (EP)\";\n+ bfer_cols.push_back(std::make_pair(\"EP\", \"\"));\n+ break;\n+ }\n+\n+ bfer_title.second += \" and the channel A noise\";\n+\n+ bfer_cols.push_back(std::make_pair(\"SIG_A\", \"(dB)\"));\n+ bfer_cols.push_back(std::make_pair(\"FRA\", \"\"));\n+ bfer_cols.push_back(std::make_pair(\"A_PRIORI\", \"(I_A)\"));\n+ bfer_cols.push_back(std::make_pair(\"EXTRINSIC\", \"(I_E)\"));\n+\n+ throughput_title = std::make_pair(\"Global throughput\", \"and elapsed time\");\n+ throughput_cols.push_back(std::make_pair(\"SIM_THR\", \"(Mb/s)\"));\n+ throughput_cols.push_back(std::make_pair(\"ET/RT\", \"(hhmmss)\"));\n+\n+\n+ // stream << \"# \" << rang::style::bold << \"----------------------------------------------------------||---------------------\" << rang::style::reset << std::endl;\n+ // stream << \"# \" << rang::style::bold << \" EXIT chart depending on the || Global throughput \" << rang::style::reset << std::endl;\n+ // stream << \"# \" << rang::style::bold << \" Signal Noise Ratio (SNR) and the channel A noise || and elapsed time \" << rang::style::reset << std::endl;\n+ // stream << \"# \" << rang::style::bold << \"----------------------------------------------------------||---------------------\" << rang::style::reset << std::endl;\n+ // stream << \"# \" << rang::style::bold << \"-------|-------|-------|----------|-----------|-----------||----------|----------\" << rang::style::reset << std::endl;\n+ // stream << \"# \" << rang::style::bold << \" Es/N0 | Eb/N0 | SIG_A | FRA | A_PRIORI | EXTRINSIC || SIM_THR | ET/RT \" << rang::style::reset << std::endl;\n+ // stream << \"# \" << rang::style::bold << \" (dB) | (dB) | (dB) | | (I_A) | (I_E) || (Mb/s) | (hhmmss) \" << rang::style::reset << std::endl;\n+ // stream << \"# \" << rang::style::bold << \"-------|-------|-------|----------|-----------|-----------||----------|----------\" << rang::style::reset << std::endl;\n+\n+ Terminal::legend(stream); // print effectively the legend\n}\ntemplate <typename B, typename R>\n@@ -113,14 +113,32 @@ void Terminal_EXIT<B,R>\nsimu_cthr /= 1000.f; // = kbps\nsimu_cthr /= 1000.f; // = mbps\n- stream << \" \";\n- stream << setprecision(2) << fixed << setw(5) << esn0 << rang::style::bold << \" | \" << rang::style::reset;\n- stream << setprecision(2) << fixed << setw(5) << ebn0 << rang::style::bold << \" | \" << rang::style::reset;\n- stream << setprecision(2) << fixed << setw(5) << sig_a << rang::style::bold << \" | \" << rang::style::reset;\n- stream << setprecision(2) << fixed << setw(8) << fra << rang::style::bold << \" | \" << rang::style::reset;\n- stream << setprecision(6) << fixed << setw(9) << I_A << rang::style::bold << \" | \" << rang::style::reset;\n- stream << setprecision(6) << fixed << setw(9) << I_E << rang::style::bold << \" || \" << rang::style::reset;\n- stream << setprecision(2) << fixed << setw(8) << simu_cthr;\n+ stream << data_tag;\n+\n+ switch (this->noise.get_type())\n+ {\n+ case Noise_type::SIGMA :\n+ stream << setprecision(2) << fixed << setw(column_width-1) << this->noise.get_esn0() << report_style\n+ << spaced_scol_separator << rang::style::reset;\n+ stream << setprecision(2) << fixed << setw(column_width-1) << this->noise.get_ebn0() << report_style\n+ << spaced_scol_separator << rang::style::reset;\n+ break;\n+ case Noise_type::ROP :\n+ stream << setprecision(2) << fixed << setw(column_width-1) << this->noise.get_rop() << report_style\n+ << spaced_scol_separator << rang::style::reset;\n+ break;\n+ case Noise_type::EP :\n+ stream << setprecision(4) << fixed << setw(column_width-1) << this->noise.get_ep() << report_style\n+ << spaced_scol_separator << rang::style::reset;\n+ break;\n+ }\n+\n+\n+ stream << setprecision(2) << fixed << setw(column_width-1) << sig_a << rang::style::bold << spaced_scol_separator << rang::style::reset;\n+ stream << setprecision(2) << fixed << setw(column_width-1) << fra << rang::style::bold << spaced_scol_separator << rang::style::reset;\n+ stream << setprecision(6) << fixed << setw(column_width-1) << I_A << rang::style::bold << spaced_scol_separator << rang::style::reset;\n+ stream << setprecision(6) << fixed << setw(column_width-1) << I_E << rang::style::bold << spaced_dcol_separator << rang::style::reset;\n+ stream << setprecision(2) << fixed << setw(column_width-1) << simu_cthr;\n}\ntemplate <typename B, typename R>\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": "@@ -19,19 +19,16 @@ class Terminal_EXIT : public Terminal\n{\nprotected:\nconst module::Monitor_EXIT<B,R> &monitor;\n- float esn0;\n- float ebn0;\n- float sig_a;\nstd::chrono::time_point<std::chrono::steady_clock, std::chrono::nanoseconds> t_snr;\nunsigned short real_time_state;\n+ float sig_a;\n+ Noise<> noise;\npublic:\nexplicit Terminal_EXIT(const module::Monitor_EXIT<B,R> &monitor);\nvirtual ~Terminal_EXIT() {}\n- void set_esn0 (const float esn0 );\n- void set_ebn0 (const float ebn0 );\nvoid set_sig_a(const float sig_a);\nvoid set_noise(const Noise<float>& noise);\n@@ -42,7 +39,6 @@ public:\nvoid final_report(std::ostream &stream = std::cout);\nprotected:\n- static std::string get_time_format(float secondes);\nvoid _report(std::ostream &stream);\n};\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/Terminal.cpp",
"new_path": "src/Tools/Display/Terminal/Terminal.cpp",
"diff": "using namespace aff3ct;\nusing namespace aff3ct::tools;\n+\n+const char aff3ct::tools::Terminal::col_separator = '|';\n+const char aff3ct::tools::Terminal::line_separator = '-';\n+const std::string aff3ct::tools::Terminal::comment_tag = \"# \";\n+const std::string aff3ct::tools::Terminal::spaced_scol_separator = \" |\" ;\n+const std::string aff3ct::tools::Terminal::spaced_dcol_separator = \" ||\";\n+const std::string aff3ct::tools::Terminal::data_tag = \" \";\n+const rang::style aff3ct::tools::Terminal::legend_style = rang::style::bold;\n+const rang::style aff3ct::tools::Terminal::report_style = rang::style::bold;\n+\n+\nTerminal\n::Terminal()\n: stop_terminal(false)\n@@ -18,6 +29,134 @@ Terminal\nvoid Terminal\n::legend(std::ostream &stream)\n{\n+ std::ios::fmtflags f(stream.flags());\n+\n+ // stream << \"# \" << \"----------------------------------------------||---------------------------------\" << std::endl; // line 1\n+ // stream << \"# \" << \" cols_groups[0].first.first || cols_groups[1].first.first \" << std::endl; // line 2\n+ // stream << \"# \" << \" cols_groups[0].first.second || cols_groups[1].first.second \" << std::endl; // line 3\n+ // stream << \"# \" << \"----------------------------------------------||---------------------------------\" << std::endl; // line 4\n+ // stream << \"# \" << \"----------|-----------|-----------|-----------||----------|----------|-----------\" << std::endl; // line 5\n+ // stream << \"# \" << \" (1.1) | (2.1) | (3.1) | (4.1) || (5.1) | (6.1) | (7.1) \" << std::endl; // line 6\n+ // stream << \"# \" << \" (1.2) | (2.2) | (3.2) | (4.2) || (5.2) | (6.2) | (7.2) \" << std::endl; // line 7\n+ // stream << \"# \" << \"----------|-----------|-----------|-----------||----------|----------|-----------\" << std::endl; // line 8\n+ // indice (1.1) is \"cols_groups[0].second[0].first\"\n+ // indice (1.2) is \"cols_groups[0].second[0].second\"\n+ // indice (2.1) is \"cols_groups[0].second[1].first\"\n+ // indice (2.2) is \"cols_groups[0].second[1].second\"\n+ // indice (3.1) is \"cols_groups[0].second[2].first\"\n+ // indice (3.2) is \"cols_groups[0].second[2].second\"\n+ // indice (4.1) is \"cols_groups[0].second[3].first\"\n+ // indice (4.2) is \"cols_groups[0].second[3].second\"\n+ // indice (5.1) is \"cols_groups[1].second[0].first\"\n+ // indice (5.2) is \"cols_groups[1].second[0].second\"\n+ // indice (6.1) is \"cols_groups[1].second[1].first\"\n+ // indice (6.2) is \"cols_groups[1].second[1].second\"\n+ // indice (7.1) is \"cols_groups[1].second[2].first\"\n+ // indice (7.2) is \"cols_groups[1].second[2].second\"\n+\n+ // print line 1 of the table\n+ stream << comment_tag;\n+ for (unsigned i = 0; i < cols_groups.size(); i++)\n+ {\n+ const unsigned group_width = cols_groups[i].second.size()*(column_width+1)-1; // add a col separator between each exept for the last\n+ stream << legend_style << std::string(group_width, line_separator) << rang::style::reset ;\n+\n+ if (i < (cols_groups.size() -1)) // print group separator except for last\n+ stream << legend_style << std::string(2, col_separator) << rang::style::reset ;\n+ }\n+ stream << std::endl;\n+\n+ // print line 2 and 3 of the table (group title lines)\n+ for (auto l = 0; l < 2; l++)\n+ {\n+ stream << comment_tag;\n+ for (unsigned i = 0; i < cols_groups.size(); i++)\n+ {\n+ const auto& text = l == 0 ? cols_groups[i].first.first : cols_groups[i].first.second;\n+\n+ const unsigned group_width = cols_groups[i].second.size()*(column_width+1)-1; // add a col separator between each exept for the last\n+ const int n_spaces = (int)group_width - (int)text.size();\n+ const int n_spaces_left = n_spaces/2;\n+ const int n_spaces_right = n_spaces - n_spaces_left; // can be different than n_spaces/2 if odd size\n+ stream << legend_style << std::string(n_spaces_left, ' ') << rang::style::reset ;\n+ stream << legend_style << text << rang::style::reset ;\n+ stream << legend_style << std::string(n_spaces_right, ' ') << rang::style::reset ;\n+\n+ if (i < (cols_groups.size() -1)) // print group separator except for last\n+ stream << legend_style << std::string(2, col_separator) << rang::style::reset;\n+ }\n+ stream << std::endl;\n+ }\n+\n+ // print line 4 of the table\n+ stream << comment_tag;\n+ for (unsigned i = 0; i < cols_groups.size(); i++)\n+ {\n+ const unsigned group_width = cols_groups[i].second.size()*(column_width+1)-1; // add a col separator between each exept for the last\n+ stream << legend_style << std::string(group_width, line_separator) << rang::style::reset;\n+\n+ if (i < (cols_groups.size() -1)) // print group separator except for last\n+ stream << legend_style << std::string(2, col_separator) << rang::style::reset;\n+ }\n+ stream << std::endl;\n+\n+ // print line 5 of the table\n+ stream << comment_tag;\n+ for (unsigned i = 0; i < cols_groups.size(); i++)\n+ {\n+ for (unsigned j = 0; j < cols_groups[i].second.size(); j++)\n+ {\n+ stream << legend_style << std::string(column_width, line_separator) << rang::style::reset;\n+ if (j < (cols_groups[i].second.size() -1)) // print column separator except for last\n+ stream << legend_style << std::string(1, col_separator) << rang::style::reset;\n+ }\n+\n+ if (i < (cols_groups.size() -1)) // print group separator except for last\n+ stream << legend_style << std::string(2, col_separator) << rang::style::reset;\n+ }\n+ stream << std::endl;\n+\n+ // print line 6 and 7 of the table (column title lines)\n+ for (auto l = 0; l < 2; l++)\n+ {\n+ stream << comment_tag;\n+ for (unsigned i = 0; i < cols_groups.size(); i++)\n+ {\n+\n+ for (unsigned j = 0; j < cols_groups[i].second.size(); j++)\n+ {\n+ const auto& text = l == 0 ? cols_groups[i].second[j].first : cols_groups[i].second[j].second;\n+ const int n_spaces = (int)column_width - (int)text.size() -1;\n+ stream << legend_style << std::string(n_spaces, ' ') << rang::style::reset;\n+ stream << legend_style << text + \" \" << rang::style::reset;\n+\n+ if (j < (cols_groups[i].second.size() -1)) // print column separator except for last\n+ stream << legend_style << std::string(1, col_separator) << rang::style::reset;\n+ }\n+\n+ if (i < (cols_groups.size() -1)) // print group separator except for last\n+ stream << legend_style << std::string(2, col_separator) << rang::style::reset;\n+ }\n+ stream << std::endl;\n+ }\n+\n+ // print line 8 of the table\n+ stream << comment_tag;\n+ for (unsigned i = 0; i < cols_groups.size(); i++)\n+ {\n+ for (unsigned j = 0; j < cols_groups[i].second.size(); j++)\n+ {\n+ stream << legend_style << std::string(column_width, line_separator) << rang::style::reset;\n+ if (j < (cols_groups[i].second.size() -1)) // print column separator except for last\n+ stream << legend_style << std::string(1, col_separator) << rang::style::reset;\n+ }\n+\n+ if (i < (cols_groups.size() -1)) // print group separator except for last\n+ stream << legend_style << std::string(2, col_separator) << rang::style::reset;\n+ }\n+ stream << std::endl;\n+\n+ stream.flags(f);\n}\nvoid Terminal\n@@ -59,3 +198,21 @@ void Terminal\nterminal->temp_report(std::clog); // display statistics in the terminal\n}\n}\n+\n+std::string Terminal\n+::get_time_format(float secondes)\n+{\n+ auto ss = (int)secondes % 60;\n+ auto mm = ((int)(secondes / 60.f) % 60);\n+ auto hh = (int)(secondes / 3600.f);\n+\n+ // TODO: this is not a C++ style code\n+ char time_format[256];\n+#ifdef _MSC_VER\n+ sprintf_s(time_format, 32, \"%2.2dh%2.2d'%2.2d\", hh, mm, ss);\n+#else\n+ sprintf(time_format, \"%2.2dh%2.2d'%2.2d\", hh, mm, ss);\n+#endif\n+\n+ return std::string(time_format);\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/Terminal.hpp",
"new_path": "src/Tools/Display/Terminal/Terminal.hpp",
"diff": "#include <thread>\n#include <condition_variable>\n#include <iostream>\n+#include <vector>\n+#include <utility>\n+#include <rang.hpp>\nnamespace aff3ct\n{\n@@ -25,12 +28,36 @@ namespace tools\n*/\nclass Terminal\n{\n+public:\n+ static const char col_separator;\n+ static const char line_separator;\n+ static const std::string comment_tag;\n+ static const std::string spaced_scol_separator;\n+ static const std::string spaced_dcol_separator;\n+ static const std::string data_tag;\n+ static const rang::style legend_style;\n+ static const rang::style report_style;\n+\n+ #ifdef _WIN32\n+ const int column_width = 11;\n+ #else\n+ const int column_width = 10;\n+ #endif\n+\n+\nprivate:\nstd::thread term_thread;\nstd::mutex mutex_terminal;\nstd::condition_variable cond_terminal;\nbool stop_terminal;\n+protected:\n+ // vector of pairs {group title, columns titles}\n+ // group title is a pair {first line, second line}\n+ // columns titles is a vector of pair {first line, second line}\n+ std::vector<std::pair<std::pair<std::string, std::string>, std::vector<std::pair<std::string, std::string>>>> cols_groups;\n+\n+\npublic:\n/*!\n* \\brief Constructor.\n@@ -67,6 +94,8 @@ public:\nvoid stop_temp_report();\n+ static std::string get_time_format(float secondes);\n+\nprivate:\nstatic void start_thread_terminal(Terminal *terminal, const std::chrono::milliseconds freq);\n};\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Enhance the Terminals with the Noise type and by adding general tools in Terminal interface
|
8,483 |
16.04.2018 14:36:07
| -7,200 |
0b1ca2de4b053045d698c593427ed3400c7dd3ba
|
Move the Terminal's 'column_width' attribute instantiation in the .cpp
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/Terminal.cpp",
"new_path": "src/Tools/Display/Terminal/Terminal.cpp",
"diff": "@@ -13,6 +13,11 @@ const std::string aff3ct::tools::Terminal::data_tag = \" \";\nconst rang::style aff3ct::tools::Terminal::legend_style = rang::style::bold;\nconst rang::style aff3ct::tools::Terminal::report_style = rang::style::bold;\n+#ifdef _WIN32\n+const int aff3ct::tools::Terminal::column_width = 11;\n+#else\n+const int aff3ct::tools::Terminal::column_width = 10;\n+#endif\nTerminal\n::Terminal()\n@@ -122,7 +127,6 @@ void Terminal\nstream << comment_tag;\nfor (unsigned i = 0; i < cols_groups.size(); i++)\n{\n-\nfor (unsigned j = 0; j < cols_groups[i].second.size(); j++)\n{\nconst auto& text = l == 0 ? cols_groups[i].second[j].first : cols_groups[i].second[j].second;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/Terminal.hpp",
"new_path": "src/Tools/Display/Terminal/Terminal.hpp",
"diff": "@@ -37,12 +37,7 @@ public:\nstatic const std::string data_tag;\nstatic const rang::style legend_style;\nstatic const rang::style report_style;\n-\n- #ifdef _WIN32\n- const int column_width = 11;\n- #else\n- const int column_width = 10;\n- #endif\n+ static const int column_width;\nprivate:\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Move the Terminal's 'column_width' attribute instantiation in the .cpp
|
8,483 |
16.04.2018 15:48:48
| -7,200 |
1d8ad551bca80ae61ddce35cafdc5a0c12bdf732
|
Add string lib in Terminal
|
[
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/BFER/Terminal_BFER.cpp",
"new_path": "src/Tools/Display/Terminal/BFER/Terminal_BFER.cpp",
"diff": "@@ -94,11 +94,6 @@ void Terminal_BFER<B>\nTerminal::legend(stream); // print effectively the legend\n}\n-std::string get_spaces_left(const std::string& str, const int total_width)\n-{\n- return std::string(total_width - str.size() -1, ' '); // -1 because a space is reserved for the right\n-}\n-\ntemplate <typename B>\nvoid Terminal_BFER<B>\n::_report(std::ostream &stream)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Display/Terminal/Terminal.hpp",
"new_path": "src/Tools/Display/Terminal/Terminal.hpp",
"diff": "#include <iostream>\n#include <vector>\n#include <utility>\n+#include <string>\n#include <rang.hpp>\nnamespace aff3ct\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Add string lib in Terminal
|
8,483 |
17.04.2018 08:41:37
| -7,200 |
17e33f5c7d2477b1139f93c4ed649bb28a934b58
|
Move erased symbol value as a static attribute of Noise class and add erased LLR value
|
[
{
"change_type": "MODIFY",
"old_path": "src/Module/Channel/BEC/Channel_BEC.cpp",
"new_path": "src/Module/Channel/BEC/Channel_BEC.cpp",
"diff": "@@ -76,7 +76,7 @@ void Channel_BEC<R>\nconst auto erasure_probability = this->n.get_ep();\n- const mipp::Reg<R> r_erased = tools::erased_value<R>();\n+ const mipp::Reg<R> r_erased = tools::Noise<R>::erased_symbol_val;\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@@ -90,7 +90,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::erased_value<R>() : X_N[i];\n+ Y_N[i] = get_random() <= erasure_probability ? tools::Noise<R>::erased_symbol_val : X_N[i];\n}\n// ==================================================================================== explicit template instantiation\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Module/Modem/OOK/Modem_OOK.cpp",
"new_path": "src/Module/Modem/OOK/Modem_OOK.cpp",
"diff": "@@ -71,9 +71,9 @@ void Modem_OOK<B,R,Q>\nbreak;\ncase tools::Noise_type::EP:\n{\n- auto sign = (Q)0.00001;\n+ auto sign = (Q)tools::Noise<R>::erased_llr_val;\nfor (auto i = 0; i < this->N_fil; i++)\n- if (Y_N1[i] == tools::erased_value<Q>())\n+ if (Y_N1[i] == tools::Noise<R>::erased_symbol_val)\n{\nY_N2[i] = sign;\nsign *= (Q)-1;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Noise.cpp",
"new_path": "src/Tools/Noise.cpp",
"diff": "#include \"Noise.hpp\"\nusing namespace aff3ct;\n-using namespace tools;\n+using namespace aff3ct::tools;\n+\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;\ntemplate <typename R>\nNoise<R>::\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Tools/Noise.hpp",
"new_path": "src/Tools/Noise.hpp",
"diff": "@@ -12,16 +12,13 @@ namespace tools\nenum class Noise_type : uint8_t{ SIGMA, ROP, EP }; // Sigma (SNR variance), Received optical power, Erasure Probability\n-template <typename R = float>\n-extern constexpr R erased_value() // return a predefined value that represents an Erased Value in a Binary Erasure Channel\n-{\n- return std::numeric_limits<R>::infinity();\n-}\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(const R noise, const Noise_type t = Noise_type::SIGMA);\n"
}
] |
C++
|
MIT License
|
aff3ct/aff3ct
|
Move erased symbol value as a static attribute of Noise class and add erased LLR value
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.