0

hi all,

I have this minor problem which is making me go cranky at the mo.. Can't think straight,

need some insights to what I can do...

Below is the code which I am working on which takes the test sample values stored in my test 2D array subtracts the centroids stored in centroid 2D array and stores it in temp1 1D array where temp1 goes from 1 to 4. The values in temp1 array are now squared, summed up and storee inside temp1 array again and does this for 2308 times (CLEN). I want to know how I can increment my h index without using another for loop. Where do I initialize it. Before the i for loop or before j for loop?? Please help!!!

```
for(int i=0;i<TestNum;i++){
for(int j=0;j<CLEN;j++){
temp1[h]=test[i][j]-centroid[h][j];
temp1[h]=temp1[h]*temp1[h];
temp1[h]+=temp1[h];
}
temp1[h]=sqrt(temp1[h]);
sim[EWS][i]=1/(1+temp1[h]);
temp1[h]=sqrt(temp1[h]);
sim[BL][i]=1/(1+temp1[h]);
temp1[h]=sqrt(temp1[h]);
sim[NB][i]=1/(1+temp1[h]);
//cout<<sim[NB][i]<<"\t";
temp1[h]=sqrt(temp1[h]);
sim[RMS][i]=1/(1+temp1[h]);
//cout <<sim[RMS][i]<<"\t";
//Getting the maximum similarity from the 4 for each test samples
maxSim = EWS; //max =0
for(int p=1;p<NumClass;p++)
if(sim[p][i] > sim[maxSim][i])
maxSim = p;
if(t_val[i]==maxSim)
correctClassCount++;
}
```