GNU Radio Manual and C++ API Reference  3.8.1.0
The Free & Open Software Radio Ecosystem
multiply_matrix.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2014, 2017, 2018 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 
24 #ifndef MULTIPLY_MATRIX_H
25 #define MULTIPLY_MATRIX_H
26 
27 #include <gnuradio/blocks/api.h>
28 #include <gnuradio/sync_block.h>
29 #include <cstdint>
30 
31 namespace gr {
32 namespace blocks {
33 
34 /*!
35  * \brief Matrix multiplexer/multiplier: y(k) = A x(k)
36  * \ingroup blocks
37  *
38  * This block is similar to gr::blocks::multiply_const_ff, the difference
39  * being it can handle several inputs and outputs, and the input-to-output
40  * relation can be described by the following mathematical equation:
41  * \f[
42  * \mathbf{y}(k) = \mathbf{A} \mathbf{x}(k) \, , \, y \in \mathbb{R}^N, \mathbf{x} \in
43  * \mathbb{R}^M, A \in \mathbb{R}^{N \times M} \f] \f$\mathbf{y}(k)\f$ and
44  * \f$\mathbf{x}(i)\f$ are column-vectors describing the elements on the input port at
45  * time step \f$k\f$ (this is a sync block with no memory).
46  *
47  * Examples for where to use this block include:
48  * - Switch matrices (i.e. switch which ports go where), assuming all ports run on the
49  * same rate
50  * - Simulation of static MIMO-Channels (in that case, \f$\mathbf{A}\f$ is the channel
51  * matrix)
52  * - Summing up streams with variable coefficients
53  *
54  * This block features a special tag propagation mode: When setting the tag propagation
55  * policy to gr::block::TPP_CUSTOM, a tag is propagated from input \f$k\f$ to output
56  * \f$l\f$, if \f$(A)_{l,k} \neq 0\f$.
57  *
58  * \section blocks_matrixmult_msgports_multiply_matrix Message Ports
59  *
60  * This block as one input message port (\p set_A). A message sent to this port will
61  * be converted to a std::vector<std::vector<T> >, and then passed on to set_A().
62  * If no conversion is possible, a warning is issued via the logging interface, and
63  * A remains unchanged.
64  *
65  * *Note*: It is not possible to change the dimension of the matrix after initialization,
66  * as this affects the I/O signature! If a matrix of invalid size is passed to the block,
67  * an alert is raised via the logging interface, and A remains unchanged.
68  */
69 template <class T>
71 {
72 public:
73  typedef boost::shared_ptr<multiply_matrix<T>> sptr;
74 
75  /*!
76  * \param A The matrix
77  * \param tag_propagation_policy The tag propagation policy.
78  * Note this can be any
79  * gr::block::tag_propagation_policy_t
80  * value. In case of TPP_CUSTOM, tags are
81  * only transferred from input \f$k\f$ to
82  * output \f$l \iff (A)_{l,k} \neq 0\f$.
83  */
84  static sptr make(std::vector<std::vector<T>> A,
85  gr::block::tag_propagation_policy_t tag_propagation_policy =
87 
88  //! Returns the current matrix
89  virtual const std::vector<std::vector<T>>& get_A() const = 0;
90  //! Sets the matrix to a new value \p new_A. Returns true if the new matrix was valid
91  //! and could be changed.
92  virtual bool set_A(const std::vector<std::vector<T>>& new_A) = 0;
93 
94  std::string MSG_PORT_NAME_SET_A;
95 };
96 
99 } // namespace blocks
100 } // namespace gr
101 
102 #endif /* MULTIPLY_MATRIX_H */
Definition: block.h:83
multiply_matrix< gr_complex > multiply_matrix_cc
Definition: multiply_matrix.h:98
multiply_matrix< float > multiply_matrix_ff
Definition: multiply_matrix.h:97
boost::shared_ptr< multiply_matrix< T > > sptr
Definition: multiply_matrix.h:73
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition: basic_block.h:43
#define BLOCKS_API
Definition: gr-blocks/include/gnuradio/blocks/api.h:30
Matrix multiplexer/multiplier: y(k) = A x(k)This block is similar to gr::blocks::multiply_const_ff, the difference being it can handle several inputs and outputs, and the input-to-output relation can be described by the following mathematical equation: and are column-vectors describing the elements on the input port at time step (this is a sync block with no memory).
Definition: multiply_matrix.h:70
synchronous 1:1 input to output with historyOverride work to provide the signal processing implementa...
Definition: sync_block.h:37
tag_propagation_policy_t
enum to represent different tag propagation policies.
Definition: block.h:80
std::string MSG_PORT_NAME_SET_A
Definition: multiply_matrix.h:94