GNU Radio Manual and C++ API Reference 3.7.14.0
The Free & Open Software Radio Ecosystem
awgn_bp.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2015 Free Software Foundation, Inc.
4 *
5 * This file is part of GNU Radio
6 *
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
10 * any later version.
11 *
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
21 */
22
23/* -----------------------------------------------------------------
24 *
25 * This class defines functions for message passing mechanism for a
26 * AWGN channel. Message passing (also known as belief propagation)
27 * is used for decoding LDPC codes. Details of how LDPC codes are
28 * decoded is available in the link below
29 * - http://www.cs.utoronto.ca/~radford/ftp/LDPC-2012-02-11/decoding.html
30 *
31 * Belief propagation decoding is a suboptimal but efficient method of
32 * decoding LDPC codes.
33 *
34 */
35
36#ifndef AWGN_BP_H
37#define AWGN_BP_H
38
39#include "alist.h"
40#include "gf2mat.h"
41#include <gnuradio/fec/api.h>
42#include <cmath>
43#include <iostream>
44#include <vector>
45
47{
48public:
49 //! Default constructor
51
52 //! A constructor for given GF2Mat and sigma
53 awgn_bp(const GF2Mat X, float sgma);
54
55 //! A constructor for given alist and sigma
56 awgn_bp(alist _list, float sgma);
57
58 //! Initializes the class using given alist and sigma
59 void set_alist_sigma(alist _list, float sgma);
60
61 //! Returns the variable Q
62 std::vector<std::vector<double> > get_Q();
63
64 //! Returns the variable R
65 std::vector<std::vector<double> > get_R();
66
67 //! Returns the variable H
69
70 //! Calculates the likelihood ratios given an input vector
71 void rx_lr_calc(std::vector<float> codeword);
72
73 //! Returns the variable rx_lr
74 std::vector<double> get_rx_lr();
75
76 //! Returns the variable lr
77 std::vector<double> get_lr();
78
79 //! Initializes the sum product algorithm set-up
81
82 //! Updates the check-nodes based on messages from variable nodes
84
85 //! Updates the variable-nodes based on messages from check nodes
87
88 //! Returns the current estimate
89 std::vector<char> get_estimate();
90
91 //! Computes initial estimate based on the vector rx_word
92 void compute_init_estimate(std::vector<float> rx_word);
93
94 //! Computes the estimate based on current likelihood-ratios lr
95 void decision();
96
97 //! Returns the syndrome for the current estimate
98 std::vector<char> get_syndrome();
99
100 //! Returns the syndrome for the input codeword
101 std::vector<char> get_syndrome(const std::vector<char> codeword);
102
103 //! Checks if the current estimate is a codeword
105
106 //! Checks if the input is a codeword
107 bool is_codeword(const std::vector<char> codeword);
108
109 //! Sets the variable K
110 void set_K(int k);
111
112 //! Returns the variable K
113 int get_K();
114
115 //! Sets the variable max_iterations
117
118 //! Returns the variable max_iterations
120
121 /*!
122 * \brief Decodes the given vector rx_word by message passing.
123 *
124 * \param rx_word The received samples for decoding.
125 * \param niterations The number of message passing iterations
126 * done to decode this codeword.
127 */
128 std::vector<char> decode(std::vector<float> rx_word, int* niterations);
129
130private:
131 //! The number of check nodes in the tanner-graph
132 int M;
133
134 //! The number of variable nodes in the tanner-graph
135 int N;
136
137 //! The dimension of the code used
138 int K;
139
140 //! The maximum number of message passing iterations allowed
141 int max_iterations;
142
143 //! The parity check matrix of the LDPC code
144 GF2Mat H;
145
146 //! The standard-deviation of the AWGN channel
147 float sigma;
148
149 //! Matrix holding messages from check nodes to variable nodes
150 std::vector<std::vector<double> > R;
151
152 //! Matrix holding messages from variable nodes to check nodes
153 std::vector<std::vector<double> > Q;
154
155 //! The array of likelihood computed from the channel output
156 std::vector<double> rx_lr;
157
158 //! The array for holding likelihoods computed on BP decoding
159 std::vector<double> lr;
160
161 //! List of integer coordinates along each column with non-zero entries
162 std::vector<std::vector<int> > nlist;
163
164 //! List of integer coordinates along each row with non-zero entries
165 std::vector<std::vector<int> > mlist;
166
167 //! Weight of each column n
168 std::vector<int> num_nlist;
169
170 //! Weight of each row m
171 std::vector<int> num_mlist;
172
173 //! The array for holding estimate computed on BP decoding
174 std::vector<char> estimate;
175};
176#endif // ifndef AWGN_BP_H
Definition: gf2mat.h:30
Definition: alist.h:45
Definition: awgn_bp.h:47
std::vector< char > get_estimate()
Returns the current estimate.
std::vector< std::vector< double > > get_R()
Returns the variable R.
std::vector< char > decode(std::vector< float > rx_word, int *niterations)
Decodes the given vector rx_word by message passing.
std::vector< double > get_lr()
Returns the variable lr.
void spa_initialize()
Initializes the sum product algorithm set-up.
void update_chks()
Updates the check-nodes based on messages from variable nodes.
void decision()
Computes the estimate based on current likelihood-ratios lr.
bool is_codeword()
Checks if the current estimate is a codeword.
void rx_lr_calc(std::vector< float > codeword)
Calculates the likelihood ratios given an input vector.
std::vector< char > get_syndrome()
Returns the syndrome for the current estimate.
void set_K(int k)
Sets the variable K.
GF2Mat get_H()
Returns the variable H.
std::vector< char > get_syndrome(const std::vector< char > codeword)
Returns the syndrome for the input codeword.
int get_K()
Returns the variable K.
bool is_codeword(const std::vector< char > codeword)
Checks if the input is a codeword.
std::vector< std::vector< double > > get_Q()
Returns the variable Q.
void update_vars()
Updates the variable-nodes based on messages from check nodes.
void set_alist_sigma(alist _list, float sgma)
Initializes the class using given alist and sigma.
void set_max_iterations(int k)
Sets the variable max_iterations.
awgn_bp()
Default constructor.
Definition: awgn_bp.h:50
awgn_bp(const GF2Mat X, float sgma)
A constructor for given GF2Mat and sigma.
int get_max_iterations()
Returns the variable max_iterations.
std::vector< double > get_rx_lr()
Returns the variable rx_lr.
void compute_init_estimate(std::vector< float > rx_word)
Computes initial estimate based on the vector rx_word.
awgn_bp(alist _list, float sgma)
A constructor for given alist and sigma.
#define FEC_API
Definition: gr-fec/include/gnuradio/fec/api.h:30