GNU Radio Manual and C++ API Reference  3.7.9.2
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ldpc_G_matrix.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2015 Free Software Foundation, Inc.
4  *
5  * This is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published
7  * by the Free Software Foundation; either version 3, or (at your
8  * option) any later version.
9  *
10  * This software is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this software; see the file COPYING. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef INCLUDED_ldpc_G_matrix_H
22 #define INCLUDED_ldpc_G_matrix_H
23 
24 #include <gnuradio/fec/api.h>
25 #include <gnuradio/fec/fec_mtrx.h>
26 #include <boost/shared_ptr.hpp>
27 #include <boost/enable_shared_from_this.hpp>
28 
29 namespace gr {
30  namespace fec {
31  namespace code {
32 
33  /*!
34  * \brief Class for storing H or G matrix
35  * \ingroup error_coding_blk
36  *
37  * \details
38  * This class stores a matrix variable, specifically
39  * either a:
40  *
41  * 1) Generator matrix, G, in the standard format G = [I P],
42  * where I is an identity matrix and P is the parity
43  * submatrix.
44  *
45  * or
46  *
47  * 2) Parity matrix, H, in the standard format H = [P' I],
48  * where P' is the transpose of the parity submatrix and I
49  * is an identity matrix.
50  *
51  * This variable can used by the ldpc_gen_mtrx_encoder and
52  * ldpc_bit_flip_decoder classes.
53  */
54  class FEC_API ldpc_G_matrix : virtual public fec_mtrx,
55  public boost::enable_shared_from_this<ldpc_G_matrix>
56  {
57  public:
58  typedef boost::shared_ptr<ldpc_G_matrix> sptr;
59 
60  /*!
61  * \brief Constructor given alist file
62  * \details
63  * 1. Reads in the matrix from an alist file
64  * 2. Determines if the matrix format is G=[I P] or H=[P' I]
65  * 3. Solves for G transpose (will be used during encoding)
66  *
67  * \param filename Name of an alist file to use. The alist
68  * format is described at:
69  * http://www.inference.phy.cam.ac.uk/mackay/codes/alist.html
70  */
71  static sptr make(const std::string filename);
72 
73  //! Encode \p inbuffer with LDPC H matrix into \p outbuffer.
74  virtual void encode(unsigned char *outbuffer,
75  const unsigned char *inbuffer) const = 0;
76 
77  //! Decode \p inbuffer with LDPC H matrix into \p outbuffer.
78  virtual void decode(unsigned char *outbuffer,
79  const float *inbuffer,
80  unsigned int frame_size,
81  unsigned int max_iterations) const = 0;
82 
83  /*!
84  * \brief A pointer to make SWIG work
85  *
86  * \details
87  * SWIG doesn't understand the parent class pointer to this
88  * child class for the make function of the
89  * ldpc_bit_flip_decoder; it's expecting a pointer to the base
90  * class. This returns a shared_from_this instance.
91  */
92  virtual gr::fec::code::fec_mtrx_sptr get_base_sptr() = 0;
93  };
94 
95  }
96  }
97 }
98 
99 #endif /* INCLUDED_ldpc_G_matrix_H */
Class for storing H or G matrix.
Definition: ldpc_G_matrix.h:54
Include this header to use the message passing features.
Definition: logger.h:131
#define FEC_API
Definition: gr-fec/include/gnuradio/fec/api.h:30
FEC_API unsigned char encode(unsigned char *symbols, unsigned char *data, unsigned int nbytes, unsigned char encstate)
boost::shared_ptr< ldpc_G_matrix > sptr
Definition: ldpc_G_matrix.h:58
Base class for FEC matrix objects.
Definition: fec_mtrx.h:136