algorithm.h
Go to the documentation of this file.
1 /*******************************************************
2  * Copyright (c) 2014, ArrayFire
3  * All rights reserved.
4  *
5  * This file is distributed under 3-clause BSD license.
6  * The complete license agreement can be obtained at:
7  * http://arrayfire.com/licenses/BSD-3-Clause
8  ********************************************************/
9 
10 #pragma once
11 #include <af/defines.h>
12 
13 #ifdef __cplusplus
14 namespace af
15 {
16  class array;
17 
29  AFAPI array sum(const array &in, const int dim = -1);
30 
42  AFAPI array product(const array &in, const int dim = -1);
43 
55  AFAPI array min(const array &in, const int dim = -1);
56 
68  AFAPI array max(const array &in, const int dim = -1);
69 
81  AFAPI array allTrue(const array &in, const int dim = -1);
82 
94  AFAPI array anyTrue(const array &in, const int dim = -1);
95 
107  AFAPI array count(const array &in, const int dim = -1);
108 
117  template<typename T> T sum(const array &in);
118 
127  template<typename T> T product(const array &in);
128 
137  template<typename T> T min(const array &in);
138 
147  template<typename T> T max(const array &in);
148 
157  template<typename T> T allTrue(const array &in);
158 
167  template<typename T> T anyTrue(const array &in);
168 
177  template<typename T> T count(const array &in);
178 
191  AFAPI void min(array &val, array &idx, const array &in, const int dim = -1);
192 
205  AFAPI void max(array &val, array &idx, const array &in, const int dim = -1);
206 
216  template<typename T> void min(T *val, unsigned *idx, const array &in);
217 
227  template<typename T> void max(T *val, unsigned *idx, const array &in);
228 
238  AFAPI array accum(const array &in, const int dim = 0);
239 
248  AFAPI array where(const array &in);
249 
259  AFAPI array diff1(const array &in, const int dim = 0);
260 
270  AFAPI array diff2(const array &in, const int dim = 0);
271 
284  AFAPI array sort(const array &in, const unsigned dim = 0, const bool isAscending = true);
285 
299  AFAPI void sort(array &out, array &indices, const array &in, const unsigned dim = 0,
300  const bool isAscending = true);
315  AFAPI void sort(array &out_keys, array &out_values, const array &keys, const array &values,
316  const unsigned dim = 0, const bool isAscending = true);
317 
327  AFAPI array setUnique(const array &in, const bool is_sorted=false);
328 
339  AFAPI array setUnion(const array &first, const array &second, const bool is_unique=false);
340 
351  AFAPI array setIntersect(const array &first, const array &second, const bool is_unique=false);
352 }
353 #endif
354 
355 #ifdef __cplusplus
356 extern "C" {
357 #endif
358 
369  AFAPI af_err af_sum(af_array *out, const af_array in, const int dim);
370 
381  AFAPI af_err af_product(af_array *out, const af_array in, const int dim);
382 
393  AFAPI af_err af_min(af_array *out, const af_array in, const int dim);
394 
405  AFAPI af_err af_max(af_array *out, const af_array in, const int dim);
406 
417  AFAPI af_err af_all_true(af_array *out, const af_array in, const int dim);
418 
429  AFAPI af_err af_any_true(af_array *out, const af_array in, const int dim);
430 
441  AFAPI af_err af_count(af_array *out, const af_array in, const int dim);
442 
455  AFAPI af_err af_sum_all(double *real, double *imag, const af_array in);
456 
469  AFAPI af_err af_product_all(double *real, double *imag, const af_array in);
470 
483  AFAPI af_err af_min_all(double *real, double *imag, const af_array in);
484 
497  AFAPI af_err af_max_all(double *real, double *imag, const af_array in);
498 
511  AFAPI af_err af_all_true_all(double *real, double *imag, const af_array in);
512 
525  AFAPI af_err af_any_true_all(double *real, double *imag, const af_array in);
526 
539  AFAPI af_err af_count_all(double *real, double *imag, const af_array in);
540 
552  AFAPI af_err af_imin(af_array *out, af_array *idx, const af_array in, const int dim);
553 
565  AFAPI af_err af_imax(af_array *out, af_array *idx, const af_array in, const int dim);
566 
580  AFAPI af_err af_imin_all(double *real, double *imag, unsigned *idx, const af_array in);
581 
595  AFAPI af_err af_imax_all(double *real, double *imag, unsigned *idx, const af_array in);
596 
607  AFAPI af_err af_accum(af_array *out, const af_array in, const int dim);
608 
618  AFAPI af_err af_where(af_array *idx, const af_array in);
619 
630  AFAPI af_err af_diff1(af_array *out, const af_array in, const int dim);
631 
642  AFAPI af_err af_diff2(af_array *out, const af_array in, const int dim);
643 
657  AFAPI af_err af_sort(af_array *out, const af_array in, const unsigned dim, const bool isAscending);
658 
673  AFAPI af_err af_sort_index(af_array *out, af_array *indices, const af_array in,
674  const unsigned dim, const bool isAscending);
690  AFAPI af_err af_sort_by_key(af_array *out_keys, af_array *out_values,
691  const af_array keys, const af_array values,
692  const unsigned dim, const bool isAscending);
693 
704  AFAPI af_err af_set_unique(af_array *out, const af_array in, const bool is_sorted);
705 
717  AFAPI af_err af_set_union(af_array *out, const af_array first, const af_array second, const bool is_unique);
718 
730  AFAPI af_err af_set_intersect(af_array *out, const af_array first, const af_array second, const bool is_unique);
731 
732 #ifdef __cplusplus
733 }
734 #endif
Definition: algorithm.h:14
AFAPI array where(const array &in)
C++ Interface for finding the locations of non-zero values in an array.
AFAPI af_err af_imin_all(double *real, double *imag, unsigned *idx, const af_array in)
C Interface for getting minimum value and its location from the entire array.
AFAPI af_err af_set_union(af_array *out, const af_array first, const af_array second, const bool is_unique)
C Interface for performing union of two arrays.
AFAPI af_err af_count_all(double *real, double *imag, const af_array in)
C Interface for counting total number of non-zero values in an array.
AFAPI af_err af_any_true_all(double *real, double *imag, const af_array in)
C Interface for checking if any values in an array are true.
AFAPI af_err af_product_all(double *real, double *imag, const af_array in)
C Interface for product of all elements in an array.
AFAPI af_err af_where(af_array *idx, const af_array in)
C Interface for finding the locations of non-zero values in an array.
AFAPI af_err af_set_unique(af_array *out, const af_array in, const bool is_sorted)
C Interface for getting unique values.
AFAPI array sum(const array &in, const int dim=-1)
C++ Interface for sum of elements in an array.
AFAPI af_err af_accum(af_array *out, const af_array in, const int dim)
C Interface exclusive sum (cumulative sum) of an array.
AFAPI af_err af_imax_all(double *real, double *imag, unsigned *idx, const af_array in)
C Interface for getting maximum value and it's location from the entire array.
AFAPI af_err af_sort_index(af_array *out, af_array *indices, const af_array in, const unsigned dim, const bool isAscending)
C Interface for sorting an array and getting original indices.
AFAPI array allTrue(const array &in, const int dim=-1)
C++ Interface for checking all true values in an array.
A multi dimensional data container.
Definition: array.h:27
AFAPI af_err af_count(af_array *out, const af_array in, const int dim)
C Interface for counting non-zero values in an array.
AFAPI af_err af_max(af_array *out, const af_array in, const int dim)
C Interface for maximum values in an array.
AFAPI af_err af_min_all(double *real, double *imag, const af_array in)
C Interface for getting minimum value of an array.
af_err
Definition: defines.h:58
AFAPI af_err af_product(af_array *out, const af_array in, const int dim)
C Interface for product of elements in an array.
AFAPI af_err af_imin(af_array *out, af_array *idx, const af_array in, const int dim)
C Interface for getting minimum values and their locations in an array.
AFAPI af_err af_any_true(af_array *out, const af_array in, const int dim)
C Interface for checking any true values in an array.
AFAPI array max(const array &in, const int dim=-1)
C++ Interface for maximum values in an array.
AFAPI af_err af_diff2(af_array *out, const af_array in, const int dim)
C Interface for calculating second order differences in an array.
AFAPI array imag(const array &in)
C++ Interface for getting imaginary part from complex array.
AFAPI array product(const array &in, const int dim=-1)
C++ Interface for product of elements in an array.
AFAPI af_err af_set_intersect(af_array *out, const af_array first, const af_array second, const bool is_unique)
C Interface for performing intersect of two arrays.
AFAPI af_err af_diff1(af_array *out, const af_array in, const int dim)
C Interface for calculating first order differences in an array.
AFAPI af_err af_min(af_array *out, const af_array in, const int dim)
C Interface for minimum values in an array.
AFAPI array real(const array &in)
C++ Interface for getting real part from complex array.
AFAPI af_err af_imax(af_array *out, af_array *idx, const af_array in, const int dim)
C Interface for getting maximum values and their locations in an array.
#define AFAPI
Definition: defines.h:31
AFAPI array setIntersect(const array &first, const array &second, const bool is_unique=false)
C++ Interface for performing intersect of two arrays.
AFAPI array anyTrue(const array &in, const int dim=-1)
C++ Interface for checking any true values in an array.
AFAPI array setUnique(const array &in, const bool is_sorted=false)
C++ Interface for getting unique values.
AFAPI array accum(const array &in, const int dim=0)
C++ Interface exclusive sum (cumulative sum) of an array.
AFAPI af_err af_sort(af_array *out, const af_array in, const unsigned dim, const bool isAscending)
C Interface for sorting an array.
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 for sorting an array based on keys.
void * af_array
Definition: defines.h:172
AFAPI array min(const array &in, const int dim=-1)
C++ Interface for minimum values in an array.
AFAPI af_err af_sum(af_array *out, const af_array in, const int dim)
C Interface for sum of elements in an array.
AFAPI af_err af_sum_all(double *real, double *imag, const af_array in)
C Interface for sum of all elements in an array.
AFAPI array sort(const array &in, const unsigned dim=0, const bool isAscending=true)
C++ Interface for sorting an array.
AFAPI af_err af_all_true_all(double *real, double *imag, const af_array in)
C Interface for checking if all values in an array are true.
AFAPI array count(const array &in, const int dim=-1)
C++ Interface for counting non-zero values in an array.
AFAPI array setUnion(const array &first, const array &second, const bool is_unique=false)
C++ Interface for performing union of two arrays.
AFAPI array diff1(const array &in, const int dim=0)
C++ Interface for calculating first order differences in an array.
AFAPI af_err af_all_true(af_array *out, const af_array in, const int dim)
C Interface for checking all true values in an array.
AFAPI af_err af_max_all(double *real, double *imag, const af_array in)
C Interface for getting maximum value of an array.
AFAPI array diff2(const array &in, const int dim=0)
C++ Interface for calculating second order differences in an array.