GNU Radio Manual and C++ API Reference  3.10.9.1
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  * SPDX-License-Identifier: GPL-3.0-or-later
8  *
9  */
10 
11 
12 #ifndef MULTIPLY_MATRIX_H
13 #define MULTIPLY_MATRIX_H
14 
15 #include <gnuradio/blocks/api.h>
16 #include <gnuradio/sync_block.h>
17 #include <cstdint>
18 
19 namespace gr {
20 namespace blocks {
21 
22 /*!
23  * \brief Matrix multiplexer/multiplier: y(k) = A x(k)
24  * \ingroup blocks
25  *
26  * This block is similar to gr::blocks::multiply_const_ff, the difference
27  * being it can handle several inputs and outputs, and the input-to-output
28  * relation can be described by the following mathematical equation:
29  * \f[
30  * \mathbf{y}(k) = \mathbf{A} \mathbf{x}(k) \, , \, y \in \mathbb{R}^N, \mathbf{x} \in
31  * \mathbb{R}^M, A \in \mathbb{R}^{N \times M} \f] \f$\mathbf{y}(k)\f$ and
32  * \f$\mathbf{x}(i)\f$ are column-vectors describing the elements on the input port at
33  * time step \f$k\f$ (this is a sync block with no memory).
34  *
35  * Examples for where to use this block include:
36  * - Switch matrices (i.e. switch which ports go where), assuming all ports run on the
37  * same rate
38  * - Simulation of static MIMO-Channels (in that case, \f$\mathbf{A}\f$ is the channel
39  * matrix)
40  * - Summing up streams with variable coefficients
41  *
42  * This block features a special tag propagation mode: When setting the tag propagation
43  * policy to gr::block::TPP_CUSTOM, a tag is propagated from input \f$k\f$ to output
44  * \f$l\f$, if \f$(A)_{l,k} \neq 0\f$.
45  *
46  * \section blocks_matrixmult_msgports_multiply_matrix Message Ports
47  *
48  * This block as one input message port (\p set_A). A message sent to this port will
49  * be converted to a std::vector<std::vector<T> >, and then passed on to set_A().
50  * If no conversion is possible, a warning is issued via the logging interface, and
51  * A remains unchanged.
52  *
53  * *Note*: It is not possible to change the dimension of the matrix after initialization,
54  * as this affects the I/O signature! If a matrix of invalid size is passed to the block,
55  * an alert is raised via the logging interface, and A remains unchanged.
56  */
57 template <class T>
59 {
60 public:
61  typedef std::shared_ptr<multiply_matrix<T>> sptr;
62 
63  /*!
64  * \param A The matrix
65  * \param tag_propagation_policy The tag propagation policy.
66  * Note this can be any
67  * gr::block::tag_propagation_policy_t
68  * value. In case of TPP_CUSTOM, tags are
69  * only transferred from input \f$k\f$ to
70  * output \f$l \iff (A)_{l,k} \neq 0\f$.
71  */
72  static sptr make(std::vector<std::vector<T>> A,
73  gr::block::tag_propagation_policy_t tag_propagation_policy =
75 
76  //! Returns the current matrix
77  virtual const std::vector<std::vector<T>>& get_A() const = 0;
78  //! Sets the matrix to a new value \p new_A. Returns true if the new matrix was valid
79  //! and could be changed.
80  virtual bool set_A(const std::vector<std::vector<T>>& new_A) = 0;
81 
82  std::string MSG_PORT_NAME_SET_A;
83 };
84 
87 } // namespace blocks
88 } // namespace gr
89 
90 #endif /* MULTIPLY_MATRIX_H */
tag_propagation_policy_t
enum to represent different tag propagation policies.
Definition: gnuradio-runtime/include/gnuradio/block.h:71
@ TPP_ALL_TO_ALL
Definition: gnuradio-runtime/include/gnuradio/block.h:74
Matrix multiplexer/multiplier: y(k) = A x(k)
Definition: multiply_matrix.h:59
virtual const std::vector< std::vector< T > > & get_A() const =0
Returns the current matrix.
std::string MSG_PORT_NAME_SET_A
Definition: multiply_matrix.h:82
static sptr make(std::vector< std::vector< T >> A, gr::block::tag_propagation_policy_t tag_propagation_policy=gr::block::TPP_ALL_TO_ALL)
virtual bool set_A(const std::vector< std::vector< T >> &new_A)=0
Sets the matrix to a new value new_A. Returns true if the new matrix was valid and could be changed.
std::shared_ptr< multiply_matrix< T > > sptr
Definition: multiply_matrix.h:61
synchronous 1:1 input to output with history
Definition: sync_block.h:26
#define BLOCKS_API
Definition: gr-blocks/include/gnuradio/blocks/api.h:18
multiply_matrix< gr_complex > multiply_matrix_cc
Definition: multiply_matrix.h:86
multiply_matrix< float > multiply_matrix_ff
Definition: multiply_matrix.h:85
GNU Radio logging wrapper.
Definition: basic_block.h:29