GNU Radio Manual and C++ API Reference  3.7.9.2
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 <iostream>
38 #include <fstream>
39 #include <sstream>
40 #include <vector>
41 #include <stdlib.h>
42 #include <gnuradio/fec/api.h>
43 
45 {
46  public:
47 
48  //! Default Constructor
49  alist() : data_ok(false) {}
50 
51  //! Constructor which loads alist class from an alist-file
52  alist(const char * fname);
53 
54  //! Read alist data from a file
55  void read(const char * fname);
56 
57  //! Write alist data to a file
58  void write(const char * fname) const;
59 
60  //! Retuns N, the number of variable nodes
61  int get_N();
62 
63  //! Return M, the number of check nodes
64  int get_M();
65 
66  //! Return the m_list variable
67  std::vector< std::vector<int> > get_mlist();
68 
69  //! Returns the n_list variable
70  std::vector< std::vector<int> > get_nlist();
71 
72  //! Returns the num_mlist variable
73  std::vector<int> get_num_mlist();
74 
75  //! Returns the num_nlist variable
76  std::vector<int> get_num_nlist();
77 
78  //! Returns the max_num_nlist variable
79  int get_max_num_nlist();
80 
81  //! Returns the max_num_mlist variable
82  int get_max_num_mlist();
83 
84  //! Prints the nlist[i] variable
85  void print_nlist_i(int i);
86 
87  //! Prints the mlist[i] variable
88  void print_mlist_i(int i);
89 
90  //! Returns the corresponding H matrix
91  std::vector<std::vector<char> > get_matrix();
92 
93  protected:
94  //! A variable indicating if data has been read from alist-file
95  bool data_ok;
96 
97  //! Number of variable nodes
98  int N;
99 
100  //! Number of check nodes
101  int M;
102 
103  //! Maximum weight of rows
105 
106  //! Maximum weight of columns
108 
109  //! Weight of each column n
110  std::vector<int> num_nlist;
111 
112  //! Weight of each row m
113  std::vector<int> num_mlist;
114 
115  //! List of integer coordinates along each rows with non-zero entries
116  std::vector< std::vector<int> > mlist;
117 
118  //! List of integer coordinates along each column with non-zero entries
119  std::vector< std::vector<int> > nlist;
120 };
121 #endif // ifndef ALIST_H
std::vector< int > num_nlist
Weight of each column n.
Definition: alist.h:110
PMT_API pmt_t read(std::istream &port)
int N
Number of variable nodes.
Definition: alist.h:98
Definition: alist.h:44
std::vector< int > num_mlist
Weight of each row m.
Definition: alist.h:113
std::vector< std::vector< int > > mlist
List of integer coordinates along each rows with non-zero entries.
Definition: alist.h:116
int max_num_mlist
Maximum weight of rows.
Definition: alist.h:104
std::vector< std::vector< int > > nlist
List of integer coordinates along each column with non-zero entries.
Definition: alist.h:119
alist()
Default Constructor.
Definition: alist.h:49
int max_num_nlist
Maximum weight of columns.
Definition: alist.h:107
int M
Number of check nodes.
Definition: alist.h:101
#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:95