00001
00046 #ifndef __HELPER_FUNCTIONS_H__
00047 #define __HELPER_FUNCTIONS_H__
00048
00049 #ifdef WIN32
00050 #define isnan _isnan
00051 #define finite _finite
00052 #endif
00053
00054 #include "fstream.h"
00055
00056
00057 #ifndef INFINITY
00058 #define INFINITY 1000000
00059 #endif
00060
00061 #define round(x) ( x < 0 ? -(int)(0.5-x) : (int)(x+0.5) )
00062
00063 #define MIN(X, Y) ( (X) <= (Y) ? (X):(Y) )
00064 #define MAX(X, Y) ( (X) >= (Y) ? (X):(Y) )
00065
00066 #define SIGN(X) ((X) == 0.0 ? 0:int((X) / fabs(X)))
00067
00068 #define PRINT(OS, EXP) OS << #EXP << ": " << EXP << ", "
00069 #define PRINTN(OS, EXP) OS << #EXP << ": " << EXP << endl
00070
00071 #define PRINT_OPEN(OS, EXP) OS << '[' << #EXP << ": " << EXP << ", "
00072 #define PRINT_CLOSE(OS, EXP) OS << #EXP << ": " << EXP << ']' << endl
00073
00074 #define ShowError(M) cerr << "\n\nERROR: " << M << endl
00075 #define ShowMsg(M) cout << endl << M << endl
00076
00077 double SIMILARITY(double x, double y, const double& minVal = .1);
00078
00079 class LogFile : public fstream
00080 {
00081
00082 public:
00083 LogFile() {}
00084 LogFile(const char* szFileName);
00085 void Print(const char* szFormat, ...);
00086 };
00087
00088 #endif //__HELPER_FUNCTIONS_H__