GNU Radio C++ API Reference: awgn_bp.h Source File

| GNU Radio C++ API Reference 3.10.12.0 The Free & Open Software Radio Ecosystem |

Loading...
Searching...
No Matches
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
33 class FEC_API awgn_bp
34{
35public:
36 //! Default constructor
37 awgn_bp(){};
38
39 //! A constructor for given GF2Mat
40 awgn_bp(const GF2Mat X);
41
42 //! A constructor for given alist
43 awgn_bp(alist _list);
44
45 //! Initializes the class using given alist
46 void set_alist(alist _list);
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
55 GF2Mat get_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
67 void spa_initialize();
68
69 //! Updates the check-nodes based on messages from variable nodes
70 void update_chks();
71
72 //! Updates the variable-nodes based on messages from check nodes
73 void update_vars();
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
91 bool is_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
103 void set_max_iterations(int k);
104
105 //! Returns the variable max_iterations
106 int get_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 //! Matrix holding messages from check nodes to variable nodes
134 std::vector<std::vector<double>> R;
135
136 //! Matrix holding messages from variable nodes to check nodes
137 std::vector<std::vector<double>> Q;
138
139 //! The array of likelihood computed from the channel output
140 std::vector<double> rx_lr;
141
142 //! The array for holding likelihoods computed on BP decoding
143 std::vector<double> lr;
144
145 //! List of integer coordinates along each column with non-zero entries
146 std::vector<std::vector<int>> nlist;
147
148 //! List of integer coordinates along each row with non-zero entries
149 std::vector<std::vector<int>> mlist;
150
151 //! Weight of each column n
152 std::vector<int> num_nlist;
153
154 //! Weight of each row m
155 std::vector<int> num_mlist;
156
157 //! The array for holding estimate computed on BP decoding
158 std::vector<uint8_t> estimate;
159};
160#endif // ifndef AWGN_BP_H
alist.h
GF2Mat
Definition gf2mat.h:18
alist
Definition alist.h:33
awgn_bp::get_R
std::vector< std::vector< double > > get_R()
Returns the variable R.
awgn_bp::set_alist
void set_alist(alist _list)
Initializes the class using given alist.
awgn_bp::get_lr
std::vector< double > get_lr()
Returns the variable lr.
awgn_bp::spa_initialize
void spa_initialize()
Initializes the sum product algorithm set-up.
awgn_bp::get_estimate
std::vector< uint8_t > get_estimate()
Returns the current estimate.
awgn_bp::update_chks
void update_chks()
Updates the check-nodes based on messages from variable nodes.
awgn_bp::is_codeword
bool is_codeword(const std::vector< uint8_t > codeword)
Checks if the input is a codeword.
awgn_bp::decision
void decision()
Computes the estimate based on current likelihood-ratios lr.
awgn_bp::is_codeword
bool is_codeword()
Checks if the current estimate is a codeword.
awgn_bp::rx_lr_calc
void rx_lr_calc(std::vector< float > codeword)
Calculates the likelihood ratios given an input vector.
awgn_bp::set_K
void set_K(int k)
Sets the variable K.
awgn_bp::get_H
GF2Mat get_H()
Returns the variable H.
awgn_bp::get_K
int get_K()
Returns the variable K.
awgn_bp::awgn_bp
awgn_bp(alist _list)
A constructor for given alist.
awgn_bp::get_Q
std::vector< std::vector< double > > get_Q()
Returns the variable Q.
awgn_bp::get_syndrome
std::vector< uint8_t > get_syndrome()
Returns the syndrome for the current estimate.
awgn_bp::update_vars
void update_vars()
Updates the variable-nodes based on messages from check nodes.
awgn_bp::set_max_iterations
void set_max_iterations(int k)
Sets the variable max_iterations.
awgn_bp::awgn_bp
awgn_bp()
Default constructor.
Definition awgn_bp.h:37
awgn_bp::get_max_iterations
int get_max_iterations()
Returns the variable max_iterations.
awgn_bp::get_rx_lr
std::vector< double > get_rx_lr()
Returns the variable rx_lr.
awgn_bp::awgn_bp
awgn_bp(const GF2Mat X)
A constructor for given GF2Mat.
awgn_bp::get_syndrome
std::vector< uint8_t > get_syndrome(const std::vector< uint8_t > codeword)
Returns the syndrome for the input codeword.
awgn_bp::decode
std::vector< uint8_t > decode(std::vector< float > rx_word, int *niterations)
Decodes the given vector rx_word by message passing.
awgn_bp::compute_init_estimate
void compute_init_estimate(std::vector< float > rx_word)
Computes initial estimate based on the vector rx_word.
gf2mat.h
api.h
FEC_API
#define FEC_API
Definition gr-fec/include/gnuradio/fec/api.h:18