msum()

Read(2099) Label: matrix, sum,

Description:

Calculate sum on a matrix or a multidimensional matrix.

Syntax:

msum(A, n)

Note:

An external library function (See External Library Guide) where parameter n is the sequence number of the level on which the summarization is performed. If n is absent, the desired dimension is the first one whose size is not 1 in matrix A.

Parameter:

A

A matrix or a multidimensional matrix

n

A positive integer

Option:

@a

Calculate sum on all elements of matrix A and parameter n is invalid

Return value:

Sequence/Number

Example:

 

A

 

1

[[11,12,13],[21,22,23],[31,32,33]]

 

 

 

2

=msum(A1, 1)

 

 

 

Calculate sum on the matrix’s first level – that is, calculate sum on members of each column.

3

=msum(A1, 2)

 

 

 

Calculate sum on the matrix’s second level – that is, calculate sum on members of each row.

4

=msum(A1)

 

 

 

 

Calculate sum on the first level since parameter n is absent.

5

=msum@a(A1)

 

 

 

Calculate sum on all elements of the matrix.

6

[[[111,112,113],[121,122,123],[131,132,133]],[[211,212,213],[221,222,223],[231,232,233]]]

 

 

 

Define a three-dimension matrix whose two members are 3*3 matrices.

7

=msum(A6, 1)

 

 

 

Calculate sum on matrix A6’s first level, that is, perform alignment addition on both of the two member matrices.

8

=msum(A6, 2)

Calculate sum on matrix A6’s second level, that is, perform the calculation on each column of each member matrix.