forked from hunter-packages/arrayfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalgorithm.cpp
More file actions
148 lines (120 loc) · 3.64 KB
/
algorithm.cpp
File metadata and controls
148 lines (120 loc) · 3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*******************************************************
* Copyright (c) 2015, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
********************************************************/
#include <af/array.h>
#include <af/algorithm.h>
#include "symbol_manager.hpp"
#define ALGO_HAPI_DEF(af_func) \
af_err af_func(af_array* out, const af_array in, const int dim) \
{ \
CHECK_ARRAYS(in); \
return CALL(out, in, dim); \
}
ALGO_HAPI_DEF(af_sum)
ALGO_HAPI_DEF(af_product)
ALGO_HAPI_DEF(af_min)
ALGO_HAPI_DEF(af_max)
ALGO_HAPI_DEF(af_all_true)
ALGO_HAPI_DEF(af_any_true)
ALGO_HAPI_DEF(af_count)
ALGO_HAPI_DEF(af_accum)
ALGO_HAPI_DEF(af_diff1)
ALGO_HAPI_DEF(af_diff2)
#undef ALGO_HAPI_DEF
#define ALGO_HAPI_DEF(af_func_nan) \
af_err af_func_nan(af_array* out, const af_array in, const int dim, const double nanval) \
{ \
CHECK_ARRAYS(in); \
return CALL(out, in, dim, nanval); \
}
ALGO_HAPI_DEF(af_sum_nan)
ALGO_HAPI_DEF(af_product_nan)
#undef ALGO_HAPI_DEF
#define ALGO_HAPI_DEF(af_func_all) \
af_err af_func_all(double *real, double *imag, const af_array in) \
{ \
CHECK_ARRAYS(in); \
return CALL(real, imag, in);\
}
ALGO_HAPI_DEF(af_sum_all)
ALGO_HAPI_DEF(af_product_all)
ALGO_HAPI_DEF(af_min_all)
ALGO_HAPI_DEF(af_max_all)
ALGO_HAPI_DEF(af_all_true_all)
ALGO_HAPI_DEF(af_any_true_all)
ALGO_HAPI_DEF(af_count_all)
#undef ALGO_HAPI_DEF
#define ALGO_HAPI_DEF(af_func_nan_all) \
af_err af_func_nan_all(double *real, double *imag, const af_array in, const double nanval) \
{ \
CHECK_ARRAYS(in); \
return CALL(real, imag, in, nanval);\
}
ALGO_HAPI_DEF(af_sum_nan_all)
ALGO_HAPI_DEF(af_product_nan_all)
#undef ALGO_HAPI_DEF
#define ALGO_HAPI_DEF(af_ifunc) \
af_err af_ifunc(af_array* out, af_array *idx, const af_array in, const int dim) \
{ \
CHECK_ARRAYS(in); \
return CALL(out, idx, in, dim); \
}
ALGO_HAPI_DEF(af_imin)
ALGO_HAPI_DEF(af_imax)
#undef ALGO_HAPI_DEF
#define ALGO_HAPI_DEF(af_ifunc_all) \
af_err af_ifunc_all(double *real, double *imag, unsigned *idx, const af_array in) \
{ \
CHECK_ARRAYS(in); \
return CALL(real, imag, idx, in);\
}
ALGO_HAPI_DEF(af_imin_all)
ALGO_HAPI_DEF(af_imax_all)
#undef ALGO_HAPI_DEF
af_err af_where(af_array *idx, const af_array in)
{
CHECK_ARRAYS(in);
return CALL(idx, in);
}
af_err af_sort(af_array *out, const af_array in, const unsigned dim, const bool isAscending)
{
CHECK_ARRAYS(in);
return CALL(out, in, dim, isAscending);
}
af_err af_sort_index(af_array *out, af_array *indices, const af_array in,
const unsigned dim, const bool isAscending)
{
CHECK_ARRAYS(in);
return CALL(out, indices, in, dim, isAscending);
}
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)
{
CHECK_ARRAYS(keys, values);
return CALL(out_keys, out_values, keys, values, dim, isAscending);
}
af_err af_set_unique(af_array *out, const af_array in, const bool is_sorted)
{
CHECK_ARRAYS(in);
return CALL(out, in, is_sorted);
}
af_err af_set_union(af_array *out,
const af_array first, const af_array second,
const bool is_unique)
{
CHECK_ARRAYS(first, second);
return CALL(out, first, second, is_unique);
}
af_err af_set_intersect(af_array *out,
const af_array first, const af_array second,
const bool is_unique)
{
CHECK_ARRAYS(first, second);
return CALL(out, first, second, is_unique);
}