Cosmetics + fixed the entrance in last time frame and exits in first time frame.
[mtp.git] / misc.h
1
2 ////////////////////////////////////////////////////////////////////
3 // START_IP_HEADER                                                //
4 //                                                                //
5 // Written by Francois Fleuret                                    //
6 // Contact <francois.fleuret@idiap.ch> for comments & bug reports //
7 //                                                                //
8 // END_IP_HEADER                                                  //
9 ////////////////////////////////////////////////////////////////////
10
11 #ifndef MISC_H
12 #define MISC_H
13
14 #include <stdlib.h>
15
16 // #define VERBOSE
17
18 typedef float scalar_t;
19
20 #ifdef DEBUG
21 #define ASSERT(x) if(!(x)) {                                            \
22     std::cerr << "ASSERT FAILED IN " << __FILE__ << ":" << __LINE__ << endl; \
23     abort();                                                            \
24   }
25 #else
26 #define ASSERT(x)
27 #endif
28
29 template<class T>
30 T **allocate_array(int a, int b) {
31   T *whole = new T[a * b];
32   T **array = new T *[a];
33   for(int k = 0; k < a; k++) {
34     array[k] = whole;
35     whole += b;
36   }
37   return array;
38 }
39
40 template<class T>
41 void deallocate_array(T **array) {
42   if(array) {
43     delete[] array[0];
44     delete[] array;
45   }
46 }
47
48 #endif