The C++ interface for sum.
More...
| array | sum (const array &input, int dim=-1) |
| |
| template<typename ty > |
| ty | sum (const array &input) |
| |
The C++ interface for sum.
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.
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);
printf("%g\n", sum<float>(x1));
| array af::sum |
( |
const array & |
input, |
|
|
int |
dim = -1 |
|
) |
| |
| ty af::sum |
( |
const array & |
input | ) |
|
- Parameters
-
| [in] | input | the array of values to sum |
- Returns
- sum of all values in the input array