Update.
[universe.git] / misc.h
1
2 // Written and (C) by Francois Fleuret
3 // Contact <francois.fleuret@idiap.ch> for comments & bug reports
4
5 #ifndef MISC_H
6 #define MISC_H
7
8 #include <float.h>
9 #include <stdlib.h>
10
11 #ifdef DEBUG
12 #define ASSERT(x, s) if(!(x)) { std::cerr << "ASSERT FAILED IN " << __FILE__ << ":" << __LINE__ << " [" << (s) << "]\n"; abort(); }
13 #else
14 #define ASSERT(x, s)
15 #endif
16
17 // typedef float scalar_t;
18 typedef double scalar_t;
19
20 inline scalar_t sq(scalar_t x) { return x*x; }
21
22 inline scalar_t prod_vect(scalar_t x1, scalar_t y1, scalar_t x2, scalar_t y2) {
23   return x1 * y2 - x2 * y1;
24 }
25
26 struct Couple {
27   int index;
28   scalar_t value;
29 };
30
31 int compare_couple(const void *a, const void *b);
32
33 #endif