-
Notifications
You must be signed in to change notification settings - Fork 21
/
freezer.cc
39 lines (34 loc) · 1.06 KB
/
freezer.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
Table generator for frozen bits
Copyright 2021 Ahmet Inan <[email protected]>
*/
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <functional>
#include "polar_freezer.hh"
template <int M>
void code(int N, int K)
{
long double erasure_probability = (long double)(N - K) / N;
double design_SNR = 10 * std::log10(-std::log(erasure_probability));
std::cerr << "design SNR: " << design_SNR << std::endl;
auto freeze = new CODE::PolarCodeConst0<M>;
double better_SNR = design_SNR + 1.59175;
std::cerr << "better SNR: " << better_SNR << std::endl;
long double better_probability = std::exp(-pow(10.0, better_SNR / 10));
auto frozen = new uint32_t[1<<(M-5)];
(*freeze)(frozen, M, K+(1<<M)-N, better_probability);
delete freeze;
std::cout << "static const uint32_t frozen_" << std::dec << N << "_" << K << "[" << (1<<(M-5)) << "] = { " << std::hex;
for (int i = 0; i < 1<<(M-5); ++i)
std::cout << "0x" << frozen[i] << ", ";
std::cout << "};" << std::endl;
}
int main()
{
code<16>(64512, 43040+32);
code<16>(64800, 43040+32);
return 0;
}