-
Notifications
You must be signed in to change notification settings - Fork 1
/
gldpc.h
83 lines (69 loc) · 1.91 KB
/
gldpc.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
78
79
80
81
82
83
/*
* File: GLDPC.h
* Author: masoud
*
* Created on February 13, 2012, 7:42 PM
*/
#ifndef GLDPC_H
#define GLDPC_H
#include <vector>
#include <m4ri/m4ri.h>
#include "graph.h"
#include "channel.h"
//this class should also work for none-linear codes
class ComponentCode{
public:
ComponentCode(unsigned int,unsigned int);
~ComponentCode();
unsigned int k,n;
double rate;
unsigned int size;//size of the code
void* words;
LLRType *LLR;
//virtual bool isImprovable();
//virtual improve();
inline bool istrivial(){return n==k;}
inline unsigned int length(){return n;}
//virtual void BPUpdate(std::vector<LLRType>& LLR)=0;
virtual void BPUpdate(LLRType *);
//virtual void* checkMat();
};
class RandomLinearCode : public ComponentCode{
private:
mzd_t *G,*H;
public:
RandomLinearCode(unsigned int n,unsigned int k);
~RandomLinearCode();
void generate();
void enumerateCodewords();
//void BPUpdate(LLRType*);
void* checkMat(){return H;}
void print();
};
class RateDistribution{
public:
RateDistribution();
std::vector<unsigned int> discreteharmonic(double maxvalue,double scale,int N);
};
class GLDPC {
public:
unsigned int d,D,nVars,nFactors;
BipartiteGraph *graph;
std::vector<unsigned int> coDims;
std::vector<unsigned int> coDimCount;
std::vector< std::vector<unsigned long> > VarIndices;
unsigned int length(){ return nVars;}
double designrate();
std::vector<ComponentCode*> factors;
LLRType* LLRs;
GLDPC(int N,int D=4, int d=2);
void InstantiateGraph(RateDistribution rd, double capacity);
GLDPC(const GLDPC& orig);
void SumProductIteration();
void channelLLR(const std::vector<LLRType>&);
void bp_decode(const std::vector<LLRType>& llrin,std::vector<LLRType>& llrout, unsigned int niter);
void print();
virtual ~GLDPC();
private:
};
#endif /* GLDPC_H */