GNU Radio Manual and C++ API Reference  3.10.9.1
The Free & Open Software Radio Ecosystem
ldpc_G_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_G_matrix_H
10 #define INCLUDED_ldpc_G_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 /*!
22  * \brief Class for storing H or G matrix
23  * \ingroup error_coding_blk
24  *
25  * \details
26  * This class stores a matrix variable, specifically
27  * either a:
28  *
29  * 1) Generator matrix, G, in the standard format G = [I P],
30  * where I is an identity matrix and P is the parity
31  * submatrix.
32  *
33  * or
34  *
35  * 2) Parity matrix, H, in the standard format H = [P' I],
36  * where P' is the transpose of the parity submatrix and I
37  * is an identity matrix.
38  *
39  * This variable can used by the ldpc_gen_mtrx_encoder and
40  * ldpc_bit_flip_decoder classes.
41  */
42 class FEC_API ldpc_G_matrix : virtual public fec_mtrx,
43  public std::enable_shared_from_this<ldpc_G_matrix>
44 {
45 public:
46  typedef std::shared_ptr<ldpc_G_matrix> sptr;
47 
48  /*!
49  * \brief Constructor given alist file
50  * \details
51  * 1. Reads in the matrix from an alist file
52  * 2. Determines if the matrix format is G=[I P] or H=[P' I]
53  * 3. Solves for G transpose (will be used during encoding)
54  *
55  * \param filename Name of an alist file to use. The alist
56  * format is described at:
57  * http://www.inference.phy.cam.ac.uk/mackay/codes/alist.html
58  */
59  static sptr make(const std::string filename);
60 
61  //! Encode \p inbuffer with LDPC H matrix into \p outbuffer.
62  void encode(unsigned char* outbuffer,
63  const unsigned char* inbuffer) const override = 0;
64 
65  //! Decode \p inbuffer with LDPC H matrix into \p outbuffer.
66  void decode(unsigned char* outbuffer,
67  const float* inbuffer,
68  unsigned int frame_size,
69  unsigned int max_iterations) const override = 0;
70 
71  //! Get the codeword length n
72  // Handled in fec_mtrx parent class.
73  unsigned int n() const override = 0;
74 
75  //! Get the information word length k
76  // Handled in fec_mtrx parent class.
77  unsigned int k() const override = 0;
78 
79  /*!
80  * \brief A pointer to make SWIG work
81  *
82  * \details
83  * SWIG doesn't understand the parent class pointer to this
84  * child class for the make function of the
85  * ldpc_bit_flip_decoder; it's expecting a pointer to the base
86  * class. This returns a shared_from_this instance.
87  */
88  virtual gr::fec::code::fec_mtrx_sptr get_base_sptr() = 0;
89 };
90 
91 } // namespace code
92 } // namespace fec
93 } // namespace gr
94 
95 #endif /* INCLUDED_ldpc_G_matrix_H */
Base class for FEC matrix objects.
Definition: fec_mtrx.h:124
Class for storing H or G matrix.
Definition: ldpc_G_matrix.h:44
static sptr make(const std::string filename)
Constructor given alist file.
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.
unsigned int n() const override=0
Get the codeword length n.
std::shared_ptr< ldpc_G_matrix > sptr
Definition: ldpc_G_matrix.h:46
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.
#define FEC_API
Definition: gr-fec/include/gnuradio/fec/api.h:18
GNU Radio logging wrapper.
Definition: basic_block.h:29