forked from arrayfire/arrayfire-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalgorithm.cpp
More file actions
34 lines (27 loc) · 1.07 KB
/
algorithm.cpp
File metadata and controls
34 lines (27 loc) · 1.07 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
#include "jni_helper.h"
BEGIN_EXTERN_C
#define ALGO_FUNC(FUNC) AF_MANGLE(Algorithm, FUNC)
#define SCALAR_RET_OP_DEF(func) \
JNIEXPORT jdouble JNICALL ALGO_FUNC(func##All) \
(JNIEnv *env, jclass clazz, jlong a) \
{ \
double real, imag; \
(af_##func##_all(&real, &imag, \
ARRAY(a))); \
return real; \
}
SCALAR_RET_OP_DEF(sum)
SCALAR_RET_OP_DEF(max)
SCALAR_RET_OP_DEF(min)
#define ARRAY_RET_OP_DEF(func) \
JNIEXPORT jlong JNICALL ALGO_FUNC(func) \
(JNIEnv *env, jclass clazz, jlong a, jint dim) \
{ \
af_array ret = 0; \
(af_##func(&ret, ARRAY(a), dim)); \
return JLONG(ret); \
}
ARRAY_RET_OP_DEF(sum)
ARRAY_RET_OP_DEF(max)
ARRAY_RET_OP_DEF(min)
END_EXTERN_C