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_fec_mtrx_impl_H
22 #define INCLUDED_fec_mtrx_impl_H
23 
24 #include <string>
25 
26 #include <gnuradio/fec/fec_mtrx.h>
27 #include <gsl/gsl_blas.h>
28 #include <gsl/gsl_linalg.h>
29 #include <gsl/gsl_matrix.h>
30 #include <gsl/gsl_permutation.h>
31 #include <gsl/gsl_randist.h>
32 
33 namespace gr {
34 namespace fec {
35 namespace code {
36 
37 class fec_mtrx_impl : public fec_mtrx
38 {
39 protected:
40     //! Constructor
41     fec_mtrx_impl();
42 
43     //! Codeword length n
44     unsigned int d_n;
45 
46     //! Information word length k
47     unsigned int d_k;
48 
49     //! Number of rows in the matrix read in from alist file
50     unsigned int d_num_rows;
51 
52     //! Number of columns in the matrix read in from alist file
53     unsigned int d_num_cols;
54 
55     //! GSL matrix structure for the parity check matrix
56     matrix_sptr d_H_sptr;
57 
58     //! Flag for whether or not the parity bits come first or last
59     bool d_par_bits_last;
60 
61 public:
62     //! Returns the parity check matrix H (needed by decoder)
63     const gsl_matrix* H() const;
64 
65     //! Get the codeword length n
66     unsigned int n() const;
67 
68     //! Get the information word length k
69     unsigned int k() const;
70 
71     //! Subtract matrices using mod2 operations
72     void
73     add_matrices_mod2(gsl_matrix* result, const gsl_matrix*, const gsl_matrix*) const;
74 
75     //! Multiply matrices using mod2 operations
76     void
77     mult_matrices_mod2(gsl_matrix* result, const gsl_matrix*, const gsl_matrix*) const;
78 
79     //! Invert a square matrix using mod2 operations
80     gsl_matrix* calc_inverse_mod2(const gsl_matrix*) const;
81 
82     /*!
83      * \brief Get Boolean for whether or not parity bits come first or last
84      * \details
85      * The decoder will need to know if the parity bits are
86      * coming first or last
87      */
88     bool parity_bits_come_last() const;
89 
90     virtual ~fec_mtrx_impl();
91 };
92 } // namespace code
93 } // namespace fec
94 } // namespace gr
95 
96 #endif /* INCLUDED_fec_mtrx_impl_H */
97