From 7e589c85ef5da58c8babcd324dc03616cdb62e53 Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Sat, 10 Feb 2024 19:46:25 +0100 Subject: [PATCH] keep ranges symmetric --- polar_helper.hh | 8 ++++---- tests/hadamard_regression_test.cc | 2 +- tests/ldpc_regression_test.cc | 2 +- tests/osd_regression_test.cc | 2 +- tests/osld_regression_test.cc | 2 +- tests/simplex_regression_test.cc | 2 +- tests/soft_bch_regression_test.cc | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/polar_helper.hh b/polar_helper.hh index 84a02ba..060eea2 100644 --- a/polar_helper.hh +++ b/polar_helper.hh @@ -172,7 +172,7 @@ struct PolarHelper template static int8_t quant(IN in) { - return std::min(std::max(std::nearbyint(in), -128), 127); + return std::min(std::max(std::nearbyint(in), -127), 127); } static int8_t qabs(int8_t a) { @@ -184,11 +184,11 @@ struct PolarHelper } static int8_t qadd(int8_t a, int8_t b) { - return std::min(std::max(int16_t(a) + int16_t(b), -128), 127); + return std::min(std::max(int16_t(a) + int16_t(b), -127), 127); } static int8_t qmul(int8_t a, int8_t b) { - // return std::min(std::max(int16_t(a) * int16_t(b), -128), 127); + // return std::min(std::max(int16_t(a) * int16_t(b), -127), 127); // only used for hard decision values anyway return a * b; } @@ -198,7 +198,7 @@ struct PolarHelper } static int8_t madd(int8_t a, int8_t b, int8_t c) { - return std::min(std::max(int16_t(a) * int16_t(b) + int16_t(c), -128), 127); + return std::min(std::max(int16_t(a) * int16_t(b) + int16_t(c), -127), 127); } }; diff --git a/tests/hadamard_regression_test.cc b/tests/hadamard_regression_test.cc index 1e1739b..009ce36 100644 --- a/tests/hadamard_regression_test.cc +++ b/tests/hadamard_regression_test.cc @@ -98,7 +98,7 @@ int main() float DIST = 2; // BPSK float fact = DIST / (sigma_noise * sigma_noise); for (int i = 0; i < CODE_LEN; ++i) - code[i] = std::min(std::max(std::nearbyint(fact * symb[i]), -128), 127); + code[i] = std::min(std::max(std::nearbyint(fact * symb[i]), -127), 127); for (int i = 0; i < CODE_LEN; ++i) noisy[i] = code[i]; diff --git a/tests/ldpc_regression_test.cc b/tests/ldpc_regression_test.cc index 732d8ea..8a40082 100644 --- a/tests/ldpc_regression_test.cc +++ b/tests/ldpc_regression_test.cc @@ -579,7 +579,7 @@ int main() float DIST = 2; // BPSK float fact = DIST * FACTOR / (sigma_noise * sigma_noise); for (int i = 0; i < CODE_LEN; ++i) - code[i] = std::min(std::max(std::nearbyint(fact * symb[i]), -128), 127); + code[i] = std::min(std::max(std::nearbyint(fact * symb[i]), -127), 127); for (int i = 0; i < CODE_LEN; ++i) noisy[i] = code[i]; diff --git a/tests/osd_regression_test.cc b/tests/osd_regression_test.cc index a3def17..dee1f24 100644 --- a/tests/osd_regression_test.cc +++ b/tests/osd_regression_test.cc @@ -112,7 +112,7 @@ int main() double DIST = 2; // BPSK double fact = DIST / (sigma_noise * sigma_noise); for (int i = 0; i < N; ++i) - noisy[i] = std::min(std::max(std::nearbyint(fact * symb[i]), -128), 127); + noisy[i] = std::min(std::max(std::nearbyint(fact * symb[i]), -127), 127); bool unique = osddec(decoded, noisy, genmat); diff --git a/tests/osld_regression_test.cc b/tests/osld_regression_test.cc index 598513c..2f33133 100644 --- a/tests/osld_regression_test.cc +++ b/tests/osld_regression_test.cc @@ -115,7 +115,7 @@ int main() double DIST = 2; // BPSK double fact = DIST / (sigma_noise * sigma_noise); for (int i = 0; i < N; ++i) - noisy[i] = std::min(std::max(std::nearbyint(fact * symb[i]), -128), 127); + noisy[i] = std::min(std::max(std::nearbyint(fact * symb[i]), -127), 127); osddec(rank, decoded, noisy, genmat); bool unique = rank[0] != rank[1]; diff --git a/tests/simplex_regression_test.cc b/tests/simplex_regression_test.cc index 625ccaa..a43a6cd 100644 --- a/tests/simplex_regression_test.cc +++ b/tests/simplex_regression_test.cc @@ -98,7 +98,7 @@ int main() float DIST = 2; // BPSK float fact = DIST / (sigma_noise * sigma_noise); for (int i = 0; i < CODE_LEN; ++i) - code[i] = std::min(std::max(std::nearbyint(fact * symb[i]), -128), 127); + code[i] = std::min(std::max(std::nearbyint(fact * symb[i]), -127), 127); for (int i = 0; i < CODE_LEN; ++i) noisy[i] = code[i]; diff --git a/tests/soft_bch_regression_test.cc b/tests/soft_bch_regression_test.cc index cc03d71..e765b69 100644 --- a/tests/soft_bch_regression_test.cc +++ b/tests/soft_bch_regression_test.cc @@ -107,7 +107,7 @@ int main() float DIST = 2; // BPSK float fact = DIST / (sigma_noise * sigma_noise); for (int i = 0; i < CODE_LEN; ++i) - code[i] = std::min(std::max(std::nearbyint(fact * symb[i]), -128), 127); + code[i] = std::min(std::max(std::nearbyint(fact * symb[i]), -127), 127); for (int i = 0; i < CODE_LEN; ++i) noisy[i] = code[i];