MatrixMul

AnalysisLibErrType MatrixMul (void *matrixX, void *matrixY, int numberOfRowsInX, int colsRowsInXY, int numberOfColumnsInY, void *outputMatrix);

Purpose

Multiplies two 2D input matrices, X and Y. MatrixMul obtains the (i, j)th element of the output matrix, Z, using the formula:

i = matrix row index
j = matrix column index
k = number of columns/rows in X/Y

Ensure that the matrix sizes are valid for matrix multiplication. You must meet the following size constraints:

Example

/* Multiply two matrices. Note: A x B - B x A, in general. */
double x[10][20], y[20][15], z[10][15];
int n, k, m;
n = 10;
k = 20;
m = 15;
MatrixMul (x, y, n, k, m, z);

Parameters

Input
Name Type Description
matrixX numeric array First matrix to multiply. The number of columns in matrixX must match the number of rows in matrixY. This matrix must be an array of doubles.
matrixY numeric array Second matrix to multiply. The number of columns of matrixX must match the number of rows of matrixY. This matrix must be an array of doubles.
numberOfRowsInX integer Number of rows in matrixX.
colsRowsInXY integer Number of columns in matrixX, which must be equal to the number of rows in matrixY.
numberOfColumnsInY integer Number of columns in matrixY.
Output
Name Type Description
outputMatrix numeric array Result of the matrix multiplication, as an array of doubles.

Return Value

Name Type Description
status AnalysisLibErrType A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants.