GNU Radio Manual and C++ API Reference  3.8.1.0
The Free & Open Software Radio Ecosystem
alist.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 handles sparse matrices specified in alist-format.
26  * For details about alist format please visit the link below.
27  * - http://www.inference.phy.cam.ac.uk/mackay/codes/alist.html
28  *
29  * Alist class is an efficient way of representing a sparse matrix
30  * the parity check matrix H of an LDPC code for instance.
31  *
32  */
33 
34 #ifndef ALIST_H
35 #define ALIST_H
36 
37 #include <gnuradio/fec/api.h>
38 #include <stdlib.h>
39 #include <fstream>
40 #include <iostream>
41 #include <sstream>
42 #include <vector>
43 
45 {
46 public:
47  //! Default Constructor
48  alist() : data_ok(false) {}
49 
50  //! Constructor which loads alist class from an alist-file
51  alist(const char* fname);
52 
53  //! Read alist data from a file
54  void read(const char* fname);
55 
56  //! Write alist data to a file
57  void write(const char* fname) const;
58 
59  //! Returns N, the number of variable nodes
60  int get_N();
61 
62  //! Return M, the number of check nodes
63  int get_M();
64 
65  //! Return the m_list variable
66  std::vector<std::vector<int>> get_mlist();
67 
68  //! Returns the n_list variable
69  std::vector<std::vector<int>> get_nlist();
70 
71  //! Returns the num_mlist variable
72  std::vector<int> get_num_mlist();
73 
74  //! Returns the num_nlist variable
75  std::vector<int> get_num_nlist();
76 
77  //! Returns the max_num_nlist variable
78  int get_max_num_nlist();
79 
80  //! Returns the max_num_mlist variable
81  int get_max_num_mlist();
82 
83  //! Prints the nlist[i] variable
84  void print_nlist_i(int i);
85 
86  //! Prints the mlist[i] variable
87  void print_mlist_i(int i);
88 
89  //! Returns the corresponding H matrix
90  std::vector<std::vector<char>> get_matrix();
91 
92 protected:
93  //! A variable indicating if data has been read from alist-file
94  bool data_ok;
95 
96  //! Number of variable nodes
97  int N;
98 
99  //! Number of check nodes
100  int M;
101 
102  //! Maximum weight of rows
104 
105  //! Maximum weight of columns
107 
108  //! Weight of each column n
109  std::vector<int> num_nlist;
110 
111  //! Weight of each row m
112  std::vector<int> num_mlist;
113 
114  //! List of integer coordinates along each rows with non-zero entries
115  std::vector<std::vector<int>> mlist;
116 
117  //! List of integer coordinates along each column with non-zero entries
118  std::vector<std::vector<int>> nlist;
119 };
120 #endif // ifndef ALIST_H
std::vector< int > num_nlist
Weight of each column n.
Definition: alist.h:109
PMT_API pmt_t read(std::istream &port)
int N
Number of variable nodes.
Definition: alist.h:97
Definition: alist.h:44
std::vector< int > num_mlist
Weight of each row m.
Definition: alist.h:112
int max_num_mlist
Maximum weight of rows.
Definition: alist.h:103
alist()
Default Constructor.
Definition: alist.h:48
int max_num_nlist
Maximum weight of columns.
Definition: alist.h:106
int M
Number of check nodes.
Definition: alist.h:100
#define FEC_API
Definition: gr-fec/include/gnuradio/fec/api.h:30
PMT_API void write(pmt_t obj, std::ostream &port)
bool data_ok
A variable indicating if data has been read from alist-file.
Definition: alist.h:94
std::vector< std::vector< int > > mlist
List of integer coordinates along each rows with non-zero entries.
Definition: alist.h:115
std::vector< std::vector< int > > nlist
List of integer coordinates along each column with non-zero entries.
Definition: alist.h:118