-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathindex.cpp
30 lines (23 loc) · 1.01 KB
/
index.cpp
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
#include "jni_helper.h"
BEGIN_EXTERN_C
#define INDEX_FUNC(FUNC) AF_MANGLE(Index, FUNC)
JNIEXPORT jlong JNICALL INDEX_FUNC(afLookup)(JNIEnv *env, jclass clazz, jlong in,
jlong index, int dim) {
af_array ret = 0;
AF_CHECK(af_lookup(&ret, ARRAY(in), ARRAY(index), dim));
return JLONG(ret);
}
JNIEXPORT void JNICALL INDEX_FUNC(afCopy)(JNIEnv *env, jclass clazz,
jlong dst ,jlong src,
jint ndims,
jobject idx0,
jobject idx1, jobject idx2,
jobject idx3, int dim) {
af_index_t indices[] {java::jIndexToCIndex(env, idx0),
java::jIndexToCIndex(env, idx1),
java::jIndexToCIndex(env, idx2),
java::jIndexToCIndex(env, idx3)};
af_array lhs = ARRAY(dst);
AF_CHECK_VOID(af_assign_gen(&lhs, lhs, ndims, indices, ARRAY(src)));
}
END_EXTERN_C