A high-performance general-purpose compute library

- Main Page
- Tutorials
- Release Notes
- Examples

Namespaces | Functions
algorithm.h File Reference
`#include <af/defines.h>`

Go to the source code of this file.

## Namespaces
namespace | af

## Functions
AFAPI array | sum (const array &in, const int dim=-1)
| C++ Interface to sum array elements over a given dimension.
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.
AFAPI void | sumByKey (array &keys_out, array &vals_out, const array &keys, const array &vals, const int dim=-1)
| C++ Interface to sum array elements over a given dimension, according to an array of keys.
AFAPI void | sumByKey (array &keys_out, array &vals_out, const array &keys, const array &vals, const int dim, const double nanval)
| C++ Interface to sum array elements over a given dimension, replacing any NaNs with a specified value, according to an array of keys.
AFAPI array | product (const array &in, const int dim=-1)
| C++ Interface to multiply array elements over a given dimension.
AFAPI array | product (const array &in, const int dim, const double nanval)
| C++ Interface to multiply array elements over a given dimension, replacing any NaNs with a specified value.
AFAPI void | productByKey (array &keys_out, array &vals_out, const array &keys, const array &vals, const int dim=-1)
| C++ Interface to multiply array elements over a given dimension, according to an array of keys.
AFAPI void | productByKey (array &keys_out, array &vals_out, const array &keys, const array &vals, const int dim, const double nanval)
| C++ Interface to multiply array elements over a given dimension, replacing any NaNs with a specified value, according to an array of keys.
AFAPI array | min (const array &in, const int dim=-1)
| C++ Interface to return the minimum along a given dimension.
AFAPI void | minByKey (array &keys_out, array &vals_out, const array &keys, const array &vals, const int dim=-1)
| C++ Interface to return the minimum along a given dimension, according to an array of keys.
AFAPI array | max (const array &in, const int dim=-1)
| C++ Interface to return the maximum along a given dimension.
AFAPI void | maxByKey (array &keys_out, array &vals_out, const array &keys, const array &vals, const int dim=-1)
| C++ Interface to return the maximum along a given dimension, according to an array of keys.
AFAPI void | max (array &val, array &idx, const array &in, const array &ragged_len, const int dim)
| C++ Interface to return the ragged maximum along a given dimension.
AFAPI array | allTrue (const array &in, const int dim=-1)
| C++ Interface to check if all values along a given dimension are true.
AFAPI void | allTrueByKey (array &keys_out, array &vals_out, const array &keys, const array &vals, const int dim=-1)
| C++ Interface to check if all values along a given dimension are true, according to an array of keys.
AFAPI array | anyTrue (const array &in, const int dim=-1)
| C++ Interface to check if any values along a given dimension are true.
AFAPI void | anyTrueByKey (array &keys_out, array &vals_out, const array &keys, const array &vals, const int dim=-1)
| C++ Interface to check if any values along a given dimension are true, according to an array of keys.
AFAPI array | count (const array &in, const int dim=-1)
| C++ Interface to count non-zero values in an array along a given dimension.
AFAPI void | countByKey (array &keys_out, array &vals_out, const array &keys, const array &vals, const int dim=-1)
| C++ Interface to count non-zero values in an array, according to an array of keys.
template<typename T >
T | sum (const array &in)
| C++ Interface to sum array elements over all dimensions.
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.
template<typename T >
T | product (const array &in)
| C++ Interface to multiply array elements over the first non-singleton dimension.
template<typename T >
T | product (const array &in, double nanval)
| C++ Interface to multiply array elements over the first non-singleton dimension, replacing any NaNs with a specified value.
template<typename T >
T | min (const array &in)
| C++ Interface to return the minimum along the first non-singleton dimension.
template<typename T >
T | max (const array &in)
| C++ Interface to return the maximum along the first non-singleton dimension.
template<typename T >
T | allTrue (const array &in)
| C++ Interface to check if all values along the first non-singleton dimension are true.
template<typename T >
T | anyTrue (const array &in)
| C++ Interface to check if any values along the first non-singleton dimension are true.
template<typename T >
T | count (const array &in)
| C++ Interface to count non-zero values along the first non-singleton dimension.
AFAPI void | min (array &val, array &idx, const array &in, const int dim=-1)
| C++ Interface to return the minimum and its location along a given dimension.
AFAPI void | max (array &val, array &idx, const array &in, const int dim=-1)
| C++ Interface to return the maximum and its location along a given dimension.
template<typename T >
void | min (T *val, unsigned *idx, const array &in)
| C++ Interface to return the minimum and its location over all dimensions.
template<typename T >
void | max (T *val, unsigned *idx, const array &in)
| C++ Interface to return the maximum and its location over all dimensions.
AFAPI array | accum (const array &in, const int dim=0)
| C++ Interface to evaluate the cumulative sum (inclusive) along a given dimension.
AFAPI array | scan (const array &in, const int dim=0, binaryOp op=AF_BINARY_ADD, bool inclusive_scan=true)
| C++ Interface to scan an array (generalized) over a given dimension.
AFAPI array | scanByKey (const array &key, const array &in, const int dim=0, binaryOp op=AF_BINARY_ADD, bool inclusive_scan=true)
| C++ Interface to scan an array (generalized) over a given dimension, according to an array of keys.
AFAPI array | where (const array &in)
| C++ Interface to locate the indices of the non-zero values in an array.
AFAPI array | diff1 (const array &in, const int dim=0)
| C++ Interface to calculate the first order difference in an array over a given dimension.
AFAPI array | diff2 (const array &in, const int dim=0)
| C++ Interface to calculate the second order difference in an array over a given dimension.
AFAPI array | sort (const array &in, const unsigned dim=0, const bool isAscending=true)
| C++ Interface to sort an array over a given dimension.
AFAPI void | sort (array &out, array &indices, const array &in, const unsigned dim=0, const bool isAscending=true)
| C++ Interface to sort an array over a given dimension and to return the original indices.
AFAPI void | sort (array &out_keys, array &out_values, const array &keys, const array &values, const unsigned dim=0, const bool isAscending=true)
| C++ Interface to sort an array over a given dimension, according to an array of keys.
AFAPI array | setUnique (const array &in, const bool is_sorted=false)
| C++ Interface to return the unique values in an array.
AFAPI array | setUnion (const array &first, const array &second, const bool is_unique=false)
| C++ Interface to evaluate the union of two arrays.
AFAPI array | setIntersect (const array &first, const array &second, const bool is_unique=false)
| C++ Interface to evaluate the intersection of two arrays.
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.
AFAPI af_err | af_sum_all_array (af_array *out, const af_array in)
| C Interface to sum array elements over all dimensions.
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.
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.
AFAPI af_err | af_sum_by_key (af_array *keys_out, af_array *vals_out, const af_array keys, const af_array vals, const int dim)
| C Interface to sum array elements over a given dimension, according to an array of keys.
AFAPI af_err | af_sum_by_key_nan (af_array *keys_out, af_array *vals_out, const af_array keys, const af_array vals, const int dim, const double nanval)
| C Interface to sum array elements over a given dimension, replacing any NaNs with a specified value, according to an array of keys.
AFAPI af_err | af_product (af_array *out, const af_array in, const int dim)
| C Interface to multiply array elements over a given dimension.
AFAPI af_err | af_product_all_array (af_array *out, const af_array in)
| C Interface to multiply array elements over all dimensions.
AFAPI af_err | af_product_nan (af_array *out, const af_array in, const int dim, const double nanval)
| C Interface to multiply array elements over a given dimension, replacing any NaNs with a specified value.
AFAPI af_err | af_product_nan_all_array (af_array *out, const af_array in, const double nanval)
| C Interface to multiply array elements over all dimensions, replacing any NaNs with a specified value.
AFAPI af_err | af_product_by_key (af_array *keys_out, af_array *vals_out, const af_array keys, const af_array vals, const int dim)
| C Interface to multiply array elements over a given dimension, according to an array of keys.
AFAPI af_err | af_product_by_key_nan (af_array *keys_out, af_array *vals_out, const af_array keys, const af_array vals, const int dim, const double nanval)
| C Interface to multiply array elements over a given dimension, replacing any NaNs with a specified value, according to an array of keys.
AFAPI af_err | af_min (af_array *out, const af_array in, const int dim)
| C Interface to return the minimum along a given dimension.
AFAPI af_err | af_min_by_key (af_array *keys_out, af_array *vals_out, const af_array keys, const af_array vals, const int dim)
| C Interface to return the minimum along a given dimension, according to an array of keys.
AFAPI af_err | af_max (af_array *out, const af_array in, const int dim)
| C Interface to return the maximum along a given dimension.
AFAPI af_err | af_max_by_key (af_array *keys_out, af_array *vals_out, const af_array keys, const af_array vals, const int dim)
| C Interface to return the maximum along a given dimension, according to an array of keys.
AFAPI af_err | af_max_ragged (af_array *val, af_array *idx, const af_array in, const af_array ragged_len, const int dim)
| C Interface to return the ragged maximum over a given dimension.
AFAPI af_err | af_all_true (af_array *out, const af_array in, const int dim)
| C Interface to check if all values along a given dimension are true.
AFAPI af_err | af_all_true_by_key (af_array *keys_out, af_array *vals_out, const af_array keys, const af_array vals, const int dim)
| C Interface to check if all values along a given dimension are true, according to an array of keys.
AFAPI af_err | af_any_true (af_array *out, const af_array in, const int dim)
| C Interface to check if any values along a given dimension are true.
AFAPI af_err | af_any_true_by_key (af_array *keys_out, af_array *vals_out, const af_array keys, const af_array vals, const int dim)
| C Interface to check if any values along a given dimension are true.
AFAPI af_err | af_count (af_array *out, const af_array in, const int dim)
| C Interface to count non-zero values in an array along a given dimension.
AFAPI af_err | af_count_by_key (af_array *keys_out, af_array *vals_out, const af_array keys, const af_array vals, const int dim)
| C Interface to count non-zero values in an array, according to an array of keys.
AFAPI af_err | af_sum_all (double *real, double *imag, const af_array in)
| C Interface to sum array elements over all dimensions.
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.
AFAPI af_err | af_product_all (double *real, double *imag, const af_array in)
| C Interface to multiply array elements over all dimensions.
AFAPI af_err | af_product_nan_all (double *real, double *imag, const af_array in, const double nanval)
| C Interface to multiply array elements over all dimensions, replacing any NaNs with a specified value.
AFAPI af_err | af_min_all (double *real, double *imag, const af_array in)
| C Interface to return the minimum over all dimensions.
AFAPI af_err | af_min_all_array (af_array *out, const af_array in)
| C Interface to return the minimum over all dimensions.
AFAPI af_err | af_max_all (double *real, double *imag, const af_array in)
| C Interface to return the maximum over all dimensions.
AFAPI af_err | af_max_all_array (af_array *out, const af_array in)
| C Interface to return the maximum over all dimensions.
AFAPI af_err | af_all_true_all (double *real, double *imag, const af_array in)
| C Interface to check if all values over all dimensions are true.
AFAPI af_err | af_all_true_all_array (af_array *out, const af_array in)
| C Interface to check if all values over all dimensions are true.
AFAPI af_err | af_any_true_all (double *real, double *imag, const af_array in)
| C Interface to check if any values over all dimensions are true.
AFAPI af_err | af_any_true_all_array (af_array *out, const af_array in)
| C Interface to check if any values over all dimensions are true.
AFAPI af_err | af_count_all (double *real, double *imag, const af_array in)
| C Interface to count non-zero values over all dimensions.
AFAPI af_err | af_count_all_array (af_array *out, const af_array in)
| C Interface to count non-zero values over all dimensions.
AFAPI af_err | af_imin (af_array *out, af_array *idx, const af_array in, const int dim)
| C Interface to return the minimum and its location along a given dimension.
AFAPI af_err | af_imax (af_array *out, af_array *idx, const af_array in, const int dim)
| C Interface to return the maximum and its location along a given dimension.
AFAPI af_err | af_imin_all (double *real, double *imag, unsigned *idx, const af_array in)
| C Interface to return the minimum and its location over all dimensions.
AFAPI af_err | af_imax_all (double *real, double *imag, unsigned *idx, const af_array in)
| C Interface to return the maximum and its location over all dimensions.
AFAPI af_err | af_accum (af_array *out, const af_array in, const int dim)
| C Interface to evaluate the cumulative sum (inclusive) along a given dimension.
AFAPI af_err | af_scan (af_array *out, const af_array in, const int dim, af_binary_op op, bool inclusive_scan)
| C Interface to scan an array (generalized) over a given dimension.
AFAPI af_err | af_scan_by_key (af_array *out, const af_array key, const af_array in, const int dim, af_binary_op op, bool inclusive_scan)
| C Interface to scan an array (generalized) over a given dimension, according to an array of keys.
AFAPI af_err | af_where (af_array *idx, const af_array in)
| C Interface to locate the indices of the non-zero values in an array.
AFAPI af_err | af_diff1 (af_array *out, const af_array in, const int dim)
| C Interface to calculate the first order difference in an array over a given dimension.
AFAPI af_err | af_diff2 (af_array *out, const af_array in, const int dim)
| C Interface to calculate the second order difference in an array over a given dimension.
AFAPI af_err | af_sort (af_array *out, const af_array in, const unsigned dim, const bool isAscending)
| C Interface to sort an array over a given dimension.
AFAPI af_err | af_sort_index (af_array *out, af_array *indices, const af_array in, const unsigned dim, const bool isAscending)
| C Interface to sort an array over a given dimension and to return the original indices.
AFAPI af_err | af_sort_by_key (af_array *out_keys, af_array *out_values, const af_array keys, const af_array values, const unsigned dim, const bool isAscending)
| C Interface to sort an array over a given dimension, according to an array of keys.
AFAPI af_err | af_set_unique (af_array *out, const af_array in, const bool is_sorted)
| C Interface to return the unique values in an array.
AFAPI af_err | af_set_union (af_array *out, const af_array first, const af_array second, const bool is_unique)
| C Interface to evaluate the union of two arrays.
AFAPI af_err | af_set_intersect (af_array *out, const af_array first, const af_array second, const bool is_unique)
| C Interface to evaluate the intersection of two arrays.

## Function Documentation

## ◆ af_all_true_by_key()

AFAPI af_err af_all_true_by_key | ( | af_array * | keys_out,
|  | af_array * | vals_out,
|  | const af_array | keys,
|  | const af_array | vals,
|  | const int | dim )

C Interface to check if all values along a given dimension are true, according to an array of keys.

NaN values are ignored.

Parameters

  [out] | keys_out | reduced keys
  [out] | vals_out | array containing 1's if all true; 0's otherwise
  [in] | keys | keys array
  [in] | vals | input array
  [in] | dim | dimension along which the check occurs

Returns
  AF_SUCCESS, if function returns successfully, else an af_err code is given