Loading...
Searching...
No Matches
cldpc.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
*
*/
#ifndef LDPC_H
#define LDPC_H
#include <vector>
#include "gnuradio/fec/alist.h"
#include "gnuradio/fec/gf2mat.h"
#include "gnuradio/fec/gf2vec.h"
#include <gnuradio/fec/api.h>
class FEC_API cldpc
{
public:
//! Default constructor
cldpc(){};
//! Constructs the LDPC class from given GF2mat X
cldpc(const GF2Mat X);
//! Constructs the class from the given alist _list
cldpc(const alist _list);
//! Prints the variable permute
void print_permute();
/*!
\brief Encode the given vector dataword.
dataword is of length K where K is the dimension of the code.
The function returns a vector of length N where N is the
block-length of the code.
For encoding a G matrix in the form [I P] is obtained from the
parity matrix H, by (a) Column permutations, (b) Row additions
and (c) Row permutations. Details of encoding is given in
section A.1 of the reference given below.
- "Modern Coding Theory", T Richardson and R Urbanke.
*/
std::vector<uint8_t> encode(std::vector<uint8_t> dataword);
//! Returns the dimension of the code
int dimension();
//! Returns the parity check matrix H
GF2Mat get_H();
//! Returns the matrix G used in encoding
GF2Mat get_G();
//! Returns the variable M
int get_M();
//! Returns the variable N
int get_N();
//! Returns the syndrome for a given vector "in"
std::vector<uint8_t> syndrome(const std::vector<uint8_t> in);
//! Returns true if "in" is a codeword, else false
bool is_codeword(const std::vector<uint8_t> in);
//! Set the variable _list
void set_alist(const alist _list);
//! Obtain systematic bits from "in"
std::vector<uint8_t> get_systematic_bits(std::vector<uint8_t> in);
private:
//! The parity check matrix
GF2Mat H;
//! An equivalent matrix obtained from H used for encoding
GF2Mat G;
//! Stores the column permutation in obtaining G from H
std::vector<int> permute;
//! Rank of the H matrix
int rank_H;
//! The number of check nodes in the Tanner-graph
int M;
//! The number of variable nodes in the Tanner-graph
int N;
//! The dimension of the code
size_t K;
};
#endif // ifndef LDPC_H
alist.h
GF2Mat
Definition gf2mat.h:18
alist
Definition alist.h:33
cldpc::cldpc
cldpc(const GF2Mat X)
Constructs the LDPC class from given GF2mat X.
cldpc::get_systematic_bits
std::vector< uint8_t > get_systematic_bits(std::vector< uint8_t > in)
Obtain systematic bits from "in".
cldpc::is_codeword
bool is_codeword(const std::vector< uint8_t > in)
Returns true if "in" is a codeword, else false.
cldpc::set_alist
void set_alist(const alist _list)
Set the variable _list.
cldpc::cldpc
cldpc()
Default constructor.
Definition cldpc.h:26
cldpc::get_G
GF2Mat get_G()
Returns the matrix G used in encoding.
cldpc::encode
std::vector< uint8_t > encode(std::vector< uint8_t > dataword)
Encode the given vector dataword.
cldpc::cldpc
cldpc(const alist _list)
Constructs the class from the given alist _list.
cldpc::syndrome
std::vector< uint8_t > syndrome(const std::vector< uint8_t > in)
Returns the syndrome for a given vector "in".
cldpc::get_M
int get_M()
Returns the variable M.
cldpc::get_H
GF2Mat get_H()
Returns the parity check matrix H.
cldpc::print_permute
void print_permute()
Prints the variable permute.
cldpc::dimension
int dimension()
Returns the dimension of the code.
cldpc::get_N
int get_N()
Returns the variable N.
gf2mat.h
gf2vec.h
api.h
FEC_API
#define FEC_API
Definition gr-fec/include/gnuradio/fec/api.h:18