GNU Radio Manual and C++ API Reference  3.10.9.1
The Free & Open Software Radio Ecosystem
ldpc_H_matrix.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2015 Free Software Foundation, Inc.
4  *
5  * SPDX-License-Identifier: GPL-3.0-or-later
6  *
7  */
8 
9 #ifndef INCLUDED_ldpc_H_matrix_H
10 #define INCLUDED_ldpc_H_matrix_H
11 
12 #include <gnuradio/fec/api.h>
13 #include <gnuradio/fec/fec_mtrx.h>
14 #include <memory>
15 #include <string>
16 
17 namespace gr {
18 namespace fec {
19 namespace code {
20 /*!
21  * \brief Parity check matrix in Richardson/Urbanke format
22  * \ingroup error_coding_blk
23  *
24  * \details
25  * This class stores a matrix for use with the
26  * ldpc_encoder class. It must be of the specific format
27  * described by Richardson and Urbanke in Appendix A of their
28  * book: Modern Coding Theory (ISBN 978-0-521-85229-6). The
29  * form is:
30  * \f[\left[\begin{array}{ccc} T & A & B\\ E & C & D \end{array}\right]\f]
31  * This class can be used with the ldpc_bit_flip_decoder.
32  *
33  * To convert a parity check matrix to this format, use the
34  * python functions in:
35  * /lib/python2.7/dist-packages/gnuradio/fec/LDPC/Generate_LDPC_matrix.py.
36  */
37 class FEC_API ldpc_H_matrix : virtual public fec_mtrx,
38  public std::enable_shared_from_this<ldpc_H_matrix>
39 {
40 public:
41  typedef std::shared_ptr<ldpc_H_matrix> sptr;
42 
43  /*!
44  * \brief Constructor given alist file and gap
45  * \param filename Name of an alist file to use. The alist
46  * format is described at:
47  * http://www.inference.phy.cam.ac.uk/mackay/codes/alist.html
48  * \param gap A property of the matrix being used. For alist
49  * files distributed with GNU Radio, this value
50  * is specified in the alist filename. The gap is
51  * found during the matrix preprocessing
52  * algorithm. It is equal to the number of rows in
53  * submatrices E, C and D.
54  */
55  static sptr make(const std::string filename, unsigned int gap);
56 
57  //! Encode \p inbuffer with LDPC H matrix into \p outbuffer.
58  void encode(unsigned char* outbuffer,
59  const unsigned char* inbuffer) const override = 0;
60 
61  //! Decode \p inbuffer with LDPC H matrix into \p outbuffer.
62  void decode(unsigned char* outbuffer,
63  const float* inbuffer,
64  unsigned int frame_size,
65  unsigned int max_iterations) const override = 0;
66 
67  //! Get the codeword length n
68  // Handled in fec_mtrx parent class.
69  unsigned int n() const override = 0;
70 
71  //! Get the information word length k
72  // Handled in fec_mtrx parent class.
73  unsigned int k() const override = 0;
74 
75  /*!
76  * \brief A pointer to make SWIG work
77  *
78  * \details
79  * SWIG doesn't understand the parent class pointer to this
80  * child class for the make function of the
81  * ldpc_bit_flip_decoder; it's expecting a pointer to the base
82  * class. This returns a shared_from_this instance.
83  */
84  virtual gr::fec::code::fec_mtrx_sptr get_base_sptr() = 0;
85 };
86 
87 } // namespace code
88 } // namespace fec
89 } // namespace gr
90 
91 #endif /* INCLUDED_ldpc_H_matrix_H */
Base class for FEC matrix objects.
Definition: fec_mtrx.h:124
Parity check matrix in Richardson/Urbanke format.
Definition: ldpc_H_matrix.h:39
std::shared_ptr< ldpc_H_matrix > sptr
Definition: ldpc_H_matrix.h:41
static sptr make(const std::string filename, unsigned int gap)
Constructor given alist file and gap.
void encode(unsigned char *outbuffer, const unsigned char *inbuffer) const override=0
Encode inbuffer with LDPC H matrix into outbuffer.
unsigned int k() const override=0
Get the information word length k.
void decode(unsigned char *outbuffer, const float *inbuffer, unsigned int frame_size, unsigned int max_iterations) const override=0
Decode inbuffer with LDPC H matrix into outbuffer.
unsigned int n() const override=0
Get the codeword length n.
#define FEC_API
Definition: gr-fec/include/gnuradio/fec/api.h:18
GNU Radio logging wrapper.
Definition: basic_block.h:29