ArrayFire: sum
Sum array elements over a given dimension. More...
Functions | |
| AFAPI array | sum (const array &in, const int dim=-1) |
| C++ Interface to sum array elements over a given dimension. More... | |
| AFAPI array | sum (const array &in, const int dim, const double nanval) |
| C++ Interface to sum array elements over a given dimension, replacing any NaNs with a specified value. More... | |
| template<typename T > | |
| T | sum (const array &in) |
| C++ Interface to sum array elements over all dimensions. More... | |
| template<typename T > | |
| T | sum (const array &in, double nanval) |
| C++ Interface to sum array elements over all dimensions, replacing any NaNs with a specified value. More... | |
| AFAPI af_err | af_sum (af_array *out, const af_array in, const int dim) |
| C Interface to sum array elements over a given dimension. More... | |
| AFAPI af_err | af_sum_all_array (af_array *out, const af_array in) |
| C Interface to sum array elements over all dimensions. More... | |
| AFAPI af_err | af_sum_nan (af_array *out, const af_array in, const int dim, const double nanval) |
| C Interface to sum array elements over a given dimension, replacing any NaNs with a specified value. More... | |
| AFAPI af_err | af_sum_nan_all_array (af_array *out, const af_array in, const double nanval) |
| C Interface to sum array elements over all dimensions, replacing any NaNs with a specified value. More... | |
| AFAPI af_err | af_sum_all (double *real, double *imag, const af_array in) |
| C Interface to sum array elements over all dimensions. More... | |
| AFAPI af_err | af_sum_nan_all (double *real, double *imag, const af_array in, const double nanval) |
| C Interface to sum array elements over all dimensions, replacing any NaNs with a specified value. More... | |
Sum array elements over a given dimension.
This table defines output types for corresponding input types:
| Input Type | Output Type |
|---|---|
| f32, f64, c32, c64 | same as input |
| s32, s64, u32, u64 | same as input |
| s16, s8 | s32 |
| u16, u8, b8 | u32 |
This function runs across all batches in the input simultaneously.
◆ af_sum()
C Interface to sum array elements over a given dimension.
- Parameters
-
[out] out sum [in] in input array [in] dim dimension along which the summation occurs
- Returns
- AF_SUCCESS, if function returns successfully, else an af_err code is given
◆ af_sum_all()
C Interface to sum array elements over all dimensions.
If in is real, imag will be set to zeros.
- Parameters
-
[out] real sum of all real components [out] imag sum of all imaginary components [in] in input array
- Returns
- AF_SUCCESS, if function returns successfully, else an af_err code is given
◆ af_sum_all_array()
C Interface to sum array elements over all dimensions.
Results in a single element af::array.
- Parameters
-
[out] out sum [in] in input array
- Returns
- AF_SUCCESS, if function returns successfully, else an af_err code is given
◆ af_sum_nan()
C Interface to sum array elements over a given dimension, replacing any NaNs with a specified value.
- Parameters
-
[out] out sum [in] in input array [in] dim dimension along which the summation occurs [in] nanval value that replaces NaNs
- Returns
- AF_SUCCESS, if function returns successfully, else an af_err code is given
◆ af_sum_nan_all()
| AFAPI af_err af_sum_nan_all | ( | double * | real, |
| double * | imag, | ||
| const af_array | in, | ||
| const double | nanval | ||
| ) |
C Interface to sum array elements over all dimensions, replacing any NaNs with a specified value.
If in is real, imag will be set to zeros.
- Parameters
-
[out] real sum of all real components [out] imag sum of all imaginary components [in] in input array [in] nanval value that replaces NaNs
- Returns
- AF_SUCCESS, if function returns successfully, else an af_err code is given
◆ af_sum_nan_all_array()
C Interface to sum array elements over all dimensions, replacing any NaNs with a specified value.
Results in a single element af::array.
- Parameters
-
[out] out sum [in] in input array [in] nanval value that replaces NaNs
- Returns
- AF_SUCCESS, if function returns successfully, else an af_err code is given
◆ sum() [1/4]
| T sum | ( | const array & | in | ) |
C++ Interface to sum array elements over all dimensions.
Results in a single value as an output, which may be a single element af::array.
- Parameters
- Returns
- sum
◆ sum() [2/4]
C++ Interface to sum array elements over a given dimension, replacing any NaNs with a specified value.
- Parameters
-
[in] in input array [in] dim dimension along which the summation occurs [in] nanval value that replaces NaNs
- Returns
- sum
◆ sum() [3/4]
C++ Interface to sum array elements over a given dimension.
- Parameters
-
[in] in input array [in] dim dimension along which the summation occurs, -1 denotes the first non-singleton dimension
- Returns
- sum
- Examples
- pde/bhrt.cpp, and pde/boltzmann_cfd.cpp.