sum4

Syntax

sum4(X)

Arguments

X is a scalar/vector/matrix.

Details

If X is a vector, return the sum of the fourth powers of all the elements in X.

If X is a matrix, calculate the sum of the fourth powers for each column of X and return a vector.

As with all aggregate functions, NULL values are not included in the calculation.

If all elements of a calculation are NULLs, the result is NULL.

Please note that the data type of the result is always DOUBLE, even if the data type of X is INT or LONG.

Examples

$ sum4(1 2 3);
98

$ sum4(1 NULL NULL);
1

$ sum4(1.5 4.6 7.8);
4154.3137

$ m=matrix(1 2 3, 4 5 6);
$ m;

#0

#1

1

4

2

5

3

6

$ sum4(m);
[98,2177]