Skip to content

add_matrix_modAddMatrixModAddMatrixModadd_matrix_modT_add_matrix_mod🔗

Short description🔗

add_matrix_modAddMatrixModAddMatrixModadd_matrix_modT_add_matrix_mod — Add two matrices.

Signature🔗

add_matrix_mod( matrix MatrixAID, matrix MatrixBID )void AddMatrixMod( const HTuple& MatrixAID, const HTuple& MatrixBID )static void HOperatorSet.AddMatrixMod( HTuple matrixAID, HTuple matrixBID )def add_matrix_mod( matrix_aid: HHandle, matrix_bid: HHandle ) -> None

Herror T_add_matrix_mod( const Htuple MatrixAID, const Htuple MatrixBID )

void HMatrix::AddMatrixMod( const HMatrix& MatrixBID ) const

void HMatrix.AddMatrixMod( HMatrix matrixBID )

Description🔗

The operator add_matrix_modAddMatrixMod 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. The input matrix MatrixA is overwritten with the result. 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{MatrixA} \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{MatrixA} = \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.

This operator modifies the state of the following input parameter:

During execution of this operator, access to the value of this parameter must be synchronized if it is used across multiple threads.

Parameters🔗

MatrixAIDmatrixAIDmatrix_aid (input_control, state is modified) 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.

Result🔗

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

See also

sub_matrixSubMatrix, sub_matrix_modSubMatrixMod

Module🔗

Foundation