]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/real.hh
*** empty log message ***
[lilypond.git] / flower / include / real.hh
1 /*
2   real.hh -- declare Real
3
4   source file of the Flower Library
5
6   (c) 1997--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #ifndef REAL_HH
10 #define REAL_HH
11
12 #include <algorithm>
13 #include <climits>
14
15 /*
16   MacOS 10.3 uses g++ 3.3 which doesn't have std::isinf()
17  */
18 // #include <cmath>
19 #include <math.h>
20 using namespace std;
21
22
23 typedef double Real;
24 extern const Real infinity_f;
25
26 /* namespace std { */
27   
28 template<class T> inline T abs (T x)
29 {
30   return x > 0 ? x : -x;
31 }
32
33 /* } namespace std */
34
35 inline Real
36 distance (Real x, Real y)
37 {
38   return abs (x - y);
39 }
40
41 template<class T> inline int sign (T x)
42 {
43   if (x)
44     return x > T (0) ? 1 : -1;
45   return 0;
46 }
47
48 template<class T> inline T sqr (T x)
49 {
50   return x * x;
51 }
52
53 #endif