# LGF_MatrixScalarMultiplication (FC / 3.0.2)

Overview

Author: Siemens Digital Industries

## Short description

This function block multiplies a matrix of the data type `ARRAY[*,*] of LREAL` with a scalar.

Example for 2x2 matrix:

B = b * A = \begin{bmatrix} b*a_{11} & b*a_{12} \\ b*a_{21} & b*a_{22} \end{bmatrix}

A matrix is multiplied by a scalar, thereby multiplying each matrix element by the scalar. The result is output in the `matrixResult` matrix.

Note
  Note that the input and output matrix must have the same number of columns and rows.

### Block Interface

| LGF_MatrixScalarMultiplication (FC) |
--- | --- | ---
LReal |  |  | scalar |  | Ret_Val |  |  | Void
|  |  |  |  | error |  |  | Bool
|  |  |  |  | status |  |  | Word
Array[*, *] of LReal |  |  | matrixInput |  |  | Array[*, *] of LReal
Array[*, *] of LReal |  |  | matrixResult |  |  | Array[*, *] of LReal

### Input parameter

Identifier | Data type | Description
--- | --- | ---
scalar | LReal | Scalar value where the matrix is multiplied

### Output parameter

Identifier | Data type | Description
--- | --- | ---
Ret_Val | Void | Void - Function has no return value
error | Bool | FALSE: No error TRUE: An error occurred during the execution of the FB
status | Word | 16#0000-16#7FFF: Status of the FB 16#8000-16#FFFF: Error identification (see following Table)

### In/Out parameter

Identifier | Data type | Description
--- | --- | ---
matrixInput | Array[*, *] of LReal | Matrix to multiply
matrixResult | Array[*, *] of LReal | The result matrix of the multiplication

### Status & Error codes

Code / Value | Identifier / Description
--- | ---
16#0000 | STATUS_NO_ERROR Execution finished without errors
16#8201 | ERR_MATRICES_LOWER_BOUND_ROWS_DONT_MATCH Error: Matrices lower bound rows(Dim1) do not match
16#8202 | ERR_MATRICES_UPPER_BOUND_ROWS_DONT_MATCH Error: Matrices upper bound rows(Dim1) do not match
16#8203 | ERR_MATRICES_LOWER_BOUND_COLUMNS_DONT_MATCH Error: Matrices lower bound columns(Dim2) do not match
16#8204 | ERR_MATRICES_UPPER_BOUND_COLUMNS_DONT_MATCH Error: Matrices upper bound columns(Dim2) do not match

## Change log

Version & Date | Change description
--- | ---
| 1.0.0 | Simatic Systems Support
| 11.12.2019 | First released version based on "LGF_MatrixMultiplication"
| 3.0.0 | Simatic Systems Support
| 23.04.2020 | Set version to V3.0.0, harmonize the version of the whole library
| 3.0.1 | Simatic Systems Support
| 02.02.2020 | Insert documentation
| 3.0.2 | Simatic Systems Support
| 18.07.2020 | Fix bug regarding wrong calculation