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