1
1
#include < vector>
2
2
#include < arrayfire.h>
3
- #include < af/utils .h>
3
+ #include < af/util .h>
4
4
#include " java_wrapper.h"
5
5
6
6
#ifdef ANDROID
@@ -26,6 +26,9 @@ JNIEXPORT void JNICALL Java_com_arrayfire_Array_info(JNIEnv *env, jclass clazz)
26
26
}
27
27
}
28
28
29
+ using af::cfloat;
30
+ using af::cdouble;
31
+
29
32
JNIEXPORT jlong JNICALL Java_com_arrayfire_Array_createRanduArray (JNIEnv *env, jclass clazz, jintArray dims, jint type)
30
33
{
31
34
jlong ret;
@@ -158,13 +161,8 @@ JNIEXPORT jlong JNICALL Java_com_arrayfire_Array_createArrayFromFloatComplex(JNI
158
161
jfloat real = env->GetFloatField (obj, re);
159
162
jfloat imag = env->GetFloatField (obj, im);
160
163
161
- #ifdef AFCL
162
- tmp[i].s [0 ] = real;
163
- tmp[i].s [1 ] = imag;
164
- #else
165
- tmp[i].x = real;
166
- tmp[i].y = imag;
167
- #endif
164
+ tmp[i].real = real;
165
+ tmp[i].imag = imag;
168
166
}
169
167
170
168
af::array *A = new af::array (dimptr[0 ],dimptr[1 ],dimptr[2 ],dimptr[3 ],tmp);
@@ -207,13 +205,8 @@ JNIEXPORT jlong JNICALL Java_com_arrayfire_Array_createArrayFromDoubleComplex(JN
207
205
jdouble real = env->GetDoubleField (obj, re);
208
206
jdouble imag = env->GetDoubleField (obj, im);
209
207
210
- #ifdef AFCL
211
- tmp[i].s [0 ] = real;
212
- tmp[i].s [1 ] = imag;
213
- #else
214
- tmp[i].x = real;
215
- tmp[i].y = imag;
216
- #endif
208
+ tmp[i].real = real;
209
+ tmp[i].imag = imag;
217
210
}
218
211
219
212
af::array *A = new af::array (dimptr[0 ],dimptr[1 ],dimptr[2 ],dimptr[3 ],tmp);
@@ -287,20 +280,14 @@ JNIEXPORT jobjectArray JNICALL Java_com_arrayfire_Array_getFloatComplexFromArray
287
280
cfloat *tmp = (*A).host <cfloat>();
288
281
289
282
for (int i = 0 ; i < size; i++) {
290
- #ifdef AFCL
291
- float re = tmp[i].s [0 ];
292
- float im = tmp[i].s [1 ];
293
- #else
294
- float re = tmp[i].x ;
295
- float im = tmp[i].y ;
296
- #endif
283
+ float re = tmp[i].real ;
284
+ float im = tmp[i].imag ;
297
285
jobject obj = env->NewObject (cls, id, re, im);
298
286
299
287
env->SetObjectArrayElement (result, i, obj);
300
288
}
301
289
302
- af::array::free (tmp);
303
-
290
+ delete[] tmp;
304
291
} catch (af::exception& e) {
305
292
result = NULL ;
306
293
} catch (std::exception& e) {
@@ -325,20 +312,14 @@ JNIEXPORT jobjectArray JNICALL Java_com_arrayfire_Array_getDoubleComplexFromArra
325
312
cdouble *tmp = (*A).host <cdouble>();
326
313
327
314
for (int i = 0 ; i < size; i++) {
328
- #ifdef AFCL
329
- double re = tmp[i].s [0 ];
330
- double im = tmp[i].s [1 ];
331
- #else
332
- double re = tmp[i].x ;
333
- double im = tmp[i].y ;
334
- #endif
315
+ double re = tmp[i].real ;
316
+ double im = tmp[i].imag ;
335
317
jobject obj = env->NewObject (cls, id, re, im);
336
318
337
319
env->SetObjectArrayElement (result, i, obj);
338
320
}
339
321
340
- af::array::free (tmp);
341
-
322
+ delete[] tmp;
342
323
} catch (af::exception& e) {
343
324
result = NULL ;
344
325
} catch (std::exception& e) {
@@ -445,13 +426,13 @@ UNARY_OP_DEF(sqrt)
445
426
{ \
446
427
try { \
447
428
af::array *A = (af::array*)(a); \
448
- if (A->type () == af:: f32 ) \
429
+ if (A->type () == f32 ) \
449
430
return af::func<float >( (*A) ); \
450
- if (A->type () == af:: s32) \
431
+ if (A->type () == s32) \
451
432
return af::func<int >( (*A) ); \
452
- if (A->type () == af:: f64 ) \
433
+ if (A->type () == f64 ) \
453
434
return af::func<double >( (*A) ); \
454
- if (A->type () == af:: b8) \
435
+ if (A->type () == b8) \
455
436
return af::func<float >( (*A) ); \
456
437
return af::NaN; \
457
438
} catch (af::exception& e) { \
@@ -617,7 +598,7 @@ void blur_logic(unsigned char* bufIn, unsigned char* bufOut, int* info)
617
598
convert_uchar2float (&inptr,bufIn,imgsz, chnls);
618
599
619
600
af::array img (width,height,chnls,inptr);
620
- af::array ker = af::gaussiankernel (5 ,5 );
601
+ af::array ker = af::gaussianKernel (5 ,5 );
621
602
af::array res = af::convolve (img, ker);
622
603
res (af::span, af::span, 3 ) = 1 ;
623
604
res.host (outptr);
@@ -701,7 +682,7 @@ JNIEXPORT jlong JNICALL Java_com_arrayfire_Image_meanshift(JNIEnv *env, jclass c
701
682
try {
702
683
af::array *A = (af::array*)(a);
703
684
af::array *res = new af::array ();
704
- (*res) = af::meanshift ( (*A) , space, color, iter );
685
+ (*res) = af::meanShift ( (*A) , space, color, iter );
705
686
ret = (jlong)(res);
706
687
} catch (af::exception& e) {
707
688
ret = 0 ;
@@ -765,7 +746,7 @@ JNIEXPORT jlong JNICALL Java_com_arrayfire_Image_resize1(JNIEnv *env, jclass cla
765
746
try {
766
747
af::array *A = (af::array*)(a);
767
748
af::array *res = new af::array ();
768
- (*res) = af::resize ( scale, (*A) , method );
749
+ (*res) = af::resize ( scale, (*A));
769
750
ret = (jlong)(res);
770
751
} catch (af::exception& e) {
771
752
ret = 0 ;
@@ -781,7 +762,7 @@ JNIEXPORT jlong JNICALL Java_com_arrayfire_Image_resize2(JNIEnv *env, jclass cla
781
762
try {
782
763
af::array *A = (af::array*)(a);
783
764
af::array *res = new af::array ();
784
- (*res) = af::resize ( scalex, scaley, (*A) , method );
765
+ (*res) = af::resize ( scalex, scaley, (*A));
785
766
ret = (jlong)(res);
786
767
} catch (af::exception& e) {
787
768
ret = 0 ;
@@ -797,7 +778,7 @@ JNIEXPORT jlong JNICALL Java_com_arrayfire_Image_resize3(JNIEnv *env, jclass cla
797
778
try {
798
779
af::array *A = (af::array*)(a);
799
780
af::array *res = new af::array ();
800
- (*res) = af::resize ( (unsigned int )height, (unsigned int )width, (*A) , method );
781
+ (*res) = af::resize ( (unsigned int )height, (unsigned int )width, (*A));
801
782
ret = (jlong)(res);
802
783
} catch (af::exception& e) {
803
784
ret = 0 ;
0 commit comments