Diploma Thesis Percolation Simulation
C++ Sourcecode Documentation

www.AndreasKrueger.de/thesis/code

Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

little_helpers.h File Reference

#include <string>
#include <sys/timeb.h>
#include <time.h>

Include dependency graph for little_helpers.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Defines

#define EXIT_OUTOFMEMORY   -1

Typedefs

typedef std::list< NUMBER > NUMLIST

Functions

void waitanykey ()
void errorout (char *text)
void exit_out_of_memory (char *where)
long rounded (double floating)
void give_ms (char *milliseconds)
void give_timestamp (char *timestamp)
void give_short_timestamp (char *timestamp)
string give_short_timestamp (void)
string give_timestamp (void)
string timestamp_fullyear ()
void test_timestamp ()
void waitreturnkey ()
REAL ms (clock_t clockticks)
REAL ms (REAL clockticks)
bool is_in_list (NUMLIST &list1, NUMBER element)
void write_the_list_into_file (char *fn, NUMLIST &li)
void show_ascii_table ()
void heat_random_generator ()

Variables

const int TIMESTAMP_LENGTH = 18
const int SHORT_TIMESTAMP_LENGTH = 16


Define Documentation

#define EXIT_OUTOFMEMORY   -1
 

Definition at line 29 of file little_helpers.h.

Referenced by exit_out_of_memory().


Typedef Documentation

typedef std::list<NUMBER> NUMLIST
 

Definition at line 164 of file little_helpers.h.

Referenced by is_in_list(), and write_the_list_into_file().


Function Documentation

void errorout char *    text
 

Definition at line 24 of file little_helpers.h.

Referenced by grid::boxcount_analyze_and_return_clusters(), counters::combine(), counters::count_analyze_and_return_clusters(), counters::divide_count_and_analyze(), starters::listcount(), lower(), myVector::myVector(), operator-(), myVector::operator-=(), myVector::operator=(), counters::reference_test(), spanning_directions(), analyze::spanning_directions(), spanning_dirs_and_clusters(), analyze::spanning_dirs_and_clusters(), starters::test_list(), and datafiles::write_error().

00024                          {
00025         cout <<"ERROR: "<<text<<endl;
00026 }

void exit_out_of_memory char *    where
 

Definition at line 32 of file little_helpers.h.

References EXIT_OUTOFMEMORY, and waitanykey().

Referenced by counters::divide_count_and_analyze(), starters::into_file8_pt1(), and counters::setR_count_analyze_step().

00032                                     {
00033         cout <<"\nOut of memory! \nAt position:\n ";
00034         cout <<where<<endl;
00035         cout <<"I will stop here..."<<endl;
00036         waitanykey();
00037         exit(EXIT_OUTOFMEMORY);
00038 }

void give_ms char *    milliseconds
 

Definition at line 66 of file little_helpers.h.

Referenced by give_short_timestamp(), and give_timestamp().

00066                                 {
00067         sprintf(milliseconds, "%s", "000");
00068 }

string give_short_timestamp void   
 

Definition at line 114 of file little_helpers.h.

References SHORT_TIMESTAMP_LENGTH.

Referenced by ff::find_mean_ff_with_criterion(), ff::find_mean_ffc(), counters::setR_count_analyze_step(), and counters::throw_dnc_count_analyze_step().

00114                                  {
00115         string temp; 
00116         char buffer[SHORT_TIMESTAMP_LENGTH];
00117         give_short_timestamp(buffer);
00118         temp=buffer;
00119         return temp;
00120 }       

void give_short_timestamp char *    timestamp
 

Definition at line 99 of file little_helpers.h.

References give_ms(), ms(), and TIMESTAMP_LENGTH.

00099                                           {
00100                 time_t utctime;
00101                 time (& utctime);
00102                 struct tm * todaylocal;
00103                 todaylocal=localtime(&utctime);
00104 
00105                 strcpy (timestamp, "");
00106                 char localtime[TIMESTAMP_LENGTH-3];
00107                 strftime(localtime, TIMESTAMP_LENGTH-3,"%y%m%d%H%M%S", todaylocal);
00108                 strcat (timestamp, localtime);
00109 
00110                 char ms[4];strcpy (ms, "");
00111                 give_ms(ms); strcat (timestamp, ms);
00112 }

string give_timestamp void   
 

Definition at line 122 of file little_helpers.h.

References TIMESTAMP_LENGTH.

Referenced by test_timestamp(), and timestamp_fullyear().

00122                            {
00123         string temp; 
00124         char buffer[TIMESTAMP_LENGTH];
00125         give_timestamp(buffer);
00126         temp=buffer;
00127         return temp;
00128 }

void give_timestamp char *    timestamp
 

Definition at line 84 of file little_helpers.h.

References give_ms(), ms(), and TIMESTAMP_LENGTH.

00084                                     {
00085                 time_t utctime;
00086                 time (& utctime);
00087                 struct tm * todaylocal;
00088                 todaylocal=localtime(&utctime);
00089 
00090                 strcpy (timestamp, "");
00091                 char localtime[TIMESTAMP_LENGTH-3];
00092                 strftime(localtime, TIMESTAMP_LENGTH-3,"%Y%m%d%H%M%S", todaylocal);
00093                 strcat (timestamp, localtime);
00094 
00095                 char ms[4];strcpy (ms, "");
00096                 give_ms(ms); strcat (timestamp, ms);
00097 }

void heat_random_generator  
 

Definition at line 194 of file little_helpers.h.

References pow().

Referenced by ff::find_ff_with_criterion_scanning_N_and_dim(), and ff::find_ffc_scanning_N_and_dim().

00194                             {
00195         cout <<"heat the random generator by 10^7 runs..."<<endl;
00196         long i;
00197         for (long j=9;j>=0;j--){
00198                 cout <<j<<flush;
00199                 for (i=1;i<=pow(10,6);i++){rand();};
00200         }
00201 }

bool is_in_list NUMLIST   list1,
NUMBER    element
 

Definition at line 168 of file little_helpers.h.

References NUMBER, and NUMLIST.

00168                                                {
00169         NUMLIST::iterator e;
00170         bool temp=false;
00171         for (e=list1.begin();e!=list1.end();e++){
00172                 if (*e==element) temp=true;
00173         }
00174         return temp;
00175 }

REAL ms REAL    clockticks
 

Definition at line 159 of file little_helpers.h.

References REAL.

Referenced by optimize::choose_cuts_with_reference_algo(), optimize::choose_dividings(), datafiles::closefile(), datafiles::closefile7(), optimize::compare_recursion_and_Stoddard_iteration(), optimize::double_N_and_run_all_faster_cuts(), optimize::double_N_and_run_specified_cuts(), starters::into_file(), starters::into_file2(), starters::into_file7_pt1(), starters::into_file8_pt1(), starters::into_screen(), starters::listcount(), main(), datafiles::my_fprintf(), optimize::new_vs_old_algo(), counters::reference_test(), optimize::run_different_cuts(), optimize::test_average_time_for_specified_cuts(), optimize::testspeedof_intersection_procedures(), testspeedof_intersection_procedures(), datafiles::write_best_ff_line(), datafiles::write_ff_line(), datafiles::write_one_averaged_cut(), datafiles::write_one_cut(), datafiles::write_one_step(), datafiles::write_one_step7(), and datafiles::write_one_step8().

00159                         {       
00160         return clockticks/(REAL)CLOCKS_PER_SEC*1000; 
00161 }

REAL ms clock_t    clockticks
 

Definition at line 154 of file little_helpers.h.

References REAL.

Referenced by give_short_timestamp(), and give_timestamp().

00154                            {    
00155         return (REAL)clockticks/(REAL)CLOCKS_PER_SEC*1000; 
00156 }

long rounded double    floating
 

Definition at line 41 of file little_helpers.h.

Referenced by counters::choose_optimal_cuts(), ff::find_ff_with_criterion_frontend(), ff::find_ffc_frontend(), and optimize::test_average_time_for_specified_cuts().

00041                               {
00042         return ((long)floor(floating+0.5));
00043 }

void show_ascii_table  
 

Definition at line 187 of file little_helpers.h.

00187                         {
00188         for (int c=0;c<=256;c++){
00189                 cout <<c<<":"<< (char)c<<"\t";
00190         }
00191         cout <<endl;
00192 }

void test_timestamp  
 

Definition at line 139 of file little_helpers.h.

References give_timestamp(), and TIMESTAMP_LENGTH.

00139                      {
00140         char timestamp[TIMESTAMP_LENGTH];
00141         strcpy (timestamp, "");
00142         for (;;){
00143                 give_timestamp(timestamp);
00144                 cout <<timestamp<<endl;
00145         }
00146 }

string timestamp_fullyear  
 

Definition at line 130 of file little_helpers.h.

References give_timestamp(), and TIMESTAMP_LENGTH.

Referenced by ff::find_ff_with_criterion_scanning_N_and_dim(), and ff::find_ffc_scanning_N_and_dim().

00130                            {
00131         string temp; 
00132         char buffer[TIMESTAMP_LENGTH];
00133         give_timestamp(buffer);
00134         temp=buffer;
00135         temp=temp.substr(0,TIMESTAMP_LENGTH-4);
00136         return temp;
00137 }

void waitanykey  
 

Definition at line 16 of file little_helpers.h.

Referenced by grid::boxcount_analyze_and_return_clusters(), optimize::choose_cuts_with_reference_algo(), optimize::choose_dividings(), counters::divide_count_and_analyze(), grid::divide_spheres_into_overlapping_boxes_and_conquer(), exit_out_of_memory(), optimize::frontend_cuts_test_average_time(), starters::into_screen(), optimize::new_vs_old_algo(), grid::relabel_clusternumbers_in_spheres(), optimize::run_different_cuts(), datafiles::set_and_show_filename(), grid::test_spheres2boxes(), datafiles::testresultstruct(), and starters::unitspheredimensions().

00016                  {
00017         char input; 
00018         cout << "Please press any key and <return>";
00019         cin >> input;
00020         cout << endl;
00021         cout <<"******************************************"<<endl;
00022 }

void waitreturnkey  
 

Definition at line 150 of file little_helpers.h.

00150                      {
00151         for (;!cin.get();) {};
00152 }

void write_the_list_into_file char *    fn,
NUMLIST   li
 

Definition at line 177 of file little_helpers.h.

References NUMLIST.

00177                                                     {
00178         FILE* outFile=fopen(fn, "w");
00179         NUMLIST::iterator e;
00180         for (e=li.begin();e!=li.end();e++){
00181                 fprintf(outFile, "%d",*e);              fprintf(outFile, "%s","\n");
00182         }
00183         fprintf(outFile, "%s","\n");
00184         fclose(outFile);
00185 }


Variable Documentation

const int SHORT_TIMESTAMP_LENGTH = 16
 

Definition at line 73 of file little_helpers.h.

Referenced by give_short_timestamp().

const int TIMESTAMP_LENGTH = 18
 

Definition at line 72 of file little_helpers.h.

Referenced by give_short_timestamp(), give_timestamp(), test_timestamp(), and timestamp_fullyear().




Diploma Thesis Sourcecode Documentation
check out the text and the executable binaries

www.AndreasKrueger.de/thesis/code