Admin Production ni-theme
Current Publication

MatrixMul

LabWindows/CVI

MatrixMul

AnalysisLibErrType MatrixMul (void *matrixX, void *matrixY, ssize_t numberOfRowsInX, ssize_t colsRowsInXY, ssize_t 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:

  • matrixX must be n by k.
  • matrixY must be k by m.
  • outputMatrix must be n by m.

Example Code

/* 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 void * 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 void * 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.
OfRowsInX ssize_t The number of rows in matrixX.
colsRowsInXY ssize_t Number of columns in matrixX, which must be equal to the number of rows in matrixY.
OfColumnsInY ssize_t The number of columns in matrixY.
Output
Name Type Description
outputMatrix void * 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.

Additional Information

Library: Analysis Library

Include file: analysis.h

LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later