moved initial metric of hard decision to the top

This commit is contained in:
Ahmet Inan 2020-06-09 12:54:47 +02:00
commit 0ebdada99a

View file

@ -71,10 +71,19 @@ public:
int cw = 0; int cw = 0;
for (int i = 0; i < N; ++i) for (int i = 0; i < N; ++i)
cw |= (code[i] < 0) << i; cw |= (code[i] < 0) << i;
int word = (*this)(cw);
// hard decision // hard decision
if (0) if (0)
return (*this)(cw); return word;
int word = 0, best = 0; int best = 0;
// metric of hard decision
if (1) {
int lol = 8 * sizeof(word) - 1;
int sum = 0;
for (int i = 0; i < N; ++i)
sum += ((word << (lol-i)) >> lol) * code[i];
best = sum;
}
// flip each bit and see .. // flip each bit and see ..
if (0) { if (0) {
for (int j = 0; j < N; ++j) { for (int j = 0; j < N; ++j) {
@ -111,7 +120,7 @@ public:
worst[3] = i; worst[3] = i;
} }
} }
for (int j = 0; j < (1 << num); ++j) { for (int j = 1; j < (1 << num); ++j) {
int tmp = 0; int tmp = 0;
for (int i = 0; i < num; ++i) for (int i = 0; i < num; ++i)
tmp |= ((j>>i)&1) << worst[i]; tmp |= ((j>>i)&1) << worst[i];