Skip to content

Commit a715399

Browse files
ShadyBoukharyumar456
authored andcommitted
Created Array.print() that wraps af_print_array.
1 parent 5ff457b commit a715399

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

com/arrayfire/Array.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public class Array extends ArrayFire implements AutoCloseable {
2929

3030
private native static long createArrayFromBoolean(int[] dims, boolean[] elems);
3131

32+
private native static void afPrint(long ref, String name);
33+
3234
// Global reference to JVM object
3335
// to persist between JNI calls
3436
protected long ref;
@@ -216,6 +218,10 @@ public boolean[] getBooleanArray() throws Exception {
216218
return Data.getBooleanArray(this);
217219
}
218220

221+
public void print(String name) {
222+
afPrint(ref, name);
223+
}
224+
219225
@Override
220226
public void close() throws Exception {
221227
if (ref != 0)

src/array.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ JNIEXPORT void JNICALL ARRAY_FUNC(destroyArray)(JNIEnv *env, jclass clazz,
99
AF_CHECK_VOID(af_release_array(ARRAY(ref)));
1010
}
1111

12+
JNIEXPORT void JNICALL ARRAY_FUNC(afPrint)(JNIEnv *env, jclass clazz, jlong ref,
13+
jstring name) {
14+
const char *str = env->GetStringUTFChars(name, 0);
15+
AF_CHECK_VOID(af_print_array_gen(str, ARRAY(ref), 3));
16+
env->ReleaseStringUTFChars(name, str);
17+
}
18+
1219
JNIEXPORT jintArray JNICALL ARRAY_FUNC(getDims)(JNIEnv *env, jclass clazz,
1320
jlong ref) {
1421
jintArray result = env->NewIntArray(MaxDimSupported);

0 commit comments

Comments
 (0)