Documentation

Sum elements in an array. More...

## Modules

sum
The C++ interface for sum.

af_sum
the C interface for sum

## Detailed Description

Sum elements in an array.

Sum is a reduction operation that computes the arithmetic
sum of the elements in an array.

The first sum function sums elements along a specific dimension
of the array. The defualt dimension is the first non-singleton
dimension.

array a = constant(1,5,5);
//a = 1 1 1 1 1
// = 1 1 1 1 1
// = 1 1 1 1 1
// = 1 1 1 1 1
// = 1 1 1 1 1
b = sum(a); //b = [5]
// [5]
// [5]
// [5]
// [5]

The second form of sum is templated, and returns the sum of all array elements to the host.

float hx[] = { -3, -5, 2, -9 };
array x1(2,2, hx); // x1 = -3 2
// -5 -9
printf("%g\n", sum<float>(x1)); // -15