11#include < vector>
22#include < arrayfire.h>
3- #include < af/utils .h>
3+ #include < af/util .h>
44#include " java_wrapper.h"
55
66#ifdef ANDROID
@@ -26,6 +26,9 @@ JNIEXPORT void JNICALL Java_com_arrayfire_Array_info(JNIEnv *env, jclass clazz)
2626 }
2727}
2828
29+ using af::cfloat;
30+ using af::cdouble;
31+
2932JNIEXPORT jlong JNICALL Java_com_arrayfire_Array_createRanduArray (JNIEnv *env, jclass clazz, jintArray dims, jint type)
3033{
3134 jlong ret;
@@ -158,13 +161,8 @@ JNIEXPORT jlong JNICALL Java_com_arrayfire_Array_createArrayFromFloatComplex(JNI
158161 jfloat real = env->GetFloatField (obj, re);
159162 jfloat imag = env->GetFloatField (obj, im);
160163
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;
168166 }
169167
170168 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
207205 jdouble real = env->GetDoubleField (obj, re);
208206 jdouble imag = env->GetDoubleField (obj, im);
209207
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;
217210 }
218211
219212 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
287280 cfloat *tmp = (*A).host <cfloat>();
288281
289282 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 ;
297285 jobject obj = env->NewObject (cls, id, re, im);
298286
299287 env->SetObjectArrayElement (result, i, obj);
300288 }
301289
302- af::array::free (tmp);
303-
290+ delete[] tmp;
304291 } catch (af::exception& e) {
305292 result = NULL ;
306293 } catch (std::exception& e) {
@@ -325,20 +312,14 @@ JNIEXPORT jobjectArray JNICALL Java_com_arrayfire_Array_getDoubleComplexFromArra
325312 cdouble *tmp = (*A).host <cdouble>();
326313
327314 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 ;
335317 jobject obj = env->NewObject (cls, id, re, im);
336318
337319 env->SetObjectArrayElement (result, i, obj);
338320 }
339321
340- af::array::free (tmp);
341-
322+ delete[] tmp;
342323 } catch (af::exception& e) {
343324 result = NULL ;
344325 } catch (std::exception& e) {
@@ -445,13 +426,13 @@ UNARY_OP_DEF(sqrt)
445426 { \
446427 try { \
447428 af::array *A = (af::array*)(a); \
448- if (A->type () == af:: f32 ) \
429+ if (A->type () == f32 ) \
449430 return af::func<float >( (*A) ); \
450- if (A->type () == af:: s32) \
431+ if (A->type () == s32) \
451432 return af::func<int >( (*A) ); \
452- if (A->type () == af:: f64 ) \
433+ if (A->type () == f64 ) \
453434 return af::func<double >( (*A) ); \
454- if (A->type () == af:: b8) \
435+ if (A->type () == b8) \
455436 return af::func<float >( (*A) ); \
456437 return af::NaN; \
457438 } catch (af::exception& e) { \
@@ -617,7 +598,7 @@ void blur_logic(unsigned char* bufIn, unsigned char* bufOut, int* info)
617598 convert_uchar2float (&inptr,bufIn,imgsz, chnls);
618599
619600 af::array img (width,height,chnls,inptr);
620- af::array ker = af::gaussiankernel (5 ,5 );
601+ af::array ker = af::gaussianKernel (5 ,5 );
621602 af::array res = af::convolve (img, ker);
622603 res (af::span, af::span, 3 ) = 1 ;
623604 res.host (outptr);
@@ -701,7 +682,7 @@ JNIEXPORT jlong JNICALL Java_com_arrayfire_Image_meanshift(JNIEnv *env, jclass c
701682 try {
702683 af::array *A = (af::array*)(a);
703684 af::array *res = new af::array ();
704- (*res) = af::meanshift ( (*A) , space, color, iter );
685+ (*res) = af::meanShift ( (*A) , space, color, iter );
705686 ret = (jlong)(res);
706687 } catch (af::exception& e) {
707688 ret = 0 ;
@@ -765,7 +746,7 @@ JNIEXPORT jlong JNICALL Java_com_arrayfire_Image_resize1(JNIEnv *env, jclass cla
765746 try {
766747 af::array *A = (af::array*)(a);
767748 af::array *res = new af::array ();
768- (*res) = af::resize ( scale, (*A) , method );
749+ (*res) = af::resize ( scale, (*A));
769750 ret = (jlong)(res);
770751 } catch (af::exception& e) {
771752 ret = 0 ;
@@ -781,7 +762,7 @@ JNIEXPORT jlong JNICALL Java_com_arrayfire_Image_resize2(JNIEnv *env, jclass cla
781762 try {
782763 af::array *A = (af::array*)(a);
783764 af::array *res = new af::array ();
784- (*res) = af::resize ( scalex, scaley, (*A) , method );
765+ (*res) = af::resize ( scalex, scaley, (*A));
785766 ret = (jlong)(res);
786767 } catch (af::exception& e) {
787768 ret = 0 ;
@@ -797,7 +778,7 @@ JNIEXPORT jlong JNICALL Java_com_arrayfire_Image_resize3(JNIEnv *env, jclass cla
797778 try {
798779 af::array *A = (af::array*)(a);
799780 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));
801782 ret = (jlong)(res);
802783 } catch (af::exception& e) {
803784 ret = 0 ;
0 commit comments