converting c++ DTW code to java -


i want translate code c++ java. original code implements fast dtw algorithm. piece of code couldn't figure out i attribute i'm not sure hence, can't convert it.

the error in java in statements l_buff+i & u_buff+i because plus operator not supported between int i & double[] l_buff,u_buff.

i have included statements involves i

int  i; for(i=0; i<ep; i++) {     /// bunch of data has been read , pick 1 of them @ time use     d = buffer[i];      /// calculate sum , sum square     ex += d;     ex2 += d*d;      /// t circular array keeping current data     t[i%m] = d;      /// double size avoiding using modulo "%" operator     t[(i%m)+m] = d;      /// start task when there more m-1 points in current chunk     if( >= m-1 )     {         mean = ex/m;         std = ex2/m;         std = math.sqrt(std-mean*mean);          /// compute start location of data in current circular array, t         j = (i+1)%m;         /// start location of data in current chunk         = i-(m-1);         lb_k2 = lb_keogh_data_cumulative(order, tz, qo, cb2, l_buff+i, u_buff+i, m, mean, std, bsf); 

and lb_data_cumlative method implementation

public static double lb_keogh_data_cumulative(int[] order, double []tz, double []qo, double []cb, double []l, double []u, int len, double mean, double std, double best_so_far ) {     double lb = 0;     double uu,ll,d;      (int = 0; < len && lb < best_so_far; i++)     {         uu = (u[order[i]]-mean)/std;         ll = (l[order[i]]-mean)/std;         d = 0;         if (qo[i] > uu)             d = dist(qo[i], uu);         else         {             if(qo[i] < ll)                 d = dist(qo[i], ll);         }         lb += d;         cb[order[i]] = d;     }     return lb; } 

here paper on code relies sigkdd trillion

l_buff+i , u_buff+i mean shift beginning of arrays i elements. lb_keogh_data_cumulative parameters l , u won't see first i elements of given arrays.

so write like

lb_k2 = lb_keogh_data_cumulative(order, tz, qo, cb2, arrays.copyofrange(l_buff, i, l_buff.length), arrays.copyofrange(u_buff, i, u_buff.length), m, mean, std, bsf); 

the arrays not modified called method can pass copy.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -