Last active
September 3, 2015 09:07
-
-
Save umjammer/9800365 to your computer and use it in GitHub Desktop.
create 3d array in JNI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create the class | |
jclass floatClass1 = env->FindClass("[[F"); | |
jclass floatClass2 = env->FindClass("[F"); | |
// Create 1st and 2nd array | |
jobjectArray array1 = env->NewObjectArray(15, floatClass1, NULL); | |
for (int i = 0; i < 15; i++) { | |
jobjectArray array2 = env->NewObjectArray(16, floatClass2, NULL); | |
for (int j = 0; j < 16; j++) { | |
// Create 3rd Array | |
jfloatArray array3 = env->NewFloatArray(9); | |
// Put some data into array3 | |
env->SetFloatArrayRegion(array3, 0, 9, result[i][j]); | |
// Add array 3 to array 2 and array 2 to array 1 | |
env->SetObjectArrayElement(array2, j, array3); | |
} | |
env->SetObjectArrayElement(array1, i, array2); | |
} | |
return array1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment