GNU Radio C++ API Reference: gf2mat.h Source File

| GNU Radio C++ API Reference 3.10.12.0 The Free & Open Software Radio Ecosystem |

Loading...
Searching...
No Matches
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
28public:
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
60 GF2Vec operator[](int i);
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
alist.h
GF2Mat::get_row
GF2Vec get_row(int i)
Returns the ith row.
GF2Mat::get_element
char get_element(int i, int j)
Returns the element at coordinate (i, j).
GF2Mat::add_cols
void add_cols(int i, int j)
Adds column j to i and replace i with the sum.
GF2Mat::set_element
void set_element(int i, int j, char val)
Set the element at (i, j) coordinate to val.
GF2Mat::set_col
void set_col(int i, GF2Vec vec)
Sets the ith column with the given vector.
GF2Mat::GF2Mat
GF2Mat(alist _list)
Loads the matrix from alist _list.
GF2Mat::GF2Mat
GF2Mat(int m, int n)
Construct an M x N matrix with all 0 entries.
GF2Mat::add_rows
void add_rows(int i, int j)
Add row j to i and replace j with the sum.
GF2Mat::set_row
void set_row(int i, GF2Vec vec)
Sets the ith row with the given vector.
GF2Mat::operator[]
GF2Vec operator[](int i)
Returns the ith row.
GF2Mat::get_N
int get_N()
Returns the variable N.
GF2Mat::GF2Mat
GF2Mat()
Default constructor.
Definition gf2mat.h:30
GF2Mat::get_G
GF2Mat get_G(std::vector< int > &p, int &rank)
Obtains an equivalent representation of H for encoding.
GF2Mat::get_M
int get_M()
Returns the variable M.
GF2Mat::get_H
std::vector< std::vector< uint8_t > > get_H()
Returns the variable H.
GF2Mat::swap_cols
void swap_cols(int i, int j)
Swaps columns i and j.
GF2Mat::print_matrix
void print_matrix()
Prints the matrix H.
GF2Mat::get_col
GF2Vec get_col(int i)
Returns the ith column.
GF2Mat::GF2Mat
GF2Mat(std::vector< std::vector< uint8_t > > X)
Initializes the class from a 2-D vector X.
GF2Vec
Definition gf2vec.h:18
alist
Definition alist.h:33
gf2vec.h