]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/real.hh
release: 0.1.58
[lilypond.git] / flower / include / real.hh
1 /*
2   real.hh -- declare Real
3
4   source file of the Flower Library
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9
10 #ifndef REAL_HH
11 #define REAL_HH
12
13
14 #include <math.h>
15 #include <limits.h>
16
17 typedef double Real;
18 const Real infinity_f = HUGE_VAL;
19
20 template<class T> inline T abs (T x)
21 {
22   return x > 0 ? x : -x;
23 }
24
25 template<class T> inline int sign (T x)
26 {
27   if (x)
28     return x > 0 ? 1 : -1;
29   return 0;
30 }
31
32 template<class T> inline T max (T x, T y)
33 {
34   return x >? y;
35 }
36
37 template<class T> inline T sqr (T x)
38 {
39   return x*x;
40 }
41
42
43 template<class T> inline T min (T x, T y)
44 {
45   return x <? y;
46 }
47
48 inline Real
49 distance (Real x,Real y)
50 {
51     return abs (x-y);
52 }
53
54 #endif