Operators

mult_matrix (Operator)

Name

mult_matrix — Multiply two matrices.

Signature

mult_matrix( : : MatrixAID, MatrixBID, MultType : MatrixMultID)

Description

The operator mult_matrix computes the product of the input matrices MatrixA and MatrixB defined by the matrix handles MatrixAID and MatrixBID. A new matrix MatrixMult is generated with the result. The operator returns the matrix handle MatrixMultID of the matrix MatrixMult. Access to the elements of the matrix is possible e.g. with the operator get_full_matrix. If desired, one or both input matrices will be transposed for the multiplication.

The type of multiplication can be selected via MultType:

'AB':

The matrices MatrixA and MatrixB will not be transposed. Therefore, the formula for the calculation of the result is:

MatrixMult = MatrixA * MatrixB.

The number of columns of the matrix MatrixA must be identical to the number of rows of the matrix MatrixB.

Example:

/   3.0  -3.0  \                /   3.0  -3.0   1.0   1.0  \
MatrixA = |   2.0  -5.0  |      MatrixB = \   2.0  -1.0  -2.0  -1.0  /
\  -3.0   2.0  /

/   3.0  -6.0   9.0   6.0  \
->    MatrixMult = |  -4.0  -1.0  12.0   7.0  |
\  -5.0   7.0  -7.0  -5.0  /

'ATB':

The matrix MatrixA will be transposed. The matrix MatrixB will not be transposed. Therefore, the formula for the calculation of the result is:

MatrixMult = MatrixA^T * MatrixB.

The number of rows of the matrix MatrixA must be identical to the number of rows of the matrix MatrixB.

Example:

/   3.0   2.0  -3.0  \             /   3.0  -3.0   1.0   1.0  \
MatrixA = \  -3.0  -5.0   2.0  /   MatrixB = \   2.0  -1.0  -2.0  -1.0  /

/   3.0  -6.0   9.0   6.0  \
->    MatrixMult = |  -4.0  -1.0  12.0   7.0  |
\  -5.0   7.0  -7.0  -5.0  /

'ABT':

The matrix MatrixA will not be transposed. The matrix MatrixB will be transposed. Therefore, the formula for the calculation of the result is:

MatrixMult = MatrixA * MatrixB^T.

The number of columns of the matrix MatrixA must be identical to the number of columns of the matrix MatrixB.

Example:

/   3.0   2.0  \
/   3.0  -3.0  \                |  -3.0  -1.0  |
MatrixA = |   2.0  -5.0  |      MatrixB = |   1.0  -2.0  |
\  -3.0   2.0  /                \   1.0  -1.0  /

/   3.0  -6.0   9.0   6.0  \
->    MatrixMult = |  -4.0  -1.0  12.0   7.0  |
\  -5.0   7.0  -7.0  -5.0  /

'ATBT':

The matrix MatrixA and the matrix MatrixB will be transposed. Therefore, the formula for the calculation of the result is:

MatrixMult = MatrixA^T * MatrixB^T.

The number of rows of the matrix MatrixA must be identical to the number of columns of the matrix MatrixB.

Example:

/   3.0   2.0  \
/   3.0   2.0  -3.0  \                |  -3.0  -1.0  |
MatrixA = \  -3.0  -5.0   2.0  /      MatrixB = |   1.0  -2.0  |
\   1.0  -1.0  /

/   3.0  -6.0   9.0   6.0  \
->    MatrixMult = |  -4.0  -1.0  12.0   7.0  |
\  -5.0   7.0  -7.0  -5.0  /

Parallelization

• Multithreading type: reentrant (runs in parallel with non-exclusive operators).
• Processed without parallelization.

Parameters

MatrixAID (input_control)  matrix (integer)

Matrix handle of the input matrix A.

MatrixBID (input_control)  matrix (integer)

Matrix handle of the input matrix B.

MultType (input_control)  string (string)

Type of the input matrices.

Default value: 'AB'

List of values: 'AB', 'ABT', 'ATB', 'ATBT'

MatrixMultID (output_control)  matrix (integer)

Matrix handle of the multiplied matrices.

Result

If the parameters are valid, the operator mult_matrix returns the value 2 (H_MSG_TRUE). If necessary, an exception is raised.