20 #ifdef HAVE_MKL // obsolete 37 #ifndef MATLAB_MEX_FILE 42 #define MAX_THREADS 64 47 #define MIN(a,b) (((a) > (b)) ? (b) : (a)) 48 #define MAX(a,b) (((a) > (b)) ? (a) : (b)) 49 #define SIGN(a) (((a) < 0) ? -1.0 : 1.0) 51 #define ABS(a) (((a) < 0) ? -(a) : (a)) 54 #define PRINT_I(name) printf(#name " : %d\n",name); 55 #define PRINT_F(name) printf(#name " : %g\n",name); 56 #define PRINT_S(name) printf("%s\n",name); 57 #define FLAG(a) printf("flag : %d \n",a); 60 #define EPSILON 10e-10 62 #define INFINITY 10e20 64 #define EPSILON_OMEGA 0.001 65 #define TOL_CGRAD 10e-6 66 #define MAX_ITER_CGRAD 40 76 #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) 77 #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64 79 #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL 89 int gettimeofday(
struct timeval *tv,
struct timezone *tz)
92 unsigned __int64 tmpres = 0;
93 static int tzflag = 0;
97 GetSystemTimeAsFileTime(&ft);
99 tmpres |= ft.dwHighDateTime;
101 tmpres |= ft.dwLowDateTime;
105 tmpres -= DELTA_EPOCH_IN_MICROSECS;
106 tv->tv_sec = (long)(tmpres / 1000000UL);
107 tv->tv_usec = (long)(tmpres % 1000000UL);
117 tz->tz_minuteswest = _timezone / 60;
118 tz->tz_dsttime = _daylight;
125 #include <sys/time.h> 146 void inline start() { _running=
true;
147 gettimeofday(_time1,NULL); };
150 gettimeofday(_time2,NULL);
152 _cumul+=
static_cast<double>((_time2->tv_sec - (_time1->tv_sec))*1000000 + _time2->tv_usec-_time1->tv_usec)/1000000.0;
156 gettimeofday(_time1,NULL); };
158 void inline printElapsed();
160 double inline getElapsed()
const;
170 Timer::Timer() :_running(false) ,_cumul(0) {
171 _time1 = (
struct timeval*)malloc(
sizeof(
struct timeval));
172 _time2 = (
struct timeval*)malloc(
sizeof(
struct timeval));
184 gettimeofday(
_time2,NULL);
185 cerr <<
"Time elapsed : " <<
_cumul +
static_cast<double>((
_time2->tv_sec -
188 cerr <<
"Time elapsed : " <<
_cumul << endl;
195 gettimeofday(
_time2,NULL);
197 static_cast<double>((
_time2->tv_sec -
199 _time1->tv_usec)/1000000.0;
void start()
start the time
void printElapsed()
print the elapsed time
double getElapsed() const
print the elapsed time
void reset()
reset the timer