Loading...
Searching...
No Matches
alist.h
Go to the documentation of this file.
/* -*- c++ -*- */
/*
* Copyright 2015 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
*/
/* -----------------------------------------------------------------
*
* This class handles sparse matrices specified in alist-format.
* For details about alist format please visit the link below.
* - http://www.inference.phy.cam.ac.uk/mackay/codes/alist.html
*
* Alist class is an efficient way of representing a sparse matrix
* the parity check matrix H of an LDPC code for instance.
*
*/
#ifndef ALIST_H
#define ALIST_H
#include <gnuradio/fec/api.h>
#include <cstdint>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include <vector>
class FEC_API alist
{
public:
//! Default Constructor
alist() : data_ok(false) {}
//! Constructor which loads alist class from an alist-file
alist(const char* fname);
//! Read alist data from a file
void read(const char* fname);
//! Write alist data to a file
void write(const char* fname) const;
//! Returns N, the number of variable nodes
int get_N();
//! Return M, the number of check nodes
int get_M();
//! Return the m_list variable
std::vector<std::vector<int>> get_mlist();
//! Returns the n_list variable
std::vector<std::vector<int>> get_nlist();
//! Returns the num_mlist variable
std::vector<int> get_num_mlist();
//! Returns the num_nlist variable
std::vector<int> get_num_nlist();
//! Returns the max_num_nlist variable
int get_max_num_nlist();
//! Returns the max_num_mlist variable
int get_max_num_mlist();
//! Prints the nlist[i] variable
void print_nlist_i(int i);
//! Prints the mlist[i] variable
void print_mlist_i(int i);
//! Returns the corresponding H matrix
std::vector<std::vector<uint8_t>> get_matrix();
protected:
//! A variable indicating if data has been read from alist-file
bool data_ok;
//! Number of variable nodes
int N;
//! Number of check nodes
int M;
//! Maximum weight of rows
int max_num_mlist;
//! Maximum weight of columns
int max_num_nlist;
//! Weight of each column n
std::vector<int> num_nlist;
//! Weight of each row m
std::vector<int> num_mlist;
//! List of integer coordinates along each rows with non-zero entries
std::vector<std::vector<int>> mlist;
//! List of integer coordinates along each column with non-zero entries
std::vector<std::vector<int>> nlist;
};
#endif // ifndef ALIST_H
alist::get_num_nlist
std::vector< int > get_num_nlist()
Returns the num_nlist variable.
alist::num_nlist
std::vector< int > num_nlist
Weight of each column n.
Definition alist.h:97
alist::get_M
int get_M()
Return M, the number of check nodes.
alist::mlist
std::vector< std::vector< int > > mlist
List of integer coordinates along each rows with non-zero entries.
Definition alist.h:103
alist::get_matrix
std::vector< std::vector< uint8_t > > get_matrix()
Returns the corresponding H matrix.
alist::N
int N
Number of variable nodes.
Definition alist.h:85
alist::num_mlist
std::vector< int > num_mlist
Weight of each row m.
Definition alist.h:100
alist::M
int M
Number of check nodes.
Definition alist.h:88
alist::max_num_nlist
int max_num_nlist
Maximum weight of columns.
Definition alist.h:94
alist::get_nlist
std::vector< std::vector< int > > get_nlist()
Returns the n_list variable.
alist::alist
alist(const char *fname)
Constructor which loads alist class from an alist-file.
alist::read
void read(const char *fname)
Read alist data from a file.
alist::get_mlist
std::vector< std::vector< int > > get_mlist()
Return the m_list variable.
alist::get_N
int get_N()
Returns N, the number of variable nodes.
alist::write
void write(const char *fname) const
Write alist data to a file.
alist::nlist
std::vector< std::vector< int > > nlist
List of integer coordinates along each column with non-zero entries.
Definition alist.h:106
alist::max_num_mlist
int max_num_mlist
Maximum weight of rows.
Definition alist.h:91
alist::data_ok
bool data_ok
A variable indicating if data has been read from alist-file.
Definition alist.h:82
alist::get_max_num_mlist
int get_max_num_mlist()
Returns the max_num_mlist variable.
alist::print_mlist_i
void print_mlist_i(int i)
Prints the mlist[i] variable.
alist::alist
alist()
Default Constructor.
Definition alist.h:36
alist::print_nlist_i
void print_nlist_i(int i)
Prints the nlist[i] variable.
alist::get_max_num_nlist
int get_max_num_nlist()
Returns the max_num_nlist variable.
alist::get_num_mlist
std::vector< int > get_num_mlist()
Returns the num_mlist variable.
api.h
FEC_API
#define FEC_API
Definition gr-fec/include/gnuradio/fec/api.h:18