Skip to content

add_matrixAddMatrixAddMatrixadd_matrixT_add_matrix🔗

Short description🔗

add_matrixAddMatrixAddMatrixadd_matrixT_add_matrix — Add two matrices.

Signature🔗

add_matrix( matrix MatrixAID, matrix MatrixBID, out matrix MatrixSumID )void AddMatrix( const HTuple& MatrixAID, const HTuple& MatrixBID, HTuple* MatrixSumID )static void HOperatorSet.AddMatrix( HTuple matrixAID, HTuple matrixBID, out HTuple matrixSumID )def add_matrix( matrix_aid: HHandle, matrix_bid: HHandle ) -> HHandle

Herror T_add_matrix( const Htuple MatrixAID, const Htuple MatrixBID, Htuple* MatrixSumID )

HMatrix HMatrix::AddMatrix( const HMatrix& MatrixBID ) const

HMatrix HMatrix.AddMatrix( HMatrix matrixBID )

Description🔗

The operator add_matrixAddMatrix computes the sum of the input matrices MatrixA and MatrixB given by the matrix handles MatrixAIDmatrixAIDmatrix_aid and MatrixBIDmatrixBIDmatrix_bid. Both matrices must have identical dimensions. A new matrix MatrixSum is generated with the result. The operator returns the matrix handle MatrixSumIDmatrixSumIDmatrix_sum_id of the matrix MatrixSum. Access to the elements of the matrix is possible e.g., with the operator get_full_matrixGetFullMatrix. The formula for the calculation of the result is:

\[\begin{eqnarray*} \texttt{MatrixSum} \quad = \quad \texttt{MatrixA} \quad + \quad \texttt{MatrixB}. \end{eqnarray*}\]

Example:

\[\begin{eqnarray*} \texttt{MatrixA} = \left[ \begin{array}{rrr} 3.0 & 1.0 & -2.0 \\ -5.0 & 7.0 & 2.0 \\ -9.0 & -4.0 & 1.0 \end{array} \right] \qquad \texttt{MatrixB} = \left[ \begin{array}{rrr} 2.0 & 8.0 & -3.0 \\ -4.0 & -1.0 & 5.0 \\ 2.0 & -4.0 & 7.0 \end{array} \right] \end{eqnarray*}\]
\[\begin{eqnarray*} \to \qquad \texttt{MatrixSum} = \left[ \begin{array}{rrr} 5.0 & 9.0 & -5.0 \\ -9.0 & 6.0 & 7.0 \\ -7.0 & -8.0 & 8.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.

MatrixSumIDmatrixSumIDmatrix_sum_id (output_control) matrix → (handle)HTuple (HHandle)HMatrix, HTuple (IntPtr)HHandleHtuple (handle)

Matrix handle with the sum of the input matrices.

Result🔗

If the parameters are valid, the operator add_matrixAddMatrix 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

add_matrix_modAddMatrixMod

See also

sub_matrixSubMatrix, sub_matrix_modSubMatrixMod

Module🔗

Foundation