-
Notifications
You must be signed in to change notification settings - Fork 1
/
CASCL.h
77 lines (63 loc) · 1.96 KB
/
CASCL.h
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Parity-Check aided Pruning
// Encoding : x = wG ( G is Sparse Matrix(type:COO) )
// Decoding SCL (with CRC)
// author : Yusuke Oki
#include <iostream>
#include <cstdint>
#include <vector>
#include <stack>
#include <cmath>
#include "COO.h"
using namespace std;
class CA_SCL
{
public:
// Channel Setting
int _m; // log(N)
int _list_size;
int _list_max;
int _block_length; // power(2, _m)
int _info_length;
int _effective_info_length;
// CRC setting
int _crc_length;
vector<int> _crc_gen;
vector<int> crc_encode(vector<int> info);
int crc_decode(vector<int> y);
// Polar Code
double _design_ep;
COO _Gen; // Generate Mattix
vector<int> _frozen; // if i is frozen bit's index, _frozen[i] = 0
void init();
vector<int> encode(vector<int> info_bits);
vector<int> decode_scl_llr(vector<double> llr);
private:
std::vector<std::vector<double *>> _arrayPointer_LLR;
std::vector<double> _pathMetric_LLR;
stack<int> _inactivePathIndices;
vector<int> _activePath;
vector<vector<double *>> _arrayPointer_P;
vector<vector<int *>> _arrayPointer_C;
vector<int *> _arrayPointer_Info;
vector<vector<int>> _pathIndexToArrayIndex;
vector<stack<int>> _inactiveArrayIndices;
vector<vector<int>> _arrayReferenceCount;
vector<int> _channel_order;
vector<int> _bit_rev_order;
// function for SCL Decoding
void initializeDataStructures();
int assignInitialPath();
int clonePath(int l);
void killPath(int l);
double * getArrayPointer_LLR(int lam, int l);
int * getArrayPointer_C(int lam, int l);
void recursivelyCalcLLR(int lam, int phi);
void recursivelyUpdateC(int lam, int phi);
void continuePaths_FrozenBit(int phi);
void continuePaths_UnfrozenBit(int phi);
int findMostProbablePath();
void create_bit_rev_order();
void initialize_frozen_bits(); // function for init frozen bit
// function for Encoding
void initGenerateMatrix();
};