Skip to content

Commit

Permalink
metrics are kept sorted now
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmet Inan committed Mar 3, 2024
1 parent ed9521b commit bef1bdd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
11 changes: 2 additions & 9 deletions polar_list_decoder.hh
Original file line number Diff line number Diff line change
Expand Up @@ -318,19 +318,12 @@ public:
default: assert(false);
}

int perm[TYPE::SIZE];
for (int k = 0; k < TYPE::SIZE; ++k)
perm[k] = k;
std::sort(perm, perm + TYPE::SIZE, [metric](int a, int b) { return metric[a] < metric[b]; });
for (int i = 0, r = 0; rank != nullptr && i < TYPE::SIZE; ++i) {
if (i > 0 && metric[perm[i-1]] != metric[perm[i]])
if (i > 0 && metric[i-1] != metric[i])
++r;
rank[i] = r;
}
MAP acc;
for (int k = 0; k < TYPE::SIZE; ++k)
acc.v[k] = perm[k];
acc = vshuf(maps[count-1], acc);
MAP acc = maps[count-1];
for (int i = count-2; i >= 0; --i) {
message[i] = vshuf(message[i], acc);
acc = vshuf(maps[i], acc);
Expand Down
11 changes: 2 additions & 9 deletions polar_parity_aided.hh
Original file line number Diff line number Diff line change
Expand Up @@ -381,19 +381,12 @@ public:
default: assert(false);
}

int perm[TYPE::SIZE];
for (int k = 0; k < TYPE::SIZE; ++k)
perm[k] = k;
std::sort(perm, perm + TYPE::SIZE, [metric](int a, int b) { return metric[a] < metric[b]; });
for (int i = 0, r = 0; rank != nullptr && i < TYPE::SIZE; ++i) {
if (i > 0 && metric[perm[i-1]] != metric[perm[i]])
if (i > 0 && metric[i-1] != metric[i])
++r;
rank[i] = r;
}
MAP acc;
for (int k = 0; k < TYPE::SIZE; ++k)
acc.v[k] = perm[k];
acc = vshuf(maps[index-1], acc);
MAP acc = maps[index-1];
for (int i = index-2; i >= 0; --i) {
message[i] = vshuf(message[i], acc);
acc = vshuf(maps[i], acc);
Expand Down

0 comments on commit bef1bdd

Please sign in to comment.