/
cldpc.h
102 lines (74 loc) · 2.38 KB
/
cldpc.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/* -*- c++ -*- */
/*
* Copyright 2015 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef LDPC_H
#define LDPC_H
#include <vector>
#include "gnuradio/fec/alist.h"
#include "gnuradio/fec/gf2mat.h"
#include "gnuradio/fec/gf2vec.h"
#include <gnuradio/fec/api.h>
class FEC_API cldpc
{
public:
//! Default constructor
cldpc(){};
//! Constructs the LDPC class from given GF2mat X
cldpc(const GF2Mat X);
//! Constructs the class from the given alist _list
cldpc(const alist _list);
//! Prints the variable permute
void print_permute();
/*!
\brief Encode the given vector dataword.
dataword is of length K where K is the dimension of the code.
The function returns a vector of length N where N is the
block-length of the code.
For encoding a G matrix in the form [I P] is obtained from the
parity matrix H, by (a) Column permutations, (b) Row additions
and (c) Row permutations. Details of encoding is given in
section A.1 of the reference given below.
- "Modern Coding Theory", T Richardson and R Urbanke.
*/
std::vector<uint8_t> encode(std::vector<uint8_t> dataword);
//! Returns the dimension of the code
int dimension();
//! Returns the parity check matrix H
GF2Mat get_H();
//! Returns the matrix G used in encoding
GF2Mat get_G();
//! Returns the variable M
int get_M();
//! Returns the variable N
int get_N();
//! Returns the syndrome for a given vector "in"
std::vector<uint8_t> syndrome(const std::vector<uint8_t> in);
//! Returns true if "in" is a codeword, else false
bool is_codeword(const std::vector<uint8_t> in);
//! Set the variable _list
void set_alist(const alist _list);
//! Obtain systematic bits from "in"
std::vector<uint8_t> get_systematic_bits(std::vector<uint8_t> in);
private:
//! The parity check matrix
GF2Mat H;
//! An equivalent matrix obtained from H used for encoding
GF2Mat G;
//! Stores the column permutation in obtaining G from H
std::vector<int> permute;
//! Rank of the H matrix
int rank_H;
//! The number of check nodes in the Tanner-graph
int M;
//! The number of variable nodes in the Tanner-graph
int N;
//! The dimension of the code
size_t K;
};
#endif // ifndef LDPC_H