GNU Radio Manual and C++ API Reference 3.10.5.1
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 * SPDX-License-Identifier: GPL-3.0-or-later
8 *
9 */
10
11/* -----------------------------------------------------------------
12 *
13 * This class defines functions for message passing mechanism for a
14 * AWGN channel. Message passing (also known as belief propagation)
15 * is used for decoding LDPC codes. Details of how LDPC codes are
16 * decoded is available in the link below
17 * - http://www.cs.utoronto.ca/~radford/ftp/LDPC-2012-02-11/decoding.html
18 *
19 * Belief propagation decoding is a suboptimal but efficient method of
20 * decoding LDPC codes.
21 *
22 */
23
24#ifndef AWGN_BP_H
25#define AWGN_BP_H
26
27#include "alist.h"
28#include "gf2mat.h"
29#include <gnuradio/fec/api.h>
30#include <cmath>
31#include <vector>
32
34{
35public:
36 //! Default constructor
38
39 //! A constructor for given GF2Mat and sigma
40 awgn_bp(const GF2Mat X, float sgma);
41
42 //! A constructor for given alist and sigma
43 awgn_bp(alist _list, float sgma);
44
45 //! Initializes the class using given alist and sigma
46 void set_alist_sigma(alist _list, float sgma);
47
48 //! Returns the variable Q
49 std::vector<std::vector<double>> get_Q();
50
51 //! Returns the variable R
52 std::vector<std::vector<double>> get_R();
53
54 //! Returns the variable H
56
57 //! Calculates the likelihood ratios given an input vector
58 void rx_lr_calc(std::vector<float> codeword);
59
60 //! Returns the variable rx_lr
61 std::vector<double> get_rx_lr();
62
63 //! Returns the variable lr
64 std::vector<double> get_lr();
65
66 //! Initializes the sum product algorithm set-up
68
69 //! Updates the check-nodes based on messages from variable nodes
71
72 //! Updates the variable-nodes based on messages from check nodes
74
75 //! Returns the current estimate
76 std::vector<uint8_t> get_estimate();
77
78 //! Computes initial estimate based on the vector rx_word
79 void compute_init_estimate(std::vector<float> rx_word);
80
81 //! Computes the estimate based on current likelihood-ratios lr
82 void decision();
83
84 //! Returns the syndrome for the current estimate
85 std::vector<uint8_t> get_syndrome();
86
87 //! Returns the syndrome for the input codeword
88 std::vector<uint8_t> get_syndrome(const std::vector<uint8_t> codeword);
89
90 //! Checks if the current estimate is a codeword
92
93 //! Checks if the input is a codeword
94 bool is_codeword(const std::vector<uint8_t> codeword);
95
96 //! Sets the variable K
97 void set_K(int k);
98
99 //! Returns the variable K
100 int get_K();
101
102 //! Sets the variable max_iterations
104
105 //! Returns the variable max_iterations
107
108 /*!
109 * \brief Decodes the given vector rx_word by message passing.
110 *
111 * \param rx_word The received samples for decoding.
112 * \param niterations The number of message passing iterations
113 * done to decode this codeword.
114 */
115 std::vector<uint8_t> decode(std::vector<float> rx_word, int* niterations);
116
117private:
118 //! The number of check nodes in the tanner-graph
119 int M;
120
121 //! The number of variable nodes in the tanner-graph
122 int N;
123
124 //! The dimension of the code used
125 int K;
126
127 //! The maximum number of message passing iterations allowed
128 int max_iterations;
129
130 //! The parity check matrix of the LDPC code
131 GF2Mat H;
132
133 //! The standard-deviation of the AWGN channel
134 float sigma;
135
136 //! Matrix holding messages from check nodes to variable nodes
137 std::vector<std::vector<double>> R;
138
139 //! Matrix holding messages from variable nodes to check nodes
140 std::vector<std::vector<double>> Q;
141
142 //! The array of likelihood computed from the channel output
143 std::vector<double> rx_lr;
144
145 //! The array for holding likelihoods computed on BP decoding
146 std::vector<double> lr;
147
148 //! List of integer coordinates along each column with non-zero entries
149 std::vector<std::vector<int>> nlist;
150
151 //! List of integer coordinates along each row with non-zero entries
152 std::vector<std::vector<int>> mlist;
153
154 //! Weight of each column n
155 std::vector<int> num_nlist;
156
157 //! Weight of each row m
158 std::vector<int> num_mlist;
159
160 //! The array for holding estimate computed on BP decoding
161 std::vector<uint8_t> estimate;
162};
163#endif // ifndef AWGN_BP_H
Definition: gf2mat.h:18
Definition: alist.h:32
Definition: awgn_bp.h:34
std::vector< std::vector< double > > get_R()
Returns the variable R.
std::vector< double > get_lr()
Returns the variable lr.
void spa_initialize()
Initializes the sum product algorithm set-up.
std::vector< uint8_t > get_estimate()
Returns the current estimate.
void update_chks()
Updates the check-nodes based on messages from variable nodes.
bool is_codeword(const std::vector< uint8_t > codeword)
Checks if the input is a codeword.
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.
void set_K(int k)
Sets the variable K.
GF2Mat get_H()
Returns the variable H.
int get_K()
Returns the variable K.
std::vector< std::vector< double > > get_Q()
Returns the variable Q.
std::vector< uint8_t > get_syndrome()
Returns the syndrome for the current estimate.
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:37
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.
std::vector< uint8_t > get_syndrome(const std::vector< uint8_t > codeword)
Returns the syndrome for the input codeword.
std::vector< uint8_t > decode(std::vector< float > rx_word, int *niterations)
Decodes the given vector rx_word by message passing.
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:18