hey.. im having a problem with my code...
its quite a long script and this is a pretty big extract but the main part im having the issue with is the inner most nested for loop
Code:
for(i=0;i<N_gnc2;i++){
for(l=0;l<N_gnc1;l++){
absolute3[l]=abs(index_gnc2[index_gncthistag[i]]-index_TS2[index_TSthistag[l]]);
}
}
if i set N_gnc1 to 10 or 100 the code runs but if i set it to the correct value which is 109727 then it appears to run indefinetly
here is the larger part of the script that the code is a part of, important variables are
end_i=462154
n_TS = 109727;
n_TN = 7;
lengthtypeofTT = 5;
i apologise if i made any mistakes posting hear... im still a beginner on these forums and with programming in general.
Code:
int N_gnc1;
int N_gnc2;
int *index_gnctoTS;
index_gnctoTS = (int *)malloc(end_i * sizeof(int));
int *index_TSthistag;
index_TSthistag = (int *)malloc(end_i * sizeof(int));
int *index_gncthistag;
index_gncthistag = (int *)malloc(end_i * sizeof(int));
int *absolute3;
absolute3 = (int *)malloc(end_i * sizeof(int));
int n_TN;
n_TS = elnum_index_TS2;
n_TN = elnum5;
lengthtypeofTT;
n=0;
m=0;
printf("n_TS = %d\n", n_TS);
printf("n_TN = %d\n", n_TN);
printf("end_i = %d\n", end_i);
printf("lengthtypeofTT = %d\n", lengthtypeofTT);
for(i=0;i<n_TS;i++){
index_gnctoTS[i]=0;
}
for(j=0;j<n_TN;j++){
for(k=0;k<lengthtypeofTT;k++){
for(i=0;i<n_TS;i++){
if( (time_tag2[index_TS2[i]]==typeofTT[k]) && (node_id2[index_TS2[i]]==node_type[j]) ){
index_TSthistag[m]=i;
m=m+1;
}
}
N_gnc1=m;
for(i=0;i<n_TS;i++){
if( (time_tag2[index_gnc2[i]]==typeofTT[k]) && (node_id2[index_gnc2[i]]==node_type[j]) ){
index_gncthistag[n]=i;
n=n+1;
}
}
N_gnc2=n;
for(i=0;i<N_gnc2;i++){
for(l=0;l<N_gnc1;l++){
absolute3[l]=abs(index_gnc2[index_gncthistag[i]]-index_TS2[index_TSthistag[l]]);
}
}
}
}