GNU Radio Manual and C++ API Reference 3.8.5.0
The Free & Open Software Radio Ecosystem
 
Loading...
Searching...
No Matches
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
31namespace gr {
32namespace 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 */
69template <class T>
71{
72public:
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
95};
96
99} // namespace blocks
100} // namespace gr
101
102#endif /* MULTIPLY_MATRIX_H */
tag_propagation_policy_t
enum to represent different tag propagation policies.
Definition block.h:80
@ TPP_ALL_TO_ALL
Definition block.h:83
Matrix multiplexer/multiplier: y(k) = A x(k)
Definition multiply_matrix.h:71
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.
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:94
static sptr make(std::vector< std::vector< T > > A, gr::block::tag_propagation_policy_t tag_propagation_policy=gr::block::TPP_ALL_TO_ALL)
boost::shared_ptr< multiply_matrix< T > > sptr
Definition multiply_matrix.h:73
synchronous 1:1 input to output with history
Definition sync_block.h:38
#define BLOCKS_API
Definition gr-blocks/include/gnuradio/blocks/api.h:30
multiply_matrix< gr_complex > multiply_matrix_cc
Definition multiply_matrix.h:98
multiply_matrix< float > multiply_matrix_ff
Definition multiply_matrix.h:97
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition basic_block.h:46