]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/real.hh
release: 0.1.48
[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
21 template<class T> inline T abs (T x)
22 {
23   return x > 0 ? x : -x;
24 }
25
26 template<class T> inline int sign (T x)
27 {
28   if (x)
29     return x > 0 ? 1 : -1;
30   return 0;
31 }
32
33 template<class T> inline T max (T x, T y)
34 {
35   return x >? y;
36 }
37
38 template<class T> inline T sqr (T x)
39 {
40   return x*x;
41 }
42
43
44 template<class T> inline T min (T x, T y)
45 {
46   return x <? y;
47 }
48
49 inline Real
50 distance (Real x,Real y)
51 {
52     return abs (x-y);
53 }
54
55 #endif