ClassesClassesClassesClasses | | | | Operators

sum_matrixsum_matrixSumMatrixsum_matrixSumMatrixSumMatrix (Operator)

Name

sum_matrixsum_matrixSumMatrixsum_matrixSumMatrixSumMatrix — Returns the elementwise sum of a matrix.

Signature

sum_matrix( : : MatrixID, SumType : MatrixSumID)

Herror sum_matrix(const Hlong MatrixID, const char* SumType, Hlong* MatrixSumID)

Herror T_sum_matrix(const Htuple MatrixID, const Htuple SumType, Htuple* MatrixSumID)

Herror sum_matrix(const HTuple& MatrixID, const HTuple& SumType, Hlong* MatrixSumID)

HMatrix HMatrix::SumMatrix(const HTuple& SumType) const

void SumMatrix(const HTuple& MatrixID, const HTuple& SumType, HTuple* MatrixSumID)

HMatrix HMatrix::SumMatrix(const HString& SumType) const

HMatrix HMatrix::SumMatrix(const char* SumType) const

void HOperatorSetX.SumMatrix(
[in] VARIANT MatrixID, [in] VARIANT SumType, [out] VARIANT* MatrixSumID)

IHMatrixX* HMatrixX.SumMatrix([in] BSTR SumType)

static void HOperatorSet.SumMatrix(HTuple matrixID, HTuple sumType, out HTuple matrixSumID)

HMatrix HMatrix.SumMatrix(string sumType)

Description

The operator sum_matrixsum_matrixSumMatrixsum_matrixSumMatrixSumMatrix returns the sum of the elements of the MatrixMatrixMatrixMatrixMatrixmatrix defined by the matrix handle MatrixIDMatrixIDMatrixIDMatrixIDMatrixIDmatrixID. A new matrix MatrixSumMatrixSumMatrixSumMatrixSumMatrixSummatrixSum is generated with the result and the matrix handle MatrixSumIDMatrixSumIDMatrixSumIDMatrixSumIDMatrixSumIDmatrixSumID of this matrix is returned. Access to the elements of the matrix is possible e.g. with the operator get_full_matrixget_full_matrixGetFullMatrixget_full_matrixGetFullMatrixGetFullMatrix.

The type of sum determination of the matrix can be selected via the parameter SumTypeSumTypeSumTypeSumTypeSumTypesumType:

'columns'"columns""columns""columns""columns""columns":

The sum is returned for each column of the MatrixMatrixMatrixMatrixMatrixmatrix separately. The resulting matrix MatrixSumMatrixSumMatrixSumMatrixSumMatrixSummatrixSum has one row and the identical number of columns as the input matrix.

Example:


           /   8.0   4.0  -3.0  \
  Matrix = \  -6.0   2.0   7.0  /      SumType = 'columns'

  ->    MatrixSum = [  2.0   6.0   4.0  ]
  

'rows'"rows""rows""rows""rows""rows":

The sum is returned for each row of the MatrixMatrixMatrixMatrixMatrixmatrix separately. The resulting matrix MatrixSumMatrixSumMatrixSumMatrixSumMatrixSummatrixSum has the identical number of rows as the input matrix and one column.

Example:


           /   8.0   4.0  -3.0  \
  Matrix = \  -6.0   2.0   7.0  /      SumType = 'rows'

                    / 9.0 \
  ->    MatrixSum = \ 3.0 /
  

'full'"full""full""full""full""full":

The sum is returned using all elements of the MatrixMatrixMatrixMatrixMatrixmatrix. The resulting matrix MatrixSumMatrixSumMatrixSumMatrixSumMatrixSummatrixSum has one row and one column.

Example:


           /   8.0   4.0  -3.0  \
  Matrix = \  -6.0   2.0   7.0  /      SumType = 'full'

  ->   MatrixSum = [ 12.0 ]
  

Parallelization

Parameters

MatrixIDMatrixIDMatrixIDMatrixIDMatrixIDmatrixID (input_control)  matrix HMatrix, HTupleHTupleHMatrix, HTupleHMatrixX, VARIANTHtuple (integer) (IntPtr) (Hlong) (Hlong) (Hlong) (Hlong)

Matrix handle of the input matrix.

SumTypeSumTypeSumTypeSumTypeSumTypesumType (input_control)  string HTupleHTupleHTupleVARIANTHtuple (string) (string) (HString) (char*) (BSTR) (char*)

Type of summation.

Default value: 'columns' "columns" "columns" "columns" "columns" "columns"

List of values: 'columns'"columns""columns""columns""columns""columns", 'full'"full""full""full""full""full", 'rows'"rows""rows""rows""rows""rows"

MatrixSumIDMatrixSumIDMatrixSumIDMatrixSumIDMatrixSumIDmatrixSumID (output_control)  matrix HMatrix, HTupleHTupleHMatrix, HTupleHMatrixX, VARIANTHtuple (integer) (IntPtr) (Hlong) (Hlong) (Hlong) (Hlong)

Matrix handle with the sum of the input matrix.

Result

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

Possible Predecessors

create_matrixcreate_matrixCreateMatrixcreate_matrixCreateMatrixCreateMatrix

Possible Successors

get_full_matrixget_full_matrixGetFullMatrixget_full_matrixGetFullMatrixGetFullMatrix, get_value_matrixget_value_matrixGetValueMatrixget_value_matrixGetValueMatrixGetValueMatrix

See also

norm_matrixnorm_matrixNormMatrixnorm_matrixNormMatrixNormMatrix

Module

Foundation


ClassesClassesClassesClasses | | | | Operators