GNU Radio Manual and C++ API Reference  3.10.9.1
The Free & Open Software Radio Ecosystem
gf2mat.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2015 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * SPDX-License-Identifier: GPL-3.0-or-later
8  *
9  */
10 
11 #ifndef GF2MAT_H
12 #define GF2MAT_H
13 #include "alist.h"
14 #include "gf2vec.h"
15 #include <vector>
16 
17 class GF2Mat
18 {
19  //! The matrix H
20  std::vector<std::vector<uint8_t>> H;
21 
22  //! Number of rows in H
23  int M;
24 
25  //! Number of columns in H
26  int N;
27 
28 public:
29  //! Default constructor
30  GF2Mat(){};
31 
32  //! Construct an M x N matrix with all 0 entries
33  GF2Mat(int m, int n);
34 
35  //! Loads the matrix from alist _list
36  GF2Mat(alist _list);
37 
38  //! Initializes the class from a 2-D vector X
39  GF2Mat(std::vector<std::vector<uint8_t>> X);
40 
41  //! Returns the variable M
42  int get_M();
43 
44  //! Returns the variable N
45  int get_N();
46 
47  //! Set the element at (i, j) coordinate to val
48  void set_element(int i, int j, char val);
49 
50  //! Returns the element at coordinate (i, j)
51  char get_element(int i, int j);
52 
53  //! Returns the ith row
54  GF2Vec get_row(int i);
55 
56  //! Returns the ith column
57  GF2Vec get_col(int i);
58 
59  //! Returns the ith row
61 
62  //! Prints the matrix H
63  void print_matrix();
64 
65  //! Sets the ith column with the given vector
66  void set_col(int i, GF2Vec vec);
67 
68  //! Sets the ith row with the given vector
69  void set_row(int i, GF2Vec vec);
70 
71  //! Swaps columns i and j
72  void swap_cols(int i, int j);
73 
74  //! Adds column j to i and replace i with the sum
75  void add_cols(int i, int j);
76 
77  //! Add row j to i and replace j with the sum
78  void add_rows(int i, int j);
79 
80  //! Returns the variable H
81  std::vector<std::vector<uint8_t>> get_H();
82 
83  /*!
84  * \brief Obtains an equivalent representation of H for encoding
85  *
86  * For encoding a G matrix in the form [I P] obtained from the
87  * parity matrix H, by (a) Column permutations, (b) Row additions
88  * and (c) Row permutations. Details of encoding is given in
89  * section A.1 of the reference:
90  *
91  * - "Modern Coding Theory", T Richardson and R Urbanke.
92  *
93  * \param p The column permutation during this operation.
94  * \param rank The rank of the matrix.
95  */
96  GF2Mat get_G(std::vector<int>& p, int& rank);
97 };
98 
99 #endif // #ifndef GF2MAT_H
Definition: gf2mat.h:18
GF2Vec get_row(int i)
Returns the ith row.
char get_element(int i, int j)
Returns the element at coordinate (i, j)
std::vector< std::vector< uint8_t > > get_H()
Returns the variable H.
void add_cols(int i, int j)
Adds column j to i and replace i with the sum.
void set_element(int i, int j, char val)
Set the element at (i, j) coordinate to val.
void set_col(int i, GF2Vec vec)
Sets the ith column with the given vector.
GF2Mat(alist _list)
Loads the matrix from alist _list.
GF2Mat(int m, int n)
Construct an M x N matrix with all 0 entries.
void add_rows(int i, int j)
Add row j to i and replace j with the sum.
void set_row(int i, GF2Vec vec)
Sets the ith row with the given vector.
GF2Vec operator[](int i)
Returns the ith row.
int get_N()
Returns the variable N.
GF2Mat()
Default constructor.
Definition: gf2mat.h:30
GF2Mat get_G(std::vector< int > &p, int &rank)
Obtains an equivalent representation of H for encoding.
GF2Mat(std::vector< std::vector< uint8_t >> X)
Initializes the class from a 2-D vector X.
int get_M()
Returns the variable M.
void swap_cols(int i, int j)
Swaps columns i and j.
void print_matrix()
Prints the matrix H.
GF2Vec get_col(int i)
Returns the ith column.
Definition: gf2vec.h:18
Definition: alist.h:33
GR_RUNTIME_API const pmt::pmt_t vec()