GNU Radio C++ API Reference  g90d26cb
The Free & Open Software Radio Ecosystem
alist.h
Go to the documentation of this file.
1 #include "stdint.h"
2 /* -*- c++ -*- */
3 /*
4  * Copyright 2015 Free Software Foundation, Inc.
5  *
6  * This file is part of GNU Radio
7  *
8  * SPDX-License-Identifier: GPL-3.0-or-later
9  *
10  */
11 
12 /* -----------------------------------------------------------------
13  *
14  * This class handles sparse matrices specified in alist-format.
15  * For details about alist format please visit the link below.
16  * - http://www.inference.phy.cam.ac.uk/mackay/codes/alist.html
17  *
18  * Alist class is an efficient way of representing a sparse matrix
19  * the parity check matrix H of an LDPC code for instance.
20  *
21  */
22 
23 #ifndef ALIST_H
24 #define ALIST_H
25 
26 #include <gnuradio/fec/api.h>
27 #include <cstdint>
28 #include <cstdlib>
29 #include <fstream>
30 #include <sstream>
31 #include <vector>
32 
34 {
35 public:
36  //! Default Constructor
37  alist() : data_ok(false) {}
38 
39  //! Constructor which loads alist class from an alist-file
40  alist(const char* fname);
41 
42  //! Read alist data from a file
43  void read(const char* fname);
44 
45  //! Write alist data to a file
46  void write(const char* fname) const;
47 
48  //! Returns N, the number of variable nodes
49  int get_N();
50 
51  //! Return M, the number of check nodes
52  int get_M();
53 
54  //! Return the m_list variable
55  std::vector<std::vector<int>> get_mlist();
56 
57  //! Returns the n_list variable
58  std::vector<std::vector<int>> get_nlist();
59 
60  //! Returns the num_mlist variable
61  std::vector<int> get_num_mlist();
62 
63  //! Returns the num_nlist variable
64  std::vector<int> get_num_nlist();
65 
66  //! Returns the max_num_nlist variable
68 
69  //! Returns the max_num_mlist variable
71 
72  //! Prints the nlist[i] variable
73  void print_nlist_i(int i);
74 
75  //! Prints the mlist[i] variable
76  void print_mlist_i(int i);
77 
78  //! Returns the corresponding H matrix
79  std::vector<std::vector<uint8_t>> get_matrix();
80 
81 protected:
82  //! A variable indicating if data has been read from alist-file
83  bool data_ok;
84 
85  //! Number of variable nodes
86  int N;
87 
88  //! Number of check nodes
89  int M;
90 
91  //! Maximum weight of rows
93 
94  //! Maximum weight of columns
96 
97  //! Weight of each column n
98  std::vector<int> num_nlist;
99 
100  //! Weight of each row m
101  std::vector<int> num_mlist;
102 
103  //! List of integer coordinates along each rows with non-zero entries
104  std::vector<std::vector<int>> mlist;
105 
106  //! List of integer coordinates along each column with non-zero entries
107  std::vector<std::vector<int>> nlist;
108 };
109 #endif // ifndef ALIST_H
Definition: alist.h:34
std::vector< int > num_nlist
Weight of each column n.
Definition: alist.h:98
std::vector< int > get_num_mlist()
Returns the num_mlist variable.
int get_M()
Return M, the number of check nodes.
std::vector< std::vector< int > > mlist
List of integer coordinates along each rows with non-zero entries.
Definition: alist.h:104
int N
Number of variable nodes.
Definition: alist.h:86
std::vector< std::vector< uint8_t > > get_matrix()
Returns the corresponding H matrix.
std::vector< int > num_mlist
Weight of each row m.
Definition: alist.h:101
int M
Number of check nodes.
Definition: alist.h:89
std::vector< int > get_num_nlist()
Returns the num_nlist variable.
int max_num_nlist
Maximum weight of columns.
Definition: alist.h:95
alist(const char *fname)
Constructor which loads alist class from an alist-file.
void read(const char *fname)
Read alist data from a file.
int get_N()
Returns N, the number of variable nodes.
void write(const char *fname) const
Write alist data to a file.
std::vector< std::vector< int > > nlist
List of integer coordinates along each column with non-zero entries.
Definition: alist.h:107
int max_num_mlist
Maximum weight of rows.
Definition: alist.h:92
std::vector< std::vector< int > > get_nlist()
Returns the n_list variable.
bool data_ok
A variable indicating if data has been read from alist-file.
Definition: alist.h:83
int get_max_num_mlist()
Returns the max_num_mlist variable.
void print_mlist_i(int i)
Prints the mlist[i] variable.
alist()
Default Constructor.
Definition: alist.h:37
void print_nlist_i(int i)
Prints the nlist[i] variable.
int get_max_num_nlist()
Returns the max_num_nlist variable.
std::vector< std::vector< int > > get_mlist()
Return the m_list variable.
#define FEC_API
Definition: gr-fec/include/gnuradio/fec/api.h:18