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_impl_H 22 #define INCLUDED_ldpc_G_matrix_impl_H 23 24 #include <gsl/gsl_blas.h> 25 #include <gsl/gsl_linalg.h> 26 #include <gsl/gsl_permutation.h> 27 #include <gsl/gsl_randist.h> 28 29 #include "fec_mtrx_impl.h" 30 #include <gnuradio/fec/ldpc_G_matrix.h> 31 #include <gnuradio/fec/ldpc_H_matrix.h> 32 #include <gnuradio/logger.h> 33 34 namespace gr { 35 namespace fec { 36 namespace code { 37 /*! 38 * \brief Class for storing H or G matrix 39 * \ingroup error_coding_blk 40 * 41 * \details 42 * This class stores a GSL matrix variable, specifically 43 * either a: 44 * 45 * 1) Generator matrix, G, in the standard format G = [I P], 46 * where I is an identity matrix and P is the parity 47 * submatrix. 48 * 49 * or 50 * 51 * 2) Parity matrix, H, in the standard format H = [P' I], 52 * where P' is the transpose of the parity submatrix and I 53 * is an identity matrix. 54 * 55 * This variable can used by the ldpc_gen_mtrx_encoder and 56 * ldpc_bit_flip_decoder classes. 57 */ 58 class ldpc_G_matrix_impl : public fec_mtrx_impl, public ldpc_G_matrix 59 { 60 private: 61 // GSL matrix structure for transpose of G 62 gsl_matrix* d_G_transp_ptr; 63 64 gsl_matrix* d_H_obj; 65 66 //! Get the generator matrix (used during encoding) 67 const gsl_matrix* G_transpose() const; 68 69 gr::logger_ptr d_logger; 70 gr::logger_ptr d_debug_logger; 71 72 public: 73 ldpc_G_matrix_impl(const std::string filename); 74 75 void encode(unsigned char* outbuffer, const unsigned char* inbuffer) const; 76 77 void decode(unsigned char* outbuffer, 78 const float* inbuffer, 79 unsigned int frame_size, 80 unsigned int max_iterations) const; 81 n()82 unsigned int n() const { return fec_mtrx_impl::n(); } 83 k()84 unsigned int k() const { return fec_mtrx_impl::k(); } 85 86 gsl_matrix* generate_H(); 87 88 gr::fec::code::fec_mtrx_sptr get_base_sptr(); 89 90 /*! 91 * \brief Destructor 92 * \details 93 * Calls the gsl_matrix_free function to free memory. 94 */ 95 virtual ~ldpc_G_matrix_impl(); 96 }; 97 98 } // namespace code 99 } // namespace fec 100 } // namespace gr 101 102 #endif /* INCLUDED_ldpc_G_matrix_impl_H */ 103