# Matrix valued signals

Activate signals are matrix valued. A signal referred to as scalar is in fact a 1x1 matrix valued signal. A signal sized mx1 is called vector valued but it is just a special case of a matrix valued signal. In particular, a 1xn signal is not considered vector valued, and a parameter of type vector defined as a 1xn matrix is automatically converted to an nx1 column vector.

### Matrix signal support

Most Activate blocks support non-scalar matrix valued signals as inputs and outputs. This is true even for blocks not present in the MatrixOperations palette. In general when an input or inputs of a block not present in the MatrixOperations palette are matrix valued, the block applies its operation to every element of the input matrix or matrices producing an output of corresponding size. For example blocks realizing basic functions such as exp, sin, cos, etc., apply these functions element-wise to the input matrix. These blocks do not implement the matrix exponential, sine or cosine functions. Blocks realizing matrix operations are in the MatrixOperations palette. See for example the Expm and MatrixGain blocks for the matrix exponential function and matrix multiplication with a constant gain.

Blocks with no inputs and multiple inputs also support arbitrary sized matrices. For example most signal generators produce matrix valued signals if their block parameters are matrices. For example the SineWaveGenerator block may produce a matrix of sine waves with different amplitudes, frequencies, phases and bias values. Similarly blocks with more than one input may perform element-wise operations on their input matrices. For example the Sum, Product and ConditionalSelect blocks accept non-scalar matrix valued inputs.

### Size constraints

The element-wise operations realized by Activate blocks when the inputs and parameters have arbitrary matrix values imply in general that the sizes of these input and parameter matrices must be equal. To add two signals, the signals must in general have identical sizes. When a sine wave is generated, its size is given by the size of all of its block parameters, etc. In most cases however, this size constraint is relaxed to facilitate model construction. For example the Sum block accepts adding a scalar (which is nothing but a 1x1 matrix) input to an arbitrary sized mxn matrix. In that case the scalar is virtually expanded to an mxn matrix with entries identical to the original scalar. Similarly any one of the parameters of the SineWaveGenerator block may be defined as scalar even if the others are not. This size expansion rule is not limited to scalars.

### Row/Column expansions

The relaxation of size constraints on mixed sized operations on block inputs and parameters go further than just allowing mix operations with scalars. In general, any dimension (row, column or both) that equals to one could be expanded. For example, the Sum block may add an mxn matrix to an mx1 matrix. The latter input matrix is (virtually) expanded to an mxn matrix by replicating its columns. Similarly, an mxn matrix may be added to a 1xn matrix. In both cases, the output would be mxn. This expansion rule also allows adding a 1xn matrix to an mx1 matrix. Applying this expansion rule in particular produces a consistent addition where the output is of size mxn. Note that in this case the output size does not equal the input size of any of the inputs but it is consistent with the input sizes. In general, the output is the smallest sized matrix consistent with all the inputs (and parameters). Note that the expansion is done virtually and is not explicitly realized in order to perform the block operation for efficiently.