1.4.2.24 DSP_MatrixMul32 Function

Multiplication of two matrices C = A x B.

Description

void DSP_MatrixMul32(matrix32 *resMat, matrix32 *srcMat1, matrix32 *srcMat2);

Multiplication of two matrices, with inputs and outputs being in fractional Q31 numerical format. The output elements will saturate if the dot product exceeds maximum or minimum fractional values.

Preconditions

Matrices must be aligned such that columns of A = rows of B.

resMat must have the format of rows of A, columns of B.

All Matrices must be set into structure (ROWS, COLUMNS, vector_pointer).

Parameters

resMat pointer to different Matrix C structure (*int32_t)

srcMat1 pointer to the Matrix A structure (*int32_t)

srcMat2 pointer to the Matrix B structure (*int32_t)

Returns

None.

Remarks

Execution Time (cycles): 319 cycles + 38 / output matrix_element. The function will saturate the output value if it exceeds maximum limits per element.

Example

#define ROW1 3

#define COL1 2

#define ROW2 2

#define COL2 2

matrix32 *resMat, *srcMat1, *srcMat2;

int32_t result[ROW1*COL2];

int32_t test_MatrixA[ROW1*COL1]=

{

0x40000000,0x20000000, _// 0.5, 0.25_

0xD999999A,0x4CCCCCCC, _// -0.3, 0.6_

0xC0000000,0x0CCCCCCD _// -0.5 0.1_

};

int32_t test_MatrixB[ROW2*COL2]=

{

0x40000000,0x20000000, _// 0.5, 0.25_

0x0CCCCCCD,0xCCCCCCCD _// 0.1, -0.4_

};

matrix32 mat, mat2, mat3;

resMat=&mat;

srcMat1=&mat2;

srcMat2=&mat3;

srcMat1->row=ROW1;

srcMat1->col=COL1;

srcMat1->pMatrix=test_MatrixA;

srcMat2->col=COL2;

srcMat2->row=ROW2;

srcMat2->pMatrix=test_MatrixB;

resMat->row=ROW1; _// note resulting matrix MUST have ROW1 & COL2 format_

resMat->col=COL2;

resMat->pMatrix=result;

DSP_MatrixMul32(resMat, srcMat1, srcMat2);

_// result[] = matA[] x matB[] =_

_// { 0x23333333, 0x03333333 // 0.275, 0.025_

_// 0xF47AE147, 0xD7AE147B // -0.9, -0.315_

_// 0xE147AE14, 0xEAE147AE } // -0.24, -0.165_

C

void  DSP_MatrixMul32 (matrix32 * resMat , matrix32 * srcMat1 , matrix32 * srcMat2 );