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