Skip to content

mult_matrixMultMatrixMultMatrixmult_matrixT_mult_matrix๐Ÿ”—

Short description๐Ÿ”—

mult_matrixMultMatrixMultMatrixmult_matrixT_mult_matrix โ€” Multiply two matrices.

Signature๐Ÿ”—

mult_matrix( matrix MatrixAID, matrix MatrixBID, string MultType, out matrix MatrixMultID )void MultMatrix( const HTuple& MatrixAID, const HTuple& MatrixBID, const HTuple& MultType, HTuple* MatrixMultID )static void HOperatorSet.MultMatrix( HTuple matrixAID, HTuple matrixBID, HTuple multType, out HTuple matrixMultID )def mult_matrix( matrix_aid: HHandle, matrix_bid: HHandle, mult_type: str ) -> HHandle

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

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

HMatrix HMatrix::MultMatrix( const HMatrix& MatrixBID, const char* MultType ) const

HMatrix HMatrix::MultMatrix( const HMatrix& MatrixBID, const wchar_t* MultType ) const (Windows only)

HMatrix HMatrix.MultMatrix( HMatrix matrixBID, string multType )

Description๐Ÿ”—

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

The type of multiplication can be selected via MultTypemultTypemult_type:

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

    \[\begin{eqnarray*} \texttt{MatrixMult} \quad = \quad \texttt{MatrixA} \quad \cdot \quad \texttt{MatrixB}. \end{eqnarray*}\]

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

    Example:

    \[\begin{eqnarray*} \texttt{MatrixA} = \left[ \begin{array}{rr} 3.0 & -3.0 \\ 2.0 & -5.0 \\ -3.0 & 2.0 \end{array} \right] \qquad \texttt{MatrixB} = \left[ \begin{array}{rrrr} 3.0 & -3.0 & 1.0 & 1.0 \\ 2.0 & -1.0 & -2.0 & -1.0 \end{array} \right] \end{eqnarray*}\]
    \[\begin{eqnarray*} \to \qquad \texttt{MatrixMult} = \left[ \begin{array}{rrrr} 3.0 & -6.0 & 9.0 & 6.0 \\ -4.0 & -1.0 & 12.0 & 7.0 \\ -5.0 & 7.0 & -7.0 & -5.0 \end{array} \right] \end{eqnarray*}\]
  • 'ATB'"ATB": The matrix MatrixA will be transposed. The matrix MatrixB will not be transposed. Therefore, the formula for the calculation of the result is:

    \[\begin{eqnarray*} \texttt{MatrixMult} \quad = \quad \texttt{MatrixA}^T \quad \cdot \quad \texttt{MatrixB}. \end{eqnarray*}\]

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

    Example:

    \[\begin{eqnarray*} \texttt{MatrixA} = \left[ \begin{array}{rrr} 3.0 & 2.0 & -3.0 \\ -3.0 & -5.0 & 2.0 \end{array} \right] \qquad \texttt{MatrixB} = \left[ \begin{array}{rrrr} 3.0 & -3.0 & 1.0 & 1.0 \\ 2.0 & -1.0 & -2.0 & -1.0 \end{array} \right] \end{eqnarray*}\]
    \[\begin{eqnarray*} \to \qquad \texttt{MatrixMult} = \left[ \begin{array}{rrrr} 3.0 & -6.0 & 9.0 & 6.0 \\ -4.0 & -1.0 & 12.0 & 7.0 \\ -5.0 & 7.0 & -7.0 & -5.0 \end{array} \right] \end{eqnarray*}\]
  • 'ABT'"ABT": The matrix MatrixA will not be transposed. The matrix MatrixB will be transposed. Therefore, the formula for the calculation of the result is:

    \[\begin{eqnarray*} \texttt{MatrixMult} \quad = \quad \texttt{MatrixA} \quad \cdot \quad \texttt{MatrixB}^T. \end{eqnarray*}\]

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

    Example:

    \[\begin{eqnarray*} \texttt{MatrixA} = \left[ \begin{array}{rr} 3.0 & -3.0 \\ 2.0 & -5.0 \\ -3.0 & 2.0 \end{array} \right] \qquad \texttt{MatrixB} = \left[ \begin{array}{rr} 3.0 & 2.0 \\ -3.0 & -1.0 \\ 1.0 & -2.0 \\ 1.0 & -1.0 \end{array} \right] \end{eqnarray*}\]
    \[\begin{eqnarray*} \to \qquad \texttt{MatrixMult} = \left[ \begin{array}{rrrr} 3.0 & -6.0 & 9.0 & 6.0 \\ -4.0 & -1.0 & 12.0 & 7.0 \\ -5.0 & 7.0 & -7.0 & -5.0 \end{array} \right] \end{eqnarray*}\]
  • 'ATBT'"ATBT": The matrix MatrixA and the matrix MatrixB will be transposed. Therefore, the formula for the calculation of the result is:

    \[\begin{eqnarray*} \texttt{MatrixMult} \quad = \quad \texttt{MatrixA}^T \quad \cdot \quad \texttt{MatrixB}^T. \end{eqnarray*}\]

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

    Example:

    \[\begin{eqnarray*} \texttt{MatrixA} = \left[ \begin{array}{rrr} 3.0 & 2.0 & -3.0 \\ -3.0 & -5.0 & 2.0 \end{array} \right] \qquad \texttt{MatrixB} = \left[ \begin{array}{rr} 3.0 & 2.0 \\ -3.0 & -1.0 \\ 1.0 & -2.0 \\ 1.0 & -1.0 \end{array} \right] \end{eqnarray*}\]
    \[\begin{eqnarray*} \to \qquad \texttt{MatrixMult} = \left[ \begin{array}{rrrr} 3.0 & -6.0 & 9.0 & 6.0 \\ -4.0 & -1.0 & 12.0 & 7.0 \\ -5.0 & 7.0 & -7.0 & -5.0 \end{array} \right] \end{eqnarray*}\]

Execution information๐Ÿ”—

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

Parameters๐Ÿ”—

MatrixAIDmatrixAIDmatrix_aid (input_control) matrix โ†’ (handle)HTuple (HHandle)HMatrix, HTuple (IntPtr)HHandleHtuple (handle)

Matrix handle of the input matrix A.

MatrixBIDmatrixBIDmatrix_bid (input_control) matrix โ†’ (handle)HTuple (HHandle)HMatrix, HTuple (IntPtr)HHandleHtuple (handle)

Matrix handle of the input matrix B.

MultTypemultTypemult_type (input_control) string โ†’ (string)HTuple (HString)HTuple (string)strHtuple (char*)

Type of the input matrices.

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

MatrixMultIDmatrixMultIDmatrix_mult_id (output_control) matrix โ†’ (handle)HTuple (HHandle)HMatrix, HTuple (IntPtr)HHandleHtuple (handle)

Matrix handle of the multiplied matrices.

Result๐Ÿ”—

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

Combinations with other operators๐Ÿ”—

Combinations

Possible predecessors

create_matrixCreateMatrix

Possible successors

get_full_matrixGetFullMatrix, get_value_matrixGetValueMatrix

Alternatives

mult_matrix_modMultMatrixMod

See also

mult_element_matrixMultElementMatrix, mult_element_matrix_modMultElementMatrixMod, div_element_matrixDivElementMatrix, div_element_matrix_modDivElementMatrixMod, transpose_matrixTransposeMatrix, transpose_matrix_modTransposeMatrixMod

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