Diploma Thesis Percolation Simulation C++ Sourcecode Documentation |
00001 // datafiles.h 00002 // countcluster version, that writes into a diskfile 00003 // Andreas Krueger, 2/2000 00004 // version 1.3 00005 // last change: 14.7.2000 00006 00007 00008 #define FORMAT "%6u" // up to clustersize 999999 and 999999 seconds (694 days) 00009 #define FORMATINT "%3u" // 00010 #define FORMATLONG "%8u" // 00011 #define FORMATCOORD "%4.1f" // for GRIDSIZE 00012 #define FORMATBIGFLOAT "%10.2f" // for averaged NUMBERs 00013 #define FORMATSMALLFLOAT "%4.10f" // for radius 00014 #define FORMATEXACT "%10.10f" // for unitsphere 00015 #define FORMATNUMBER "%6u" // upt to clustersize 999999 00016 #define FORMATCOUNTER "%5u" // up to e.g. 99999 loops 00017 //#include <stdio.h> // for file handling 00018 00019 namespace datafiles{ 00020 using statistics::muvarskewkurt; 00021 using results::one_result; 00022 using results::all_results; 00023 00024 00025 void my_fprintf_ff_heading(FILE* outFile){ 00026 fprintf(outFile,"%s","f-factor\tradius\tnew\t"); 00027 } 00028 00029 00030 void my_fprintf_ff(FILE* outFile, REAL fillingfactor, REAL radius, bool new_result){ 00031 fprintf(outFile,FORMATSMALLFLOAT,fillingfactor); fprintf(outFile,"%c",'\t'); 00032 fprintf(outFile,FORMATSMALLFLOAT,radius); fprintf(outFile,"%c",'\t'); 00033 fprintf(outFile,FORMATINT,new_result); fprintf(outFile,"%c",'\t'); 00034 } 00035 00036 void write_intro(char *filename, NUMBER no,COORDFLOAT length, int loops, int dimension) { 00037 FILE* outFile= fopen( filename, "w" ); 00038 fprintf(outFile,"%s","cpp__at__AndreasKrueger__dot__de and his famous clustercount programm presents:\n"); 00039 fprintf(outFile,FORMAT,no); fprintf(outFile,"%s"," thrown spheres on a "); 00040 fprintf(outFile,FORMAT,dimension); fprintf(outFile,"%s"," dimensional volume of length "); 00041 fprintf(outFile,FORMATCOORD,length); fprintf(outFile,"%c",'\n'); 00042 fprintf(outFile,"%c",'\n'); 00043 00044 00045 fprintf(outFile,"%s","length of volume\t"); 00046 fprintf(outFile,FORMATCOORD,length); fprintf(outFile,"%c",'\n'); 00047 fprintf(outFile,"%s","dimensions\t"); 00048 fprintf(outFile,FORMAT,dimension); fprintf(outFile,"%c",'\n'); 00049 fprintf(outFile,"%s","number of spheres\t"); 00050 fprintf(outFile,FORMAT,no); fprintf(outFile,"%c",'\n'); 00051 fprintf(outFile,"%s","loops per radius\t"); 00052 fprintf(outFile,FORMAT,loops); fprintf(outFile,"%c",'\n'); 00053 fprintf(outFile,"%s","volume of unit sphere\t"); 00054 fprintf(outFile,FORMATEXACT,unitsphere(dimension)); fprintf(outFile,"%c",'\n'); 00055 00056 fprintf(outFile,"%c",'\n'); 00057 fprintf(outFile,"%s","radius\tf-factor\tbiggest\taverage\tmostfrq\t\ttime (milliseconds)\n"); 00058 fclose( outFile ) ; 00059 } 00060 00061 void write_intro_square(char *filename, NUMBER no,COORDFLOAT length, int loops, int dimension, COUNTER cuts) { 00062 FILE* outFile= fopen( filename, "w" ); 00063 fprintf(outFile,"%s","cpp__at__AndreasKrueger__dot__de and his famous clustercount programm presents:\n"); 00064 fprintf(outFile,FORMAT,no); fprintf(outFile,"%s"," thrown spheres on a "); 00065 fprintf(outFile,FORMAT,dimension); fprintf(outFile,"%s"," dimensional volume of length "); 00066 fprintf(outFile,FORMATCOORD,length); fprintf(outFile,"%c",'\n'); 00067 fprintf(outFile,"%c",'\n'); 00068 fprintf(outFile,"%s","length of volume\t"); 00069 fprintf(outFile,FORMATCOORD,length); fprintf(outFile,"%c",'\n'); 00070 fprintf(outFile,"%s","dimensions\t"); 00071 fprintf(outFile,FORMAT,dimension); fprintf(outFile,"%c",'\n'); 00072 fprintf(outFile,"%s","number of spheres\t"); 00073 fprintf(outFile,FORMAT,no); fprintf(outFile,"%c",'\n'); 00074 fprintf(outFile,"%s","loops per radius\t"); 00075 fprintf(outFile,FORMAT,loops); fprintf(outFile,"%c",'\t'); 00076 fprintf(outFile,"%s","#cuts(N,dim)\t"); 00077 fprintf(outFile,FORMAT,cuts); fprintf(outFile,"%c",'\n'); 00078 fprintf(outFile,"%s","volume of unit sphere\t"); 00079 fprintf(outFile,FORMATEXACT,unitsphere(dimension)); fprintf(outFile,"%c",'\n'); 00080 00081 fprintf(outFile,"%c",'\n'); 00082 fprintf(outFile,"%s","radius\tf-factor\tbiggest\taverage\tbiggest^2\taverage^2\t\ttime (milliseconds)\n"); 00083 fclose( outFile ) ; 00084 } 00085 00086 void write_error (char *filename){ 00087 errorout("file open - error. Couldn't write!"); 00088 cout << filename<<endl; 00089 cout <<"Continue without saving!"<<endl; 00090 } 00091 void write_error (const char *filename){ 00092 errorout("file open - error. Couldn't write!"); 00093 cout << filename<<endl; 00094 cout <<"Continue without saving!"<<endl; 00095 } 00096 00097 00098 00099 bool write_intro7 (char *filename, NUMBER no,COORDFLOAT length, int maxloops, int dimension, COUNTER cuts) { 00100 FILE* outFile= fopen( filename, "w" ); 00101 if (outFile==NULL) {write_error (filename); return false;} 00102 else { 00103 fprintf(outFile,"%s","cpp__at__AndreasKrueger__dot__de and his famous clustercount programm presents:\n"); 00104 fprintf(outFile,FORMAT,no); fprintf(outFile,"%s"," thrown spheres on a "); 00105 fprintf(outFile,FORMAT,dimension); fprintf(outFile,"%s"," dimensional volume of length "); 00106 fprintf(outFile,FORMATCOORD,length); fprintf(outFile,"%c",'\n'); 00107 fprintf(outFile,"%c",'\n'); 00108 fprintf(outFile,"%s","length of volume\t"); 00109 fprintf(outFile,FORMATCOORD,length); fprintf(outFile,"%c",'\n'); 00110 fprintf(outFile,"%s","dimensions\t"); 00111 fprintf(outFile,FORMAT,dimension); fprintf(outFile,"%c",'\n'); 00112 fprintf(outFile,"%s","number of spheres\t"); 00113 fprintf(outFile,FORMAT,no); fprintf(outFile,"%c",'\n'); 00114 fprintf(outFile,"%s","maximal loops per radius\t"); 00115 fprintf(outFile,FORMAT,maxloops); fprintf(outFile,"%c",'\t'); 00116 fprintf(outFile,"%s","#cuts(N,dim)\t"); 00117 fprintf(outFile,FORMAT,cuts); fprintf(outFile,"%c",'\n'); 00118 fprintf(outFile,"%s","volume of unit sphere\t"); 00119 fprintf(outFile,FORMATEXACT,unitsphere(dimension)); fprintf(outFile,"%c",'\n'); 00120 00121 fprintf(outFile,"%c",'\n'); 00122 fprintf(outFile,"%s","radius\tf-factor\t<numberofcl>\t<biggestcl>\t<meancl>"); 00123 fprintf(outFile,"%s","\tfluctuation(numberofcl)\tfluctuation(biggestcl)\tfluctuation(meancl)\tthis(numberofcl)\tthis(biggestcl)\tthis(meancl)"); 00124 fprintf(outFile,"%s","\t#loops\ttime (milliseconds)\n"); 00125 fclose( outFile ) ; 00126 return true; 00127 } 00128 } 00129 00130 bool write_one_step7(char *filename, REAL radius, REAL fillingfactor, 00131 REAL sum_numberofcl, 00132 REAL sum_biggestcl, 00133 REAL sum_averagecl, 00134 REAL fluctuation_numberofcl, 00135 REAL fluctuation_biggestcl, 00136 REAL fluctuation_averagecl, 00137 NUMBER this_numberofcl, 00138 NUMBER this_biggestcl, 00139 REAL this_averagecl, 00140 COUNTER loop_no, 00141 clock_t sum_time) 00142 { 00143 FILE *outFile = fopen( filename, "a+" ); 00144 if (outFile==NULL) {write_error (filename); return false;} 00145 else { 00146 fprintf(outFile,FORMATSMALLFLOAT,radius); fprintf(outFile,"%c",'\t'); 00147 fprintf(outFile,FORMATSMALLFLOAT,fillingfactor); fprintf(outFile,"%c",'\t'); 00148 fprintf(outFile,FORMATBIGFLOAT,sum_numberofcl); fprintf(outFile,"%c",'\t'); 00149 fprintf(outFile,FORMATBIGFLOAT,sum_biggestcl); fprintf(outFile,"%c",'\t'); 00150 fprintf(outFile,FORMATBIGFLOAT,sum_averagecl); fprintf(outFile,"%c",'\t'); 00151 fprintf(outFile,FORMATBIGFLOAT,fluctuation_numberofcl); fprintf(outFile,"%c",'\t'); 00152 fprintf(outFile,FORMATBIGFLOAT,fluctuation_biggestcl); fprintf(outFile,"%c",'\t'); 00153 fprintf(outFile,FORMATBIGFLOAT,fluctuation_averagecl); fprintf(outFile,"%c",'\t'); 00154 fprintf(outFile,FORMATNUMBER,this_numberofcl); fprintf(outFile,"%c",'\t'); 00155 fprintf(outFile,FORMATNUMBER,this_biggestcl); fprintf(outFile,"%c",'\t'); 00156 fprintf(outFile,FORMATBIGFLOAT,this_averagecl); fprintf(outFile,"%c",'\t'); 00157 fprintf(outFile,FORMATCOUNTER,loop_no); fprintf(outFile,"%c",'\t'); 00158 fprintf(outFile,FORMATBIGFLOAT,ms(sum_time)); fprintf(outFile,"%c",'\n'); 00159 fclose( outFile ); 00160 return true; 00161 } 00162 } 00163 00164 00165 00166 00167 00168 // TODO: evtl. stimmt die Zeitangabe nicht! 00169 bool closefile7(char *filename, clock_t totaltime, 00170 REAL min_fluct, REAL ffactor_min_fluct, 00171 REAL max_fluct, REAL ffactor_max_fluct) { 00172 FILE* outFile = fopen( filename, "a+" ); 00173 if (outFile==NULL) {write_error (filename); return false;} 00174 else { 00175 00176 fprintf(outFile,"%c",'\n'); fprintf(outFile,"%c",'\n'); 00177 fprintf(outFile,"%s","total time in minutes\t"); 00178 fprintf(outFile,FORMATBIGFLOAT,(REAL)ms(totaltime)/60000); fprintf(outFile,"%c",'\t'); 00179 fprintf(outFile,"%s","in seconds\t"); 00180 fprintf(outFile,FORMATBIGFLOAT,(REAL)ms(totaltime)/1000); fprintf(outFile,"%c",'\n'); 00181 00182 fprintf(outFile,"%s","minimum (fluctuation)\t"); 00183 fprintf(outFile,FORMATBIGFLOAT,min_fluct); fprintf(outFile,"%c",'\t'); 00184 fprintf(outFile,"%s","at fillingfactor\t"); 00185 fprintf(outFile,FORMATSMALLFLOAT,ffactor_min_fluct); fprintf(outFile,"%c",'\n'); 00186 00187 fprintf(outFile,"%s","maximum (fluctuation)\t"); 00188 fprintf(outFile,FORMATBIGFLOAT,max_fluct); fprintf(outFile,"%c",'\t'); 00189 fprintf(outFile,"%s","at fillingfactor\t"); 00190 fprintf(outFile,FORMATSMALLFLOAT,ffactor_max_fluct); fprintf(outFile,"%c",'\n'); 00191 00192 fclose( outFile ) ; 00193 return true; 00194 } 00195 } 00196 00197 00198 void write_results7 (char * filename, 00199 COUNTER FILE_STEPS, REAL* R, REAL *ffactor, 00200 REAL* sum_numberofcl, REAL* sum_biggestcl, REAL* sum_averagecl, 00201 REAL* fluctuation_numberofcl, REAL* fluctuation_biggestcl, REAL* fluctuation_averagecl, 00202 NUMBER* this_numberofcl, NUMBER* this_biggestcl, REAL* this_averagecl, 00203 COUNTER* loop_no, 00204 clock_t* sum_time, 00205 clock_t totaltime, 00206 REAL min_fluctuation, REAL ffactor_min_fluct, 00207 REAL max_fluctuation, REAL ffactor_max_fluct){ 00208 00209 for (COUNTER index=0;index<=FILE_STEPS; index++){ 00210 write_one_step7(filename, R[index], ffactor[index], 00211 sum_numberofcl[index], 00212 sum_biggestcl[index], 00213 sum_averagecl[index], 00214 fluctuation_numberofcl[index], 00215 fluctuation_biggestcl[index], 00216 fluctuation_averagecl[index], 00217 this_numberofcl[index], 00218 this_biggestcl[index], 00219 this_averagecl[index], 00220 loop_no[index], 00221 sum_time[index]); 00222 } 00223 00224 closefile7( filename, totaltime, 00225 min_fluctuation, ffactor_min_fluct, 00226 max_fluctuation, ffactor_max_fluct); 00227 } 00228 00229 00230 00231 00232 00233 00234 void closefile(char *filename, clock_t totaltime) { 00235 FILE* outFile = fopen( filename, "a+" ); 00236 00237 totaltime=clock()-totaltime; 00238 REAL totaltime_minutes=(REAL)ms(totaltime)/1000/60; 00239 00240 fprintf(outFile,"%c",'\n'); fprintf(outFile,"%c",'\n'); 00241 fprintf(outFile,"%s","total time in minutes\t"); 00242 fprintf(outFile,FORMATBIGFLOAT,totaltime_minutes); fprintf(outFile,"%c",'\n'); 00243 00244 fclose( outFile ) ; 00245 } 00246 00247 00248 00249 00250 00251 void setfilename(char* filename, char* head, 00252 NUMBER N, int dimension, 00253 int loops, 00254 REAL from, REAL to, int steps) 00255 { 00256 00257 sprintf(filename, "%scluster-%ddim-N%d-F%1.2f-T%1.2f-S%d-(L%d).txt",head, dimension, N, from, to, steps, loops); 00258 } 00259 00260 void set_and_show_filename (char *filename, 00261 REAL FILE_FROM, 00262 REAL FILE_TO, 00263 int FILE_STEPS, 00264 int loops, 00265 COORDFLOAT gridsize, 00266 int dimension, 00267 NUMBER N, 00268 char* FILEHEAD, 00269 REAL &rfrom, 00270 REAL &rto, 00271 REAL &rstep) 00272 { 00273 rfrom=give_radius(FILE_FROM, N, gridsize, dimension); 00274 rto=give_radius(FILE_TO, N, gridsize, dimension); 00275 rstep=(rto-rfrom)/FILE_STEPS; 00276 00277 setfilename(filename, FILEHEAD,N,dimension,loops,FILE_FROM,FILE_TO,FILE_STEPS); 00278 00279 cout << "\nFrom r="<<rfrom<<" to "<<rto<<" in "<<FILE_STEPS<<" steps of size "<<rstep<<endl; 00280 cout <<"write results to "<<filename<<endl; 00281 waitanykey(); 00282 } 00283 00284 00285 00286 void write_one_step(char *filename, 00287 REAL radius, 00288 REAL fillingfactor, 00289 REAL sum_biggestcl, 00290 REAL sum_averagecl, 00291 clock_t sum_time) 00292 { 00293 FILE *outFile = fopen( filename, "a+" ); 00294 fprintf(outFile,FORMATSMALLFLOAT,radius); fprintf(outFile,"%c",'\t'); 00295 fprintf(outFile,FORMATSMALLFLOAT,fillingfactor); fprintf(outFile,"%c",'\t'); 00296 fprintf(outFile,FORMATBIGFLOAT,sum_biggestcl); fprintf(outFile,"%c",'\t'); 00297 fprintf(outFile,FORMATBIGFLOAT,sum_averagecl); fprintf(outFile,"%c",'\t'); 00298 fprintf(outFile,"%c",'\t'); fprintf(outFile,"%c",'\t'); // instead of mostfrequent 00299 fprintf(outFile,FORMATBIGFLOAT,ms(sum_time)); fprintf(outFile,"%c",'\n'); 00300 fclose( outFile ); 00301 } 00302 00303 void write_one_step(char *filename, 00304 REAL radius, 00305 REAL fillingfactor, 00306 REAL sum_biggestcl, 00307 REAL sum_averagecl, 00308 REAL sum_square_biggestcl, 00309 REAL sum_square_averagecl, 00310 clock_t sum_time) 00311 { 00312 FILE *outFile = fopen( filename, "a+" ); 00313 fprintf(outFile,FORMATSMALLFLOAT,radius); fprintf(outFile,"%c",'\t'); 00314 fprintf(outFile,FORMATSMALLFLOAT,fillingfactor); fprintf(outFile,"%c",'\t'); 00315 fprintf(outFile,FORMATBIGFLOAT,sum_biggestcl); fprintf(outFile,"%c",'\t'); 00316 fprintf(outFile,FORMATBIGFLOAT,sum_averagecl); fprintf(outFile,"%c",'\t'); 00317 fprintf(outFile,FORMATBIGFLOAT,sum_square_biggestcl); fprintf(outFile,"%c",'\t'); 00318 fprintf(outFile,FORMATBIGFLOAT,sum_square_averagecl); fprintf(outFile,"%c",'\t'); 00319 fprintf(outFile,"%c",'\t'); 00320 fprintf(outFile,FORMATBIGFLOAT,ms(sum_time)); fprintf(outFile,"%c",'\n'); 00321 fclose( outFile ); 00322 } 00323 00324 00325 bool write_one_step(char *filename, REAL radius, REAL fillingfactor, 00326 REAL sum_biggestcl, 00327 REAL sum_averagecl, 00328 REAL sum_square_biggestcl, 00329 REAL sum_square_averagecl, 00330 REAL fluctuation_biggestcl, 00331 REAL fluctuation_averagecl, 00332 NUMBER this_biggestcl, 00333 REAL this_averagecl, 00334 COUNTER loop_no, 00335 clock_t sum_time) 00336 { 00337 FILE *outFile = fopen( filename, "a+" ); 00338 if (outFile==NULL) {write_error (filename); return false;} 00339 else { 00340 fprintf(outFile,FORMATSMALLFLOAT,radius); fprintf(outFile,"%c",'\t'); 00341 fprintf(outFile,FORMATSMALLFLOAT,fillingfactor); fprintf(outFile,"%c",'\t'); 00342 fprintf(outFile,FORMATBIGFLOAT,sum_biggestcl); fprintf(outFile,"%c",'\t'); 00343 fprintf(outFile,FORMATBIGFLOAT,sum_averagecl); fprintf(outFile,"%c",'\t'); 00344 fprintf(outFile,FORMATBIGFLOAT,sum_square_biggestcl); fprintf(outFile,"%c",'\t'); 00345 fprintf(outFile,FORMATBIGFLOAT,sum_square_averagecl); fprintf(outFile,"%c",'\t'); 00346 fprintf(outFile,FORMATBIGFLOAT,fluctuation_biggestcl); fprintf(outFile,"%c",'\t'); 00347 fprintf(outFile,FORMATBIGFLOAT,fluctuation_averagecl); fprintf(outFile,"%c",'\t'); 00348 fprintf(outFile,FORMATNUMBER,this_biggestcl); fprintf(outFile,"%c",'\t'); 00349 fprintf(outFile,FORMATBIGFLOAT,this_averagecl); fprintf(outFile,"%c",'\t'); 00350 fprintf(outFile,FORMATCOUNTER,loop_no); fprintf(outFile,"%c",'\t'); 00351 fprintf(outFile,FORMATBIGFLOAT,ms(sum_time)); fprintf(outFile,"%c",'\n'); 00352 fclose( outFile ); 00353 return true; 00354 } 00355 } 00356 00357 00358 void write_cuts_intro(char *filename, char *compname, COORDFLOAT length, int loops, int dimension) { 00359 FILE* outFile= fopen( filename, "w" ); 00360 fprintf(outFile,"%s","cpp__at__AndreasKrueger__dot__de and his famous clustercount programm present:\n"); 00361 fprintf(outFile,"%s","Algorithm configuration table for percolating hyperspheres\nthrown on a "); 00362 fprintf(outFile,FORMAT,dimension); fprintf(outFile,"%s"," dimensional volume of length "); 00363 fprintf(outFile,FORMATCOORD,length); fprintf(outFile,"%c",'\n'); 00364 fprintf(outFile,"%c",'\n'); 00365 00366 fprintf(outFile,"%s","length of volume\t"); 00367 fprintf(outFile,FORMATCOORD,length); fprintf(outFile,"%c",'\n'); 00368 fprintf(outFile,"%s","dimensions\t"); 00369 fprintf(outFile,FORMAT,dimension); fprintf(outFile,"%c",'\n'); 00370 fprintf(outFile,"%s","volume of unit sphere\t"); 00371 fprintf(outFile,FORMATEXACT,unitsphere(dimension)); fprintf(outFile,"%c",'\n'); 00372 fprintf(outFile,"%s","loops per one cut\t"); 00373 fprintf(outFile,FORMAT,loops); fprintf(outFile,"%c",'\n'); 00374 fprintf(outFile,"%s","computername\t"); 00375 fprintf(outFile,"%s",compname); fprintf(outFile,"%c",'\n'); 00376 00377 fprintf(outFile,"%c",'\n'); 00378 fprintf(outFile,"%s","N\tR\tmax_cuts\tcuts\ttime(milliseconds)\n"); 00379 fclose( outFile ) ; 00380 } 00381 00382 void write_one_cut(char *filename, 00383 NUMBER N, 00384 REAL radius, 00385 NUMBER max_cuts, 00386 NUMBER cuts, 00387 clock_t time) 00388 { 00389 FILE *outFile = fopen( filename, "a+" ); 00390 fprintf(outFile,FORMAT,N); fprintf(outFile,"%c",'\t'); 00391 fprintf(outFile,FORMATSMALLFLOAT,radius); fprintf(outFile,"%c",'\t'); 00392 fprintf(outFile,FORMAT,max_cuts); fprintf(outFile,"%c",'\t'); 00393 fprintf(outFile,FORMAT,cuts); fprintf(outFile,"%c",'\t'); 00394 fprintf(outFile,FORMATBIGFLOAT,ms(time)); fprintf(outFile,"%c",'\n'); 00395 fclose( outFile ); 00396 } 00397 00398 00399 void write_averaged_cuts_intro(const char *filename, string compname, COORDFLOAT length, int dimension, int criterion) { 00400 FILE* outFile= fopen( filename, "w" ); 00401 fprintf(outFile,"%s","cpp__at__AndreasKrueger__dot__de and his famous clustercount programm present:\n"); 00402 fprintf(outFile,"%s","time-averaging loops for predefined cuts-intervalls that generate an\n"); 00403 fprintf(outFile,"%s","Algorithm configuration table for percolating hyperspheres\nthrown on a "); 00404 fprintf(outFile,FORMAT,dimension); fprintf(outFile,"%s"," dimensional volume of length "); 00405 fprintf(outFile,FORMATCOORD,length); fprintf(outFile,"%c",'\n'); 00406 fprintf(outFile,"%c",'\n'); 00407 00408 fprintf(outFile,"%s","length of volume\t"); 00409 fprintf(outFile,FORMATCOORD,length); fprintf(outFile,"%c",'\n'); 00410 fprintf(outFile,"%s","dimensions\t"); 00411 fprintf(outFile,FORMAT,dimension); fprintf(outFile,"%c",'\n'); 00412 fprintf(outFile,"%s","MAXDIM(internal)\t"); 00413 fprintf(outFile,FORMAT,MAXDIM); fprintf(outFile,"%c",'\n'); 00414 00415 fprintf(outFile,"%s","ff-criterion\t"); 00416 fprintf(outFile,FORMAT,criterion); fprintf(outFile,"%c",'\n'); 00417 00418 fprintf(outFile,"%s","volume of unit sphere\t"); 00419 fprintf(outFile,FORMATEXACT,unitsphere(dimension)); fprintf(outFile,"%c",'\n'); 00420 fprintf(outFile,"%s","computername\t"); 00421 fprintf(outFile,"%s",compname.c_str()); fprintf(outFile,"%c",'\n'); 00422 00423 fprintf(outFile,"%c",'\n'); 00424 fprintf(outFile,"%s","N\tR\tloops\tcuts\ttime(ms)\ttime_sdev(ms)\n"); 00425 fclose( outFile ) ; 00426 } 00427 00428 void write_one_averaged_cut(const char *filename, 00429 NUMBER N, 00430 REAL radius, 00431 NUMBER loops, 00432 NUMBER cuts, 00433 clock_t time, 00434 clock_t time_sdev) 00435 { 00436 FILE *outFile = fopen( filename, "a+" ); 00437 fprintf(outFile,FORMAT,N); fprintf(outFile,"%c",'\t'); 00438 fprintf(outFile,FORMATSMALLFLOAT,radius); fprintf(outFile,"%c",'\t'); 00439 fprintf(outFile,FORMAT,loops); fprintf(outFile,"%c",'\t'); 00440 fprintf(outFile,FORMAT,cuts); fprintf(outFile,"%c",'\t'); 00441 fprintf(outFile,FORMATBIGFLOAT,ms(time)); fprintf(outFile,"%c",'\t'); 00442 fprintf(outFile,FORMATBIGFLOAT,ms(time_sdev)); fprintf(outFile,"%c",'\n'); 00443 fclose( outFile ); 00444 } 00445 00446 struct resultfile { 00447 COORDFLOAT length; 00448 int dim; 00449 NUMBER N; 00450 COUNTER maxloops; 00451 COUNTER cuts; 00452 REAL unitsphere; 00453 unsigned long totaltime; 00454 REAL minfluct; 00455 REAL minfluct_ffactor; 00456 REAL maxfluct; 00457 REAL maxfluct_ffactor; 00458 REAL* radius; 00459 REAL* ffactor; 00460 REAL* biggest; 00461 REAL* average; 00462 REAL* biggest_square; 00463 REAL* average_square; 00464 REAL* biggest_fluct; 00465 REAL* average_fluct; 00466 NUMBER* biggest_this; 00467 REAL* average_this; 00468 COUNTER* loop_no; 00469 unsigned long* time; 00470 public: 00471 resultfile(); 00472 void createtables(COUNTER index); 00473 void destroytables(); 00474 }; 00475 00476 resultfile::resultfile(){} 00477 00478 void resultfile::createtables(COUNTER index) { 00479 radius=new REAL[index+1]; 00480 ffactor=new REAL[index+1]; 00481 biggest=new REAL[index+1]; 00482 average=new REAL[index+1]; 00483 biggest_square=new REAL[index+1]; 00484 average_square=new REAL[index+1]; 00485 biggest_fluct=new REAL[index+1]; 00486 average_fluct=new REAL[index+1]; 00487 biggest_this=new NUMBER[index+1]; 00488 average_this=new REAL[index+1]; 00489 loop_no=new COUNTER[index+1]; 00490 time=new unsigned long[index+1]; 00491 } 00492 00493 void resultfile::destroytables() { 00494 cout<<"destruction"<<endl; 00495 delete[] this->radius,this->ffactor, this->biggest,this->average,this->biggest_square,this->average_square; 00496 delete[] this->biggest_fluct,this->average_fluct,this->biggest_this,this->average_this,this->loop_no,this->time; 00497 } 00498 00499 00500 00501 void testresultstruct(){ 00502 waitanykey(); 00503 resultfile rF; 00504 rF.createtables(70); 00505 waitanykey(); 00506 rF.destroytables(); 00507 } 00508 00509 00510 00511 void read_until_tab(FILE* filestream) { 00512 char c; 00513 do { 00514 c=(char)fgetc(filestream); 00515 } while (c!='\t'); 00516 } 00517 00518 00519 void LoadResultFile (FILE* inFile, resultfile & rF, int ff_steps){ 00520 00521 char stringline[200]; 00522 double totaltime; 00523 COUNTER rstep; 00524 00525 // skip text intro 00526 fgets(stringline,200,inFile); 00527 fgets(stringline,200,inFile); 00528 fgets(stringline,200,inFile); 00529 // read parameters 00530 read_until_tab(inFile); 00531 fscanf(inFile,"%f",& rF.length); 00532 read_until_tab(inFile); 00533 fscanf(inFile,"%d",& rF.dim); 00534 read_until_tab(inFile); 00535 fscanf(inFile,"%ld",& rF.N); 00536 read_until_tab(inFile); 00537 fscanf(inFile,"%d",& rF.maxloops); 00538 read_until_tab(inFile); 00539 read_until_tab(inFile); 00540 fscanf(inFile,"%d",& rF.cuts); 00541 read_until_tab(inFile); 00542 fscanf(inFile,"%lf",& rF.unitsphere); 00543 // skip heading line 00544 fgets(stringline,200,inFile); 00545 fgets(stringline,200,inFile); 00546 fgets(stringline,200,inFile); 00547 // read lines of data, each radius step is one line 00548 for (rstep=0;rstep<=ff_steps;rstep++){ 00549 fscanf(inFile,"%lf",& rF.radius[rstep]); 00550 fscanf(inFile,"%lf",& rF.ffactor[rstep]); 00551 fscanf(inFile,"%lf",& rF.biggest[rstep]); 00552 fscanf(inFile,"%lf",& rF.average[rstep]); 00553 fscanf(inFile,"%lf",& rF.biggest_square[rstep]); 00554 fscanf(inFile,"%lf",& rF.average_square[rstep]); 00555 fscanf(inFile,"%lf",& rF.biggest_fluct[rstep]); 00556 fscanf(inFile,"%lf",& rF.average_fluct[rstep]); 00557 fscanf(inFile,"%ld",& rF.biggest_this[rstep]); 00558 fscanf(inFile,"%lf",& rF.average_this[rstep]); 00559 fscanf(inFile,"%d",& rF.loop_no[rstep]); 00560 fscanf(inFile,"%ld",& rF.time[rstep]); 00561 fgets(stringline,200,inFile); 00562 } 00563 00564 // read the summary (totaltime and fluctuation extrema) 00565 read_until_tab(inFile); 00566 read_until_tab(inFile); 00567 read_until_tab(inFile); 00568 fscanf(inFile,"%lf",& totaltime); 00569 rF.totaltime=(NUMBER)totaltime*1000; 00570 read_until_tab(inFile); 00571 fscanf(inFile,"%lf",& rF.minfluct); 00572 read_until_tab(inFile); 00573 read_until_tab(inFile); 00574 fscanf(inFile,"%lf",& rF.minfluct_ffactor); 00575 read_until_tab(inFile); 00576 fscanf(inFile,"%lf",& rF.maxfluct); 00577 read_until_tab(inFile); 00578 read_until_tab(inFile); 00579 fscanf(inFile,"%lf",& rF.maxfluct_ffactor); 00580 } 00581 00582 void show_resultfile(resultfile rF, int ff_steps){ 00583 cout <<rF.length<<endl; 00584 cout <<rF.dim<<endl; 00585 cout <<rF.N<<endl; 00586 cout <<rF.maxloops<<endl; 00587 cout <<rF.cuts<<endl; 00588 cout <<rF.unitsphere<<endl; 00589 cout <<"\n!!!Now the data!!!"<<endl; 00590 for (COUNTER rstep=0;rstep<=ff_steps;rstep++){ 00591 cout <<rF.radius[rstep]<<"\t"; 00592 cout <<rF.ffactor[rstep]<<"\t"; 00593 cout <<rF.biggest[rstep]<<"\t"; 00594 cout <<rF.average[rstep]<<"\t"; 00595 cout <<rF.biggest_square[rstep]<<"\t"; 00596 cout <<rF.average_square[rstep]<<"\t"; 00597 cout <<rF.biggest_fluct[rstep]<<"\t"; 00598 cout <<rF.average_fluct[rstep]<<"\t"; 00599 cout <<rF.biggest_this[rstep]<<"\t"; 00600 cout <<rF.average_this[rstep]<<"\t"; 00601 cout <<rF.loop_no[rstep]<<"\t"; 00602 cout <<rF.time[rstep]<<"\n"; 00603 } 00604 cout <<rF.totaltime<<endl; 00605 cout <<rF.minfluct<<endl; 00606 cout <<rF.minfluct_ffactor<<endl; 00607 cout <<rF.maxfluct<<endl; 00608 cout <<rF.maxfluct_ffactor<<endl<<endl; 00609 } 00610 00611 void my_fprintf(FILE* outFile, one_result last, NUMBER N, int dim, COORDFLOAT L){ 00612 // TODO: Evtl. Remove all perc...() because spcl_dirs contains all data 00613 fprintf(outFile,FORMATINT,last.percolate()); fprintf(outFile,"%c",'\t'); 00614 fprintf(outFile,FORMATINT,last.perc_lr()); fprintf(outFile,"%c",'\t'); 00615 fprintf(outFile,FORMATINT,last.perc_tb()); fprintf(outFile,"%c",'\t'); 00616 fprintf(outFile,FORMATINT,last.perc_all_dirs(dim)); fprintf(outFile,"%c",'\t'); 00617 fprintf(outFile,FORMATLONG,last.spcl_dirs); fprintf(outFile,"%c",'\t'); 00618 fprintf(outFile,FORMATNUMBER,last.numberof_cl); fprintf(outFile,"%c",'\t'); 00619 fprintf(outFile,FORMATNUMBER,last.biggest_clsz); fprintf(outFile,"%c",'\t'); 00620 fprintf(outFile,FORMATBIGFLOAT,last.mean_clsz); fprintf(outFile,"%c",'\t'); 00621 fprintf(outFile,FORMATBIGFLOAT,last.mean_clsz2); fprintf(outFile,"%c",'\t'); 00622 fprintf(outFile,FORMATBIGFLOAT,ms(last.last_counttime)); fprintf(outFile,"%c",'\t'); 00623 fprintf(outFile,"%s",last.counttime.c_str()); fprintf(outFile,"%c",'\t'); 00624 fprintf(outFile,"%s",last.throwtime.c_str()); fprintf(outFile,"%c",'\t'); 00625 fprintf(outFile,FORMAT,N); fprintf(outFile,"%c",'\t'); 00626 fprintf(outFile,FORMAT,dim); fprintf(outFile,"%c",'\t'); 00627 fprintf(outFile,FORMATBIGFLOAT,L); fprintf(outFile,"%c",'\t'); 00628 } 00629 void my_fprintf_nothing(FILE* outFile){ 00630 fprintf(outFile,"%s"," \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t"); 00631 } 00632 00633 bool write_one_result(const char* filename, REAL ff, one_result one, NUMBER N, int dim, COORDFLOAT L){ 00634 FILE* outFile= fopen( filename, "a+" ); 00635 if (outFile==NULL) {write_error (filename); return false;}; 00636 my_fprintf_ff(outFile,ff,give_radius(ff,N,GRIDSIZE,dim),true); 00637 // true means new result (not only averaging of old ones) 00638 // TODO: true -> enum newresult{no, increment, ffc} 0,1,2 00639 00640 my_fprintf(outFile, one, N, dim, L); 00641 fprintf(outFile, "%s","\n"); 00642 fclose(outFile); 00643 return true; 00644 } 00645 00646 void my_fprintf_heading_oneresult(FILE* outFile) 00647 { 00648 // TODO: remove left-right & top-bottom (is in "..._dirs" anyway) 00649 fprintf(outFile,"%s","spanning_any\t"); 00650 fprintf(outFile,"%s","spanning_lr\tspanning_tb\t"); 00651 fprintf(outFile,"%s","spanning_all\t"); 00652 fprintf(outFile,"%s","spanning_dirs\t"); 00653 fprintf(outFile,"%s","numberof_cl\tbiggest_clsz\tmean_clsz\tmean_clsz2\t"); 00654 fprintf(outFile,"%s","time(ms)\tcounttime\tthrowtime\t"); 00655 fprintf(outFile,"%s","N\tdim\tL\t"); 00656 // TODO: IP-Nummer 00657 } 00658 00659 bool write_intro8 (char *filename, NUMBER no,COORDFLOAT length, int maxloops, int dimension, COUNTER cuts) { 00660 FILE* outFile= fopen( filename, "w" ); 00661 if (outFile==NULL) {write_error (filename); return false;} 00662 else { 00663 fprintf(outFile,"%s","cpp__at__AndreasKrueger__dot__de and his famous clustercount programm (v8.d) present:\n"); 00664 fprintf(outFile,FORMAT,no); fprintf(outFile,"%s"," thrown spheres on a "); 00665 fprintf(outFile,FORMAT,dimension); fprintf(outFile,"%s"," dimensional volume of length "); 00666 fprintf(outFile,FORMATCOORD,length); fprintf(outFile,"%c",'\n'); 00667 fprintf(outFile,"%c",'\n'); 00668 fprintf(outFile,"%s","length of volume\t"); 00669 fprintf(outFile,FORMATCOORD,length); fprintf(outFile,"%c",'\n'); 00670 fprintf(outFile,"%s","dimensions\t"); 00671 fprintf(outFile,FORMAT,dimension); fprintf(outFile,"%c",'\n'); 00672 fprintf(outFile,"%s","number of spheres\t"); 00673 fprintf(outFile,FORMAT,no); fprintf(outFile,"%c",'\n'); 00674 fprintf(outFile,"%s","maximal loops per radius\t"); 00675 fprintf(outFile,FORMAT,maxloops); fprintf(outFile,"%c",'\n'); 00676 fprintf(outFile,"%s","#cuts(N,dim)\t"); 00677 fprintf(outFile,FORMAT,cuts); fprintf(outFile,"%c",'\n'); 00678 fprintf(outFile,"%s","volume of unit sphere\t"); 00679 fprintf(outFile,FORMATEXACT,unitsphere(dimension)); fprintf(outFile,"%c",'\n'); 00680 00681 fprintf(outFile,"%c",'\n'); 00682 my_fprintf_ff_heading(outFile); 00683 00684 // last result 00685 my_fprintf_heading_oneresult(outFile); 00686 // end: last result 00687 00688 // from here: statistics 00689 fprintf(outFile,"%s","loop_no\t"); 00690 fprintf(outFile,"%s","<spanningcl>\tsdev(<spanningcl>)\t"); 00691 fprintf(outFile,"%s","<spanningcl_lr>\tsdev(<spanningcl_lr>)\t"); 00692 fprintf(outFile,"%s","<spanningcl_tb>\tsdev(<spanningcl_tb>)\t"); 00693 fprintf(outFile,"%s","<spanningcl_alldirs>\tsdev(<spanningcl_alldirs>)\t"); 00694 fprintf(outFile,"%s","<numberof_cl>\tsdev(<numberof_cl>)\t"); 00695 00696 fprintf(outFile,"%s","<biggest_clsz>\tsdev(<biggest_clsz>)\t"); 00697 fprintf(outFile,"%s","biggest_clsz.variance\tsdev(biggest_clsz.variance)\t"); 00698 fprintf(outFile,"%s","biggest_clsz.skewness\tsdev(biggest_clsz.skewness)\t"); 00699 fprintf(outFile,"%s","biggest_clsz.kurtosis\tsdev(biggest_clsz.kurtosis)\t"); 00700 00701 fprintf(outFile,"%s","<mean_clsz>\tsdev(<mean_clsz>)\t"); 00702 fprintf(outFile,"%s","<mean_clsz2>\tsdev(<mean_clsz2>)\t"); 00703 fprintf(outFile,"%s","total(clcount-time)(ms)\t"); 00704 fprintf(outFile,"%s","total(spsearch-time)(ms)\n"); 00705 00706 fclose( outFile ) ; 00707 return true; 00708 } 00709 } 00710 00711 bool write_one_step8(char *filename, REAL fillingfactor, REAL radius, 00712 bool new_result, 00713 one_result last, 00714 REAL spcl_av, REAL spcl_sdev, 00715 REAL spcl_lr_av, REAL spcl_lr_sdev, 00716 REAL spcl_tb_av, REAL spcl_tb_sdev, 00717 REAL spcl_alldirs_av, REAL spcl_alldirs_sdev, 00718 REAL numberof_cl_av, REAL numberof_cl_sdev, 00719 REAL biggest_clsz_av, REAL biggest_clsz_sdev, 00720 REAL biggest_clsz_variance, REAL biggest_clsz_variance_sdev, 00721 REAL biggest_clsz_skewness, REAL biggest_clsz_skewness_sdev, 00722 REAL biggest_clsz_kurtosis, REAL biggest_clsz_kurtosis_sdev, 00723 REAL mean_clsz_av, REAL mean_clsz_sdev, 00724 REAL mean_clsz2_av, REAL mean_clsz2_sdev, 00725 COUNTER loop_no, 00726 clock_t time_findcl, 00727 clock_t time_findspcl, 00728 NUMBER N, 00729 int dim) 00730 { 00731 00732 00733 FILE *outFile = fopen( filename, "a+" ); 00734 if (outFile==NULL) {write_error (filename); return false;} 00735 else { 00736 00737 my_fprintf_ff(outFile, fillingfactor, radius, new_result); 00738 00739 if (new_result){ 00740 my_fprintf(outFile, last, N, dim, GRIDSIZE); 00741 } 00742 else { 00743 my_fprintf_nothing(outFile); 00744 } 00745 fprintf(outFile,FORMATCOUNTER,loop_no); fprintf(outFile,"%c",'\t'); 00746 00747 fprintf(outFile,FORMATSMALLFLOAT,spcl_av); fprintf(outFile,"%c",'\t'); 00748 fprintf(outFile,FORMATSMALLFLOAT,spcl_sdev); fprintf(outFile,"%c",'\t'); 00749 fprintf(outFile,FORMATSMALLFLOAT,spcl_lr_av); fprintf(outFile,"%c",'\t'); 00750 fprintf(outFile,FORMATSMALLFLOAT,spcl_lr_sdev); fprintf(outFile,"%c",'\t'); 00751 fprintf(outFile,FORMATSMALLFLOAT,spcl_tb_av); fprintf(outFile,"%c",'\t'); 00752 fprintf(outFile,FORMATSMALLFLOAT,spcl_tb_sdev); fprintf(outFile,"%c",'\t'); 00753 fprintf(outFile,FORMATSMALLFLOAT,spcl_alldirs_av); fprintf(outFile,"%c",'\t'); 00754 fprintf(outFile,FORMATSMALLFLOAT,spcl_alldirs_sdev);fprintf(outFile,"%c",'\t'); 00755 fprintf(outFile,FORMATBIGFLOAT,numberof_cl_av); fprintf(outFile,"%c",'\t'); 00756 fprintf(outFile,FORMATBIGFLOAT,numberof_cl_sdev); fprintf(outFile,"%c",'\t'); 00757 00758 fprintf(outFile,FORMATBIGFLOAT,biggest_clsz_av); fprintf(outFile,"%c",'\t'); 00759 fprintf(outFile,FORMATBIGFLOAT,biggest_clsz_sdev); fprintf(outFile,"%c",'\t'); 00760 fprintf(outFile,FORMATBIGFLOAT,biggest_clsz_variance); fprintf(outFile,"%c",'\t'); 00761 fprintf(outFile,FORMATBIGFLOAT,biggest_clsz_variance_sdev); fprintf(outFile,"%c",'\t'); 00762 fprintf(outFile,FORMATBIGFLOAT,biggest_clsz_skewness); fprintf(outFile,"%c",'\t'); 00763 fprintf(outFile,FORMATBIGFLOAT,biggest_clsz_skewness_sdev); fprintf(outFile,"%c",'\t'); 00764 fprintf(outFile,FORMATBIGFLOAT,biggest_clsz_kurtosis); fprintf(outFile,"%c",'\t'); 00765 fprintf(outFile,FORMATBIGFLOAT,biggest_clsz_kurtosis_sdev); fprintf(outFile,"%c",'\t'); 00766 00767 fprintf(outFile,FORMATBIGFLOAT,mean_clsz_av); fprintf(outFile,"%c",'\t'); 00768 fprintf(outFile,FORMATBIGFLOAT,mean_clsz_sdev); fprintf(outFile,"%c",'\t'); 00769 fprintf(outFile,FORMATBIGFLOAT,mean_clsz2_av); fprintf(outFile,"%c",'\t'); 00770 fprintf(outFile,FORMATBIGFLOAT,mean_clsz2_sdev);fprintf(outFile,"%c",'\t'); 00771 00772 fprintf(outFile,FORMATBIGFLOAT,ms(time_findcl)); fprintf(outFile,"%c",'\t'); 00773 fprintf(outFile,FORMATBIGFLOAT,ms(time_findspcl)); fprintf(outFile,"%c",'\t'); 00774 00775 fprintf(outFile,"%c",'\n'); 00776 00777 fclose( outFile ); 00778 return true; 00779 } 00780 } 00781 00782 00783 void write_results8 (char * filename, 00784 NUMBER N, int dimension, 00785 COUNTER FILE_STEPS, 00786 REAL* R, REAL *ffactor, 00787 all_results* res, 00788 clock_t totaltime, 00789 REAL min_fluctuation, REAL ffactor_min_fluct, 00790 REAL max_fluctuation, REAL ffactor_max_fluct){ 00791 00792 for (COUNTER index=0;index<=FILE_STEPS; index++){ 00793 write_one_step8(filename, ffactor[index], R[index], 00794 res[index].new_result, 00795 res[index].last, 00796 res[index].spcl_cum.mu.av(), res[index].spcl_cum.mu.sdev(), 00797 res[index].spcl_lr_cum.mu.av(), res[index].spcl_lr_cum.mu.sdev(), 00798 res[index].spcl_tb_cum.mu.av(), res[index].spcl_tb_cum.mu.sdev(), 00799 res[index].spcl_alldirs_cum.mu.av(),res[index].spcl_alldirs_cum.mu.sdev(), 00800 res[index].numberof_cl.mu.av(), res[index].numberof_cl.mu.sdev(), 00801 res[index].biggest_clsz.mu.av(),res[index].biggest_clsz.mu.sdev(), 00802 res[index].biggest_clsz.variance.av(),res[index].biggest_clsz.variance.sdev(), 00803 res[index].biggest_clsz.skewness.av(),res[index].biggest_clsz.skewness.sdev(), 00804 res[index].biggest_clsz.kurtosis.av(),res[index].biggest_clsz.kurtosis.sdev(), 00805 res[index].mean_clsz.mu.av(), res[index].mean_clsz.mu.sdev(), 00806 res[index].mean_clsz2.mu.av(), res[index].mean_clsz2.mu.sdev(), 00807 res[index].loop_no, 00808 res[index].sum_time, 00809 res[index].sum_spsearch_time, 00810 N, dimension); 00811 } 00812 00813 closefile7( filename, totaltime, 00814 min_fluctuation, ffactor_min_fluct, 00815 max_fluctuation, ffactor_max_fluct); 00816 } 00817 00818 00819 void save_results8(int dim, NUMBER N, 00820 COUNTER maxloops, 00821 REAL ff_from, REAL ff_to, COUNTER ff_steps, 00822 COUNTER cuts, 00823 REAL* R, REAL* ffactor, 00824 all_results* res, 00825 clock_t starttime, 00826 REAL min_fluctuation, REAL ffactor_min_fluct, 00827 REAL max_fluctuation, REAL ffactor_max_fluct 00828 ) 00829 { 00830 char filename[100]; 00831 // save to network harddisc: 00832 setfilename(filename,FILEHEAD1,N,dim,maxloops, ff_from, ff_to, ff_steps); 00833 write_intro8(filename,N,GRIDSIZE, maxloops, dim, cuts); 00834 write_results8(filename, N, dim, 00835 ff_steps, R, ffactor, 00836 res, 00837 clock()-starttime, 00838 min_fluctuation, ffactor_min_fluct, 00839 max_fluctuation, ffactor_max_fluct); 00840 // local copy for security reasons: 00841 setfilename(filename,FILEHEAD2,N,dim,maxloops, ff_from, ff_to, ff_steps); 00842 write_intro8(filename,N,GRIDSIZE, maxloops, dim, cuts); 00843 write_results8(filename, N, dim, 00844 ff_steps, R, ffactor, 00845 res, 00846 clock()-starttime, 00847 min_fluctuation, ffactor_min_fluct, 00848 max_fluctuation, ffactor_max_fluct); 00849 } 00850 00851 bool create_clusteranalysis_resultfile(const char* filename, string namecriterion){ 00852 FILE* outFile= fopen(filename, "w" ); 00853 if (outFile==NULL) {write_error (filename); return false;}; 00854 fprintf(outFile,"%s","Andreas Krueger (cpp__at__AndreasKrueger__dot__de) presents:\n"); 00855 fprintf(outFile,"%s","results of clusteranalysis around the "); 00856 fprintf(outFile,"%s",namecriterion.c_str()); 00857 fprintf(outFile,"%s"," fillingfactor (" ); 00858 fprintf(outFile,"%s",version); 00859 fprintf(outFile,"%s",")\n\n"); 00860 00861 my_fprintf_ff_heading(outFile); 00862 my_fprintf_heading_oneresult(outFile); 00863 fprintf(outFile,"%s","\n"); 00864 00865 fclose(outFile); 00866 return true; 00867 } 00868 00869 void my_fprintf(FILE* outFile, muvarskewkurt<REAL>& avr){ 00870 fprintf(outFile,FORMATSMALLFLOAT,avr.mu.av()); fprintf(outFile,"%c",'\t'); 00871 fprintf(outFile,FORMATSMALLFLOAT,avr.mu.sdev());fprintf(outFile,"%c",'\t'); 00872 fprintf(outFile,FORMATSMALLFLOAT,avr.variance.av()); fprintf(outFile,"%c",'\t'); 00873 fprintf(outFile,FORMATSMALLFLOAT,avr.variance.sdev()); fprintf(outFile,"%c",'\t'); 00874 fprintf(outFile,FORMATSMALLFLOAT,avr.skewness.av()); fprintf(outFile,"%c",'\t'); 00875 fprintf(outFile,FORMATSMALLFLOAT,avr.skewness.sdev()); fprintf(outFile,"%c",'\t'); 00876 fprintf(outFile,FORMATSMALLFLOAT,avr.kurtosis.av()); fprintf(outFile,"%c",'\t'); 00877 fprintf(outFile,FORMATSMALLFLOAT,avr.kurtosis.sdev()); fprintf(outFile,"%c",'\t'); 00878 } 00879 00880 bool create_ffc_file(const char* filename){ 00881 FILE* outFile= fopen( filename, "w" ); 00882 if (outFile==NULL) {write_error (filename); return false;}; 00883 fprintf(outFile,"%s","Andreas Krueger (cpp__at__AndreasKrueger__dot__de) presents:\n"); 00884 fprintf(outFile,"%s","bracket the critical fillingfactor ("); 00885 fprintf(outFile,"%s",version); 00886 fprintf(outFile,"%s",")\n\n"); 00887 00888 fprintf(outFile,"%s","dim\tN\tL\tff.perc_lr\tff.perc_lr.dev\t"); 00889 fprintf(outFile,"%s","time[ms]\tstep\tmissedleft\tmissedright\t"); 00890 fprintf(outFile,"%s","<ffc>\t<ffc>.dev\tvariance(<ffc>)\tvariance(<ffc>).dev\t"); 00891 fprintf(outFile,"%s","skewness(<ffc>)\tskewness(<ffc>).dev\t"); 00892 fprintf(outFile,"%s","kurtosis(<ffc>)\tkurtosis(<ffc>).dev\t"); 00893 fprintf(outFile,"%s","timestamp"); 00894 fprintf(outFile,"%s","\n"); 00895 fclose(outFile); 00896 return true; 00897 } 00898 bool write_ff_line(const char* filename, NUMBER N, int dim, COORDFLOAT L, measure<REAL> one_ff, clock_t brackettime, 00899 COUNTER loop, COUNTER missedleft, COUNTER missedright, muvarskewkurt<REAL>& ff, 00900 const char* timestamp){ 00901 FILE* outFile= fopen( filename, "a+" ); 00902 if (outFile==NULL) {write_error (filename); return false;} 00903 else { 00904 fprintf(outFile,FORMATINT,dim); fprintf(outFile,"%c",'\t'); 00905 fprintf(outFile,FORMATNUMBER,N); fprintf(outFile,"%c",'\t'); 00906 fprintf(outFile,FORMATBIGFLOAT,L); fprintf(outFile,"%c",'\t'); 00907 fprintf(outFile,FORMATSMALLFLOAT,one_ff.av()); fprintf(outFile,"%c",'\t'); 00908 fprintf(outFile,FORMATSMALLFLOAT,one_ff.sdev());fprintf(outFile,"%c",'\t'); 00909 fprintf(outFile,FORMATBIGFLOAT,ms(brackettime));fprintf(outFile,"%c",'\t'); 00910 fprintf(outFile,FORMATCOUNTER,loop); fprintf(outFile,"%c",'\t'); 00911 fprintf(outFile,FORMATCOUNTER,missedleft); fprintf(outFile,"%c",'\t'); 00912 fprintf(outFile,FORMATCOUNTER,missedright); fprintf(outFile,"%c",'\t'); 00913 00914 my_fprintf(outFile, ff); 00915 00916 fprintf(outFile,"%s",timestamp); fprintf(outFile,"%c",'\t'); 00917 } 00918 fprintf(outFile,"%c",'\n'); 00919 fclose(outFile); 00920 return true; 00921 } 00922 00923 bool create_ff_file(const char* filename, string namecriterion){ 00924 FILE* outFile= fopen( filename, "w" ); 00925 if (outFile==NULL) {write_error (filename); return false;}; 00926 fprintf(outFile,"%s","Andreas Krueger (cpp__at__AndreasKrueger__dot__de) presents:\n"); 00927 fprintf(outFile,"%s","bracket the fillingfactor "); 00928 fprintf(outFile,"%s",namecriterion.c_str()); 00929 fprintf(outFile,"%s"," ("); 00930 fprintf(outFile,"%s",version); 00931 fprintf(outFile,"%s",")\n\n"); 00932 00933 fprintf(outFile,"%s","dim\tN\tL\tone_"); fprintf(outFile,"%s",namecriterion.c_str()); 00934 fprintf(outFile,"%s","\tone_"); fprintf(outFile,"%s",namecriterion.c_str()); 00935 fprintf(outFile,"%s",".dev\t"); 00936 fprintf(outFile,"%s","time[ms]\tstep\tmissedleft\tmissedright\t"); 00937 fprintf(outFile,"%s","<ff>\t<ff>.dev\tvariance(<ff>)\tvariance(<ff>).dev\t"); 00938 fprintf(outFile,"%s","skewness(<ff>)\tskewness(<ff>).dev\t"); 00939 fprintf(outFile,"%s","kurtosis(<ff>)\tkurtosis(<ff>).dev\t"); 00940 fprintf(outFile,"%s","timestamp"); 00941 fprintf(outFile,"%s","\n"); 00942 fclose(outFile); 00943 return true; 00944 } 00945 00946 bool create_ffc_bestresults_file(const char* filename){ 00947 FILE* outFile= fopen( filename, "w" ); 00948 if (outFile==NULL) {write_error (filename); return false;}; 00949 fprintf(outFile,"%s","Andreas Krueger (cpp__at__AndreasKrueger__dot__de) presents:\n"); 00950 fprintf(outFile,"%s","Best results of the critical fillingfactor after many steps ("); 00951 fprintf(outFile,"%s",version); 00952 fprintf(outFile,"%s",")\n\n"); 00953 00954 fprintf(outFile,"%s","dim\tN\tL\t"); 00955 fprintf(outFile,"%s","steps\tmissedleft\tmissedright\t"); 00956 fprintf(outFile,"%s","min_ffc\tmax_ffc\t"); 00957 fprintf(outFile,"%s","<ffc>\t<ffc>.dev\tvariance(<ffc>)\tvariance(<ffc>).dev\t"); 00958 fprintf(outFile,"%s","skewness(<ffc>)\tskewness(<ffc>).dev\t"); 00959 fprintf(outFile,"%s","kurtosis(<ffc>)\tkurtosis(<ffc>).dev\t"); 00960 fprintf(outFile,"%s","time[ms]\tend-timestamp"); 00961 fprintf(outFile,"%s","\n"); 00962 fclose(outFile); 00963 return true; 00964 } 00965 00966 bool create_ff_bestresults_file(const char* filename, string namecriterion){ 00967 FILE* outFile= fopen( filename, "w" ); 00968 if (outFile==NULL) {write_error (filename); return false;}; 00969 fprintf(outFile,"%s","Andreas Krueger (cpp__at__AndreasKrueger__dot__de) presents:\n"); 00970 fprintf(outFile,"%s","Best results of the fillingfactor "); 00971 fprintf(outFile,"%s",namecriterion.c_str()); 00972 fprintf(outFile,"%s"," after many steps ("); 00973 fprintf(outFile,"%s",version); 00974 fprintf(outFile,"%s",")\n\n"); 00975 00976 fprintf(outFile,"%s","dim\tN\tL\t"); 00977 fprintf(outFile,"%s","steps\tmissedleft\tmissedright\t"); 00978 fprintf(outFile,"%s","min_ff\tmax_ff\t"); 00979 fprintf(outFile,"%s","<ff>\t<ff>.dev\tvariance(<ff>)\tvariance(<ff>).dev\t"); 00980 fprintf(outFile,"%s","skewness(<ff>)\tskewness(<ff>).dev\t"); 00981 fprintf(outFile,"%s","kurtosis(<ff>)\tkurtosis(<ff>).dev\t"); 00982 fprintf(outFile,"%s","time[ms]\tend-timestamp"); 00983 fprintf(outFile,"%s","\n"); 00984 fclose(outFile); 00985 return true; 00986 } 00987 00988 bool write_best_ff_line(const char* filename, 00989 NUMBER N, int dim, COORDFLOAT L, muvarskewkurt<REAL>& ff, 00990 COUNTER steps, COUNTER missedleft, COUNTER missedright, 00991 REAL leftlimit, REAL rightlimit, 00992 clock_t totaltime, const char* timestamp){ 00993 00994 FILE* outFile= fopen( filename, "a+" ); 00995 if (outFile==NULL) {write_error (filename); return false;} 00996 else { 00997 fprintf(outFile,FORMATINT,dim); fprintf(outFile,"%c",'\t'); 00998 fprintf(outFile,FORMATNUMBER,N); fprintf(outFile,"%c",'\t'); 00999 fprintf(outFile,FORMATBIGFLOAT,L); fprintf(outFile,"%c",'\t'); 01000 fprintf(outFile,FORMATCOUNTER,steps); fprintf(outFile,"%c",'\t'); 01001 fprintf(outFile,FORMATCOUNTER,missedleft); fprintf(outFile,"%c",'\t'); 01002 fprintf(outFile,FORMATCOUNTER,missedright); fprintf(outFile,"%c",'\t'); 01003 fprintf(outFile,FORMATSMALLFLOAT,leftlimit); fprintf(outFile,"%c",'\t'); 01004 fprintf(outFile,FORMATSMALLFLOAT,rightlimit); fprintf(outFile,"%c",'\t'); 01005 my_fprintf(outFile, ff); 01006 fprintf(outFile,FORMATBIGFLOAT,ms(totaltime)); fprintf(outFile,"%c",'\t'); 01007 fprintf(outFile,"%s",timestamp); fprintf(outFile,"%c",'\t'); 01008 } 01009 fprintf(outFile,"%c",'\n'); 01010 fclose(outFile); 01011 return true; 01012 } 01013 01014 bool write_best_ff_outofmemory(const char* filename, 01015 NUMBER N, int dim, 01016 const char* objectname){ 01017 01018 FILE* outFile= fopen( filename, "a+" ); 01019 if (outFile==NULL) {write_error (filename); return false;} 01020 else { 01021 fprintf(outFile,FORMATINT,dim); fprintf(outFile,"%c",'\t'); 01022 fprintf(outFile,FORMATNUMBER,N); fprintf(outFile,"%c",'\t'); 01023 fprintf(outFile,"%s","Out of memory:"); 01024 fprintf(outFile,"%s",objectname); 01025 fprintf(outFile,"%c",'\n'); 01026 fclose(outFile); 01027 return true; 01028 } 01029 } 01030 01031 01032 } // end of namespace datafiles
Diploma Thesis Sourcecode
Documentation check out the text and the executable binaries |