Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Group: Matrix Manipulation
Topic: Sorting and Counting
See also: cumprod cumsum mean prod

Function: sum
Description: sum computes the sum of the elements of an array regarding a given dimension.

Usage: z = sum (x {,j})
Input:
x d1 x d2 x ... x dn array
j integer (number of dimension, default = 1)
Output:
z d1 x d2 x .. x d(j-1) x 1 x d(j+1) x .. x dn array

Example:
x = #(1, 2)~#(3, 4)~#(5, 6)
sum(x,2)

Result:
Contents of sum

[1,]     9
[2,]    12



(C) MD*TECH Method and Data Technologies, 05.02.2006