LGF_MatrixMultiplication (FC / V3.0.1)


Author: Siemens Digital Industries

Short description

This function multiplies two matrices of the data type ARRAY[*,*] of LREAL.

Example for 2x2 matrix:

result = \begin{bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{bmatrix} * \begin{bmatrix} b_{11} & b_{12} \\ b_{21} & b_{22} \end{bmatrix} = \begin{bmatrix} a_{11}*b_{11}+a_{12}*b_{21} & a_{11}*b_{12}+a_{12}*b_{22} \\ a_{21}*b_{11}+a_{22}*b_{21} & a_{21}*b_{12}+a_{22}*b_{22} \end{bmatrix}

The block multiplies two matrices of variable size. The individual elements of the two incoming matrices are read, multiplied, and then output in the matrixResult matrix.

Note
Note that the number of columns in the first matrix must be equal to the number of rows in the second matrix.
The size of the initial matrix (m * n) results from the number of rows (m) of matrix1 and the number of columns (n) of matrix2.

Block Interface

LGF_MatrixMultiplication (FC)
   Ret_Val  Void
    
   error  Bool
    
   status  Word
    
Array[*, *] of LReal  matrix1  Array[*, *] of LReal
       
Array[*, *] of LReal  matrix2  Array[*, *] of LReal
       
Array[*, *] of LReal  matrixResult  Array[*, *] of LReal
       
   

Output parameter

IdentifierData typeDescription
Ret_ValVoidVoid - Function has no return value
errorBoolFALSE: No error
TRUE: An error occurred during the execution of the FB
statusWord16#0000-16#7FFF: Status of the FB
16#8000-16#FFFF: Error identification (see following Table)

In/Out parameter

IdentifierData typeDescription
matrix1Array[*, *] of LRealFirst factor: Matrix to multiply
matrix2Array[*, *] of LRealSecond factor: Matrix to multiply
matrixResultArray[*, *] of LRealProduct: The resulting matrix

Status & Error codes

Code / ValueIdentifier / Description
16#0000STATUS_NO_ERROR
Execution finished without errors
16#8200ERR_MATR1_LOWBOUND_COLUMNS_MATR2_LOWBOUND_ROWS
Error: Matrix 1 lower bound columns(Dim2) size is different with Matrix2 lower bound rows(Dim1)
16#8201ERR_MATR1_UPPBOUND_COLUMNS_MATR2_UPPBOUND_ROWS
Error: Matrix 1 upper bound columns(Dim2) size is different with Matrix 2 upper bound rows(Dim1)
16#8202ERR_MATR1_LOWBOUND_ROWS_RESMATR_LOWBOUND_ROWS
Error: Matrix 1 lower bound rows(Dim1) size is different with Result Matrix lower bound rows(Dim1)
16#8203ERR_MATR2_LOWBOUND_COLUMNS_RESMATR_LOWBOUND_COLUMNS
Error: Matrix 2 lower bound columns(Dim2) size is different with Result Matrix lower bound columns(Dim2)
16#8204ERR_MATR1_UPPBOUND_ROWS_RESMATR_UPPBOUND_ROWS
Error: Matrix 1 upper bound rows(Dim1) size is different with Result Matrix upper bound rows(Dim1)
16#8205ERR_MATR2_UPPBOUND_COLUMNS_RESMATR_UPPBOUND_COLUMNS
Error: Matrix 2 upper bound columns(Dim2) size is different with Result Matrix upper bound columns(Dim2)

Change log

Version & DateChange description
01.00.00Siemens Industry Online Support
19.08.2015First released version
01.00.01Siemens Industry Online Support
02.01.2017Upgrade: TIA Portal V14 Update 1
02.00.00Siemens Industry Online Support
06.02.2017Functionality using Array[*,*]
02.00.01Siemens Industry Online Support
17.08.2018Upgrade: TIA V15 Update 2
02.00.02Siemens Industry Online Support
23.11.2018Upgrade: TIA V15.1
02.00.06Simatic Systems Support
13.11.2019Regions, comments and constants are added
Moved matrices to IO field.
03.00.00Simatic Systems Support
23.04.2020Set version to V3.0.0, harmonize the version of the whole library
03.00.01Simatic Systems Support
02.02.2020Insert documentation