GNU Radio C++ API Reference 3.10.12.0
The Free & Open Software Radio Ecosystem
 
Loading...
Searching...
No Matches
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 <cstdint>
27#include <cstdlib>
28#include <fstream>
29#include <sstream>
30#include <vector>
31
33{
34public:
35 //! Default Constructor
36 alist() : data_ok(false) {}
37
38 //! Constructor which loads alist class from an alist-file
39 alist(const char* fname);
40
41 //! Read alist data from a file
42 void read(const char* fname);
43
44 //! Write alist data to a file
45 void write(const char* fname) const;
46
47 //! Returns N, the number of variable nodes
48 int get_N();
49
50 //! Return M, the number of check nodes
51 int get_M();
52
53 //! Return the m_list variable
54 std::vector<std::vector<int>> get_mlist();
55
56 //! Returns the n_list variable
57 std::vector<std::vector<int>> get_nlist();
58
59 //! Returns the num_mlist variable
60 std::vector<int> get_num_mlist();
61
62 //! Returns the num_nlist variable
63 std::vector<int> get_num_nlist();
64
65 //! Returns the max_num_nlist variable
67
68 //! Returns the max_num_mlist variable
70
71 //! Prints the nlist[i] variable
72 void print_nlist_i(int i);
73
74 //! Prints the mlist[i] variable
75 void print_mlist_i(int i);
76
77 //! Returns the corresponding H matrix
78 std::vector<std::vector<uint8_t>> get_matrix();
79
80protected:
81 //! A variable indicating if data has been read from alist-file
82 bool data_ok;
83
84 //! Number of variable nodes
85 int N;
86
87 //! Number of check nodes
88 int M;
89
90 //! Maximum weight of rows
92
93 //! Maximum weight of columns
95
96 //! Weight of each column n
97 std::vector<int> num_nlist;
98
99 //! Weight of each row m
100 std::vector<int> num_mlist;
101
102 //! List of integer coordinates along each rows with non-zero entries
103 std::vector<std::vector<int>> mlist;
104
105 //! List of integer coordinates along each column with non-zero entries
106 std::vector<std::vector<int>> nlist;
107};
108#endif // ifndef ALIST_H
Definition alist.h:33
std::vector< int > get_num_nlist()
Returns the num_nlist variable.
std::vector< int > num_nlist
Weight of each column n.
Definition alist.h:97
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:103
std::vector< std::vector< uint8_t > > get_matrix()
Returns the corresponding H matrix.
int N
Number of variable nodes.
Definition alist.h:85
std::vector< int > num_mlist
Weight of each row m.
Definition alist.h:100
int M
Number of check nodes.
Definition alist.h:88
int max_num_nlist
Maximum weight of columns.
Definition alist.h:94
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:106
int max_num_mlist
Maximum weight of rows.
Definition alist.h:91
bool data_ok
A variable indicating if data has been read from alist-file.
Definition alist.h:82
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:36
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