HALCON Reference Manual 10.0.2
Table of Contents / Matrix / Arithmetic ClassesClassesClasses | | | Operators

mult_matrixmult_matrixmult_matrixMultMatrixMultMatrix (Operator)

Name

mult_matrixmult_matrixmult_matrixMultMatrixMultMatrix — Multiply two matrices.

Signature

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

Herror mult_matrix(const Hlong MatrixAID, const Hlong MatrixBID, const char* MultType, Hlong* MatrixMultID)

Herror T_mult_matrix(const Htuple MatrixAID, const Htuple MatrixBID, const Htuple MultType, Htuple* MatrixMultID)

Herror mult_matrix(const HTuple& MatrixAID, const HTuple& MatrixBID, const HTuple& MultType, Hlong* MatrixMultID)

HMatrix HMatrix::MultMatrix(const HMatrix& MatrixBID, const HTuple& MultType) const

void HOperatorSetX.MultMatrix(
[in] VARIANT MatrixAID, [in] VARIANT MatrixBID, [in] VARIANT MultType, [out] VARIANT* MatrixMultID)

IHMatrixX* HMatrixX.MultMatrix(
[in] IHMatrixX* MatrixBID, [in] BSTR MultType)

static void HOperatorSet.MultMatrix(HTuple matrixAID, HTuple matrixBID, HTuple multType, out HTuple matrixMultID)

HMatrix HMatrix.MultMatrix(HMatrix matrixBID, string multType)

Description

The operator mult_matrixmult_matrixmult_matrixMultMatrixMultMatrix computes the product of the input matrices MatrixAMatrixAMatrixAMatrixAmatrixA and MatrixBMatrixBMatrixBMatrixBmatrixB defined by the matrix handles MatrixAIDMatrixAIDMatrixAIDMatrixAIDmatrixAID and MatrixBIDMatrixBIDMatrixBIDMatrixBIDmatrixBID. A new matrix MatrixMultMatrixMultMatrixMultMatrixMultmatrixMult is generated with the result. The operator returns the matrix handle MatrixMultIDMatrixMultIDMatrixMultIDMatrixMultIDmatrixMultID of the matrix MatrixMultMatrixMultMatrixMultMatrixMultmatrixMult. Access to the elements of the matrix is possible e.g. with the operator get_full_matrixget_full_matrixget_full_matrixGetFullMatrixGetFullMatrix. If desired, one or both input matrices will be transposed for the multiplication.

The type of multiplication can be selected via MultTypeMultTypeMultTypeMultTypemultType:

'AB'"AB""AB""AB""AB":

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

    MatrixMultMatrixMultMatrixMultMatrixMultmatrixMult = MatrixAMatrixAMatrixAMatrixAmatrixA * MatrixBMatrixBMatrixBMatrixBmatrixB.
  

The number of columns of the matrix MatrixAMatrixAMatrixAMatrixAmatrixA must be identical to the number of rows of the matrix MatrixBMatrixBMatrixBMatrixBmatrixB.

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'"ATB""ATB""ATB""ATB":

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

    MatrixMultMatrixMultMatrixMultMatrixMultmatrixMult = MatrixAMatrixAMatrixAMatrixAmatrixA^T * MatrixBMatrixBMatrixBMatrixBmatrixB.
  

The number of rows of the matrix MatrixAMatrixAMatrixAMatrixAmatrixA must be identical to the number of rows of the matrix MatrixBMatrixBMatrixBMatrixBmatrixB.

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'"ABT""ABT""ABT""ABT":

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

    MatrixMultMatrixMultMatrixMultMatrixMultmatrixMult = MatrixAMatrixAMatrixAMatrixAmatrixA * MatrixBMatrixBMatrixBMatrixBmatrixB^T.
  

The number of columns of the matrix MatrixAMatrixAMatrixAMatrixAmatrixA must be identical to the number of columns of the matrix MatrixBMatrixBMatrixBMatrixBmatrixB.

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'"ATBT""ATBT""ATBT""ATBT":

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

    MatrixMultMatrixMultMatrixMultMatrixMultmatrixMult = MatrixAMatrixAMatrixAMatrixAmatrixA^T * MatrixBMatrixBMatrixBMatrixBmatrixB^T.
  

The number of rows of the matrix MatrixAMatrixAMatrixAMatrixAmatrixA must be identical to the number of columns of the matrix MatrixBMatrixBMatrixBMatrixBmatrixB.

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

Parameters

MatrixAIDMatrixAIDMatrixAIDMatrixAIDmatrixAID (input_control)  matrix HMatrix, HTupleHMatrix, HTupleHMatrixX, VARIANTHtuple (integer) (IntPtr) (Hlong) (Hlong) (Hlong)

Matrix handle of the input matrix A.

MatrixBIDMatrixBIDMatrixBIDMatrixBIDmatrixBID (input_control)  matrix HMatrix, HTupleHMatrix, HTupleHMatrixX, VARIANTHtuple (integer) (IntPtr) (Hlong) (Hlong) (Hlong)

Matrix handle of the input matrix B.

MultTypeMultTypeMultTypeMultTypemultType (input_control)  string HTupleHTupleVARIANTHtuple (string) (string) (char*) (BSTR) (char*)

Type of the input matrices.

Default value: 'AB' "AB" "AB" "AB" "AB"

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

MatrixMultIDMatrixMultIDMatrixMultIDMatrixMultIDmatrixMultID (output_control)  matrix HMatrix, HTupleHMatrix, HTupleHMatrixX, VARIANTHtuple (integer) (IntPtr) (Hlong) (Hlong) (Hlong)

Matrix handle of the multiplied matrices.

Result

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

Possible Predecessors

create_matrixcreate_matrixcreate_matrixCreateMatrixCreateMatrix

Possible Successors

get_full_matrixget_full_matrixget_full_matrixGetFullMatrixGetFullMatrix, get_value_matrixget_value_matrixget_value_matrixGetValueMatrixGetValueMatrix

Alternatives

mult_matrix_modmult_matrix_modmult_matrix_modMultMatrixModMultMatrixMod

See also

mult_element_matrixmult_element_matrixmult_element_matrixMultElementMatrixMultElementMatrix, mult_element_matrix_modmult_element_matrix_modmult_element_matrix_modMultElementMatrixModMultElementMatrixMod, div_element_matrixdiv_element_matrixdiv_element_matrixDivElementMatrixDivElementMatrix, div_element_matrix_moddiv_element_matrix_moddiv_element_matrix_modDivElementMatrixModDivElementMatrixMod, transpose_matrixtranspose_matrixtranspose_matrixTransposeMatrixTransposeMatrix, transpose_matrix_modtranspose_matrix_modtranspose_matrix_modTransposeMatrixModTransposeMatrixMod

References

David Poole: “Linear Algebra: A Modern Introduction”; Thomson; Belmont; 2006.
Gene H. Golub, Charles F. van Loan: “Matrix Computations”; The Johns Hopkins University Press; Baltimore and London; 1996.

Module

Foundation


Table of Contents / Matrix / Arithmetic ClassesClassesClasses | | | Operators
HALCON Reference Manual 10.0.2 Copyright © 1996-2011 MVTec Software GmbH