algorithm.h Source File

- Main Page
- Tutorials
- Functions
- Release Notes
- Examples

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
31 #if AF_API_VERSION >= 31
32
43 AFAPI array sum(const array &in, const int dim, const double nanval);
44 #endif
45
57 AFAPI array product(const array &in, const int dim = -1);
58
59 #if AF_API_VERSION >= 31
60
71 AFAPI array product(const array &in, const int dim, const double nanval);
72 #endif
73
86 AFAPI array min(const array &in, const int dim = -1);
87
100 AFAPI array max(const array &in, const int dim = -1);
101
114 AFAPI array allTrue(const array &in, const int dim = -1);
115
128 AFAPI array anyTrue(const array &in, const int dim = -1);
129
142 AFAPI array count(const array &in, const int dim = -1);
143
152 template<typename T> T sum(const array &in);
153
154 #if AF_API_VERSION >= 31
155
164 template<typename T> T sum(const array &in, double nanval);
165 #endif
166
175 template<typename T> T product(const array &in);
176
177 #if AF_API_VERSION >= 31
178
187 template<typename T> T product(const array &in, double nanval);
188 #endif
189
200 template<typename T> T min(const array &in);
201
212 template<typename T> T max(const array &in);
213
224 template<typename T> T allTrue(const array &in);
225
236 template<typename T> T anyTrue(const array &in);
237
248 template<typename T> T count(const array &in);
249
264 AFAPI void min(array &val, array &idx, const array &in, const int dim = -1);
265
280 AFAPI void max(array &val, array &idx, const array &in, const int dim = -1);
281
293 template<typename T> void min(T *val, unsigned *idx, const array &in);
294
306 template<typename T> void max(T *val, unsigned *idx, const array &in);
307
317 AFAPI array accum(const array &in, const int dim = 0);
318
327 AFAPI array where(const array &in);
328
338 AFAPI array diff1(const array &in, const int dim = 0);
339
349 AFAPI array diff2(const array &in, const int dim = 0);
350
363 AFAPI array sort(const array &in, const unsigned dim = 0, const bool isAscending = true);
364
378 AFAPI void sort(array &out, array &indices, const array &in, const unsigned dim = 0,
379 const bool isAscending = true);
394 AFAPI void sort(array &out_keys, array &out_values, const array &keys, const array &values,
395 const unsigned dim = 0, const bool isAscending = true);
396
406 AFAPI array setUnique(const array &in, const bool is_sorted=false);
407
418 AFAPI array setUnion(const array &first, const array &second, const bool is_unique=false);
419
430 AFAPI array setIntersect(const array &first, const array &second, const bool is_unique=false);
431 }
432 #endif
433
434 #ifdef __cplusplus
435 extern "C" {
436 #endif
437
448 AFAPI af_err af_sum(af_array *out, const af_array in, const int dim);
449
450 #if AF_API_VERSION >= 31
451
462 AFAPI af_err af_sum_nan(af_array *out, const af_array in, const int dim, const double nanval);
463 #endif
464
475 AFAPI af_err af_product(af_array *out, const af_array in, const int dim);
476
477 #if AF_API_VERSION >= 31
478
489 AFAPI af_err af_product_nan(af_array *out, const af_array in, const int dim, const double nanval);
490 #endif
491
502 AFAPI af_err af_min(af_array *out, const af_array in, const int dim);
503
514 AFAPI af_err af_max(af_array *out, const af_array in, const int dim);
515
526 AFAPI af_err af_all_true(af_array *out, const af_array in, const int dim);
527
538 AFAPI af_err af_any_true(af_array *out, const af_array in, const int dim);
539
550 AFAPI af_err af_count(af_array *out, const af_array in, const int dim);
551
564 AFAPI af_err af_sum_all(double *real, double *imag, const af_array in);
565
566 #if AF_API_VERSION >= 31
567
580 AFAPI af_err af_sum_nan_all(double *real, double *imag, const af_array in, const double nanval);
581 #endif
582
595 AFAPI af_err af_product_all(double *real, double *imag, const af_array in);
596
597 #if AF_API_VERSION >= 31
598
611 AFAPI af_err af_product_nan_all(double *real, double *imag, const af_array in, const double nanval);
612 #endif
613
626 AFAPI af_err af_min_all(double *real, double *imag, const af_array in);
627
640 AFAPI af_err af_max_all(double *real, double *imag, const af_array in);
641
654 AFAPI af_err af_all_true_all(double *real, double *imag, const af_array in);
655
668 AFAPI af_err af_any_true_all(double *real, double *imag, const af_array in);
669
682 AFAPI af_err af_count_all(double *real, double *imag, const af_array in);
683
695 AFAPI af_err af_imin(af_array *out, af_array *idx, const af_array in, const int dim);
696
708 AFAPI af_err af_imax(af_array *out, af_array *idx, const af_array in, const int dim);
709
723 AFAPI af_err af_imin_all(double *real, double *imag, unsigned *idx, const af_array in);
724
738 AFAPI af_err af_imax_all(double *real, double *imag, unsigned *idx, const af_array in);
739
750 AFAPI af_err af_accum(af_array *out, const af_array in, const int dim);
751
761 AFAPI af_err af_where(af_array *idx, const af_array in);
762
773 AFAPI af_err af_diff1(af_array *out, const af_array in, const int dim);
774
785 AFAPI af_err af_diff2(af_array *out, const af_array in, const int dim);
786
800 AFAPI af_err af_sort(af_array *out, const af_array in, const unsigned dim, const bool isAscending);
801
816 AFAPI af_err af_sort_index(af_array *out, af_array *indices, const af_array in,
817 const unsigned dim, const bool isAscending);
833 AFAPI af_err af_sort_by_key(af_array *out_keys, af_array *out_values,
834 const af_array keys, const af_array values,
835 const unsigned dim, const bool isAscending);
836
847 AFAPI af_err af_set_unique(af_array *out, const af_array in, const bool is_sorted);
848
860 AFAPI af_err af_set_union(af_array *out, const af_array first, const af_array second, const bool is_unique);
861
873 AFAPI af_err af_set_intersect(af_array *out, const af_array first, const af_array second, const bool is_unique);
874
875 #ifdef __cplusplus
876 }
877 #endif
af
Definition: algorithm.h:14
af::where
AFAPI array where(const array &in)
C++ Interface for finding the locations of non-zero values in an array.
af_imin_all
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.
af_set_union
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.
af_count_all
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.
af_sum_nan
AFAPI af_err af_sum_nan(af_array *out, const af_array in, const int dim, const double nanval)
C Interface for sum of elements in an array while replacing nans.
af_any_true_all
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.
af_product_all
AFAPI af_err af_product_all(double *real, double *imag, const af_array in)
C Interface for product of all elements in an array.
af_where
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.
af_set_unique
AFAPI af_err af_set_unique(af_array *out, const af_array in, const bool is_sorted)
C Interface for getting unique values.
af::sum
AFAPI array sum(const array &in, const int dim=-1)
C++ Interface for sum of elements in an array.
af_accum
AFAPI af_err af_accum(af_array *out, const af_array in, const int dim)
C Interface exclusive sum (cumulative sum) of an array.
af_imax_all
AFAPI af_err af_imax_all(double *real, double *imag, unsigned *idx, const af_array in)
C Interface for getting maximum value and it&#39;s location from the entire array.
af_sort_index
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.
af::allTrue
AFAPI array allTrue(const array &in, const int dim=-1)
C++ Interface for checking all true values in an array.
af::array
A multi dimensional data container.
Definition: array.h:27
af_count
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.
af_max
AFAPI af_err af_max(af_array *out, const af_array in, const int dim)
C Interface for maximum values in an array.
af_min_all
AFAPI af_err af_min_all(double *real, double *imag, const af_array in)
C Interface for getting minimum value of an array.
af_sum_nan_all
AFAPI af_err af_sum_nan_all(double *real, double *imag, const af_array in, const double nanval)
C Interface for sum of all elements in an array while replacing nans.
af_err
af_err
Definition: defines.h:67
defines.h
af_product
AFAPI af_err af_product(af_array *out, const af_array in, const int dim)
C Interface for product of elements in an array.
af_imin
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.
af_any_true
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.
af::max
AFAPI array max(const array &in, const int dim=-1)
C++ Interface for maximum values in an array.
af_diff2
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.
af::imag
AFAPI array imag(const array &in)
C++ Interface for getting imaginary part from complex array.
af::product
AFAPI array product(const array &in, const int dim=-1)
C++ Interface for product of elements in an array.
af_set_intersect
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.
af_diff1
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.
af_min
AFAPI af_err af_min(af_array *out, const af_array in, const int dim)
C Interface for minimum values in an array.
af::real
AFAPI array real(const array &in)
C++ Interface for getting real part from complex array.
af_imax
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.
AFAPI
#define AFAPI
Definition: defines.h:31
af::setIntersect
AFAPI array setIntersect(const array &first, const array &second, const bool is_unique=false)
C++ Interface for performing intersect of two arrays.
af::anyTrue
AFAPI array anyTrue(const array &in, const int dim=-1)
C++ Interface for checking any true values in an array.
af::setUnique
AFAPI array setUnique(const array &in, const bool is_sorted=false)
C++ Interface for getting unique values.
af::accum
AFAPI array accum(const array &in, const int dim=0)
C++ Interface exclusive sum (cumulative sum) of an array.
af_product_nan
AFAPI af_err af_product_nan(af_array *out, const af_array in, const int dim, const double nanval)
C Interface for product of elements in an array while replacing nans.
af_sort
AFAPI af_err af_sort(af_array *out, const af_array in, const unsigned dim, const bool isAscending)
C Interface for sorting an array.
af_sort_by_key
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.
af_array
void * af_array
Definition: defines.h:226
af::min
AFAPI array min(const array &in, const int dim=-1)
C++ Interface for minimum values in an array.
af_sum
AFAPI af_err af_sum(af_array *out, const af_array in, const int dim)
C Interface for sum of elements in an array.
af_sum_all
AFAPI af_err af_sum_all(double *real, double *imag, const af_array in)
C Interface for sum of all elements in an array.
af::sort
AFAPI array sort(const array &in, const unsigned dim=0, const bool isAscending=true)
C++ Interface for sorting an array.
af_all_true_all
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.
af_product_nan_all
AFAPI af_err af_product_nan_all(double *real, double *imag, const af_array in, const double nanval)
C Interface for product of all elements in an array while replacing nans.
af::count
AFAPI array count(const array &in, const int dim=-1)
C++ Interface for counting non-zero values in an array.
af::setUnion
AFAPI array setUnion(const array &first, const array &second, const bool is_unique=false)
C++ Interface for performing union of two arrays.
af::diff1
AFAPI array diff1(const array &in, const int dim=0)
C++ Interface for calculating first order differences in an array.
af_all_true
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.
af_max_all
AFAPI af_err af_max_all(double *real, double *imag, const af_array in)
C Interface for getting maximum value of an array.
af::diff2
AFAPI array diff2(const array &in, const int dim=0)
C++ Interface for calculating second order differences in an array.