2 ***********************************************************
3 $SNARK_Header: S N A R K 1 4 - A PICTURE RECONSTRUCTION PROGRAM $
4 $HeadURL: svn://dig.cs.gc.cuny.edu/snark/trunk/src/snark/read_eval_recon4.c $
5 $LastChangedRevision: 137 $
6 $Date: 2014-07-15 16:38:33 -0400 (Tue, 15 Jul 2014) $
8 ***********************************************************
14 #include "experimenter.h"
16 #include "read_eval_recon4.h"
19 this function reads from the eval file the kullback-leibler distance
22 iteration - iteration number
23 keywrd - keyword which defines the algorithm whose reconstruction is to be read in.
26 recon - double precision variable which stores the normalized root mean
27 square distance between the (clipped) reconstruction and the
31 void read_eval_recon4(int iteration, char* keywrd, double* klds, double* wsqd)
43 double local_wsqd = 0;
44 char string[MAXLINESIZE];
45 char test[MAXLINESIZE];
48 if ((evalfile = fopen("eval", "r")) == NULL) errorc("in read_eval_recon4.c: error in opening file ", "eval");
52 /* Read eval file until a line which contains the string
53 'experimenter evaluation 2' is reached. If end of file is
54 reached then keyword was not found so terminate program. */
56 fgets(string, sizeof(string), evalfile);
58 if (strstr(string, "experimenter evaluation 2") != NULL)
66 sprintf(string,"Error in read_eval_recon4.c: keyword %s not found in file ","experimenter evaluation 2");
67 errorc(string, "eval");
73 /* Read eval file until a line which contains the string
74 'execution name' is reached. If this line contains the
75 keyword, break out of the while loop. If end of file is
76 reached then keyword was not found so terminate program. */
78 fgets(string, sizeof(string), evalfile);
80 if (strstr(string, "execution name") != NULL)
82 sscanf(string, "%*s%*s %s", test);
83 if (strncasecmp(test, keywrd, 4) == 0)
92 sprintf(string,"Error in read_eval_recon4.c: keyword %s not found in file ",keywrd);
93 errorc(string, "eval");
99 /* Continue reading eval file until a line of numbers is
100 reached, then break out of while loop. If end of file
101 is encountered then terminate program. */
102 fgets(string, sizeof(string), evalfile);
103 if (sscanf(string, "%d %d %lf %lf %lf %lf %lf %lf %lf %lf", &iter, &area, &average, &distance, &relerr, &variance, &stddev, &residual, &kld, &local_wsqd) == 10)
109 errorc("Error in read_eval_recon4.c: end of file reached in file eval. Hint: Have the iteration flags been set to 3?","");
113 /* If necessary, search the remaining lines of numbers until
114 the appropriate iteration number is found. Then save the
115 distance and break out of while loop. If approriate
116 iteration number is not found then terminate program. */
119 /* if this first line of numbers has correct iteration number, return*/
120 if (iter == iteration)
130 fgets(string, sizeof(string), evalfile);
131 sscanf(string, "%d %d %lf %lf %lf %lf %lf %lf %lf %lf", &iter, &area, &average, &distance, &relerr, &variance, &stddev, &residual, &kld, &local_wsqd);
132 if (iter == iteration)
140 sprintf(string,"Error in read_eval_recon4.c: %s --> iteration %d not found in file", keywrd, iteration);
141 errorc(string, " eval");
146 // iteration == 0: the last iteration should be processed instead of a literal interpretation of 0
149 char prev[MAXLINESIZE];
153 strcpy(prev, string);
154 fgets(string, sizeof(string), evalfile);
155 if (strlen(string) < 3)
161 sprintf(string, "Error in read_eval_recon4.c: %s --> iteration %d not found in file",keywrd, iteration);
162 errorc(string, " eval");
166 sscanf(prev, "%d %d %lf %lf %lf %lf %lf %lf %lf %lf", &iter, &area, &average, &distance, &relerr, &variance, &stddev, &residual, &kld, &local_wsqd);