forked from arrayfire/arrayfire-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray.cpp
More file actions
43 lines (33 loc) · 1 KB
/
array.cpp
File metadata and controls
43 lines (33 loc) · 1 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
#include "jni_helper.h"
BEGIN_EXTERN_C
#define ARRAY_FUNC(FUNC) AF_MANGLE(Array, FUNC)
JNIEXPORT void JNICALL ARRAY_FUNC(destroyArray)(JNIEnv *env, jclass clazz, jlong ref)
{
AF_TO_JAVA(af_release_array(ARRAY(ref)));
}
JNIEXPORT jintArray JNICALL ARRAY_FUNC(getDims)(JNIEnv *env, jclass clazz, jlong ref)
{
jintArray result = env->NewIntArray(MaxDimSupported);
if (result == NULL) {
return NULL;
}
dim_t dims[4];
AF_TO_JAVA(af_get_dims(dims + 0,
dims + 1,
dims + 2,
dims + 3,
ARRAY(ref)));
jint* dimsf = env->GetIntArrayElements(result, 0);
for(int k=0; k<MaxDimSupported; ++k) {
dimsf[k] = dims[k];
}
env->ReleaseIntArrayElements(result, dimsf, 0);
return result;
}
JNIEXPORT jint JNICALL ARRAY_FUNC(getType)(JNIEnv *env, jclass clazz, jlong ref)
{
af_dtype ty = f32;
AF_TO_JAVA(af_get_type(&ty, ARRAY(ref)));
return ty;
}
END_EXTERN_C