/* * Accuracy assessment for Error Matrices at most 20 x 20 */ #include #include #include #define M 20 /* Maximum size of Error matrices */ #define S 400 /* = M^2 */ FILE *fopen(),*data_r1,*data_r2,*data_w; char *f_name[4],tmp1[10],tmp2[10],tmp3[10],cc[3]; /* Variables used for files */ int c,num,i,j,r,r2,X[M][M],tmp[S]; long int xc[M],xr[M],N,ni,sum_a; double G1[M][M],G2[M][M], Pai[M],CX,AX,KapX,CBX[M],sum_c,K_hat, J_u,J_p,Ja_u,Ja_p,R_u,R_p,Tau_u[3],Tau_p[3],p[M], Var_u,Var_p, buf1[4],buf2[4],buf3[4]; /* Variables used for Accuracy Coefficients */ main() { void Input_X_G(), See_matrices(), Calculate(), See_Result(), Output2file(), See_Result1(); Input_X_G(); /* Reading of elements of Error Matrix */ if(r2==0) return; printf("\n\n"); printf(" Do you want see to the input matrices? (y/n) : "); gets(cc); if(cc[0] == 'y') See_matrices(); /* Confirmation of Input Matrix */ printf("\n\n"); Calculate(); /* Evaluation of Coefficients */ printf(" Do you want to see the result of calculation? (y/n) : "); gets(cc); printf("\n\n"); if(cc[0] == 'y') See_Result(); /* Confirmation of Evaluation Results on Screen */ printf(" Do you want to output the result to file? (y/n) : "); gets(cc); printf("\n\n"); if(cc[0] == 'y'){ Output2file(); printf(" Save data -----> %s \n\n",f_name[2]); } /* Output Evaluation Results to File */ } /*-----------------Begin of Func. Input_X_G()--------------------*/ void Input_X_G() { /* Input File Name ( X and Gamma ) */ printf("\n Length of filename should be TWO"); printf("\n Input filename of error matrix, (e.g., X1) : "); gets(tmp1); for(i=0;i<20;i++) tmp3[i]=tmp1[i]; f_name[0]=tmp1; printf("\n Enter the file name of matrix, (e.g., Ga) : "); gets(tmp2); f_name[1]=tmp2; /* Reading of Error Matrix X */ data_r1=fopen(f_name[0],"r"); num=0; while(feof(data_r1)==0){ while ( ( c = fgetc(data_r1) ) == ' ' || c == '\t' ); ungetc(c,data_r1); fscanf(data_r1,"%d",&tmp[num]); num++; /* Each element is stored in tmp */ } fclose(data_r1); r=sqrt((float)(num-1)); /* Find Category Number */ num=0; for(i=0;i Key "); gets(cc); printf("\n\n"); printf(" %s = \n",f_name[1]); for(i=0;i