]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/real.hh
* lily/general-scheme.cc: remove my_{isinf,isnan}.
[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@cs.uu.nl>
7 */
8
9 #ifndef REAL_HH
10 #define REAL_HH
11
12 #include <algorithm>
13 #include <climits>
14 #include <cmath>
15
16 typedef double Real;
17 extern const Real infinity_f;
18 using namespace std;
19 using std::isnan;
20 using std::isinf;
21
22 template<class T> inline T abs (T x)
23 {
24   return x > 0 ? x : -x;
25 }
26
27 template<class T> inline int sign (T x)
28 {
29   if (x)
30     return x > T (0) ? 1 : -1;
31   return 0;
32 }
33
34 template<class T> inline T sqr (T x)
35 {
36   return x * x;
37 }
38
39 inline Real
40 distance (Real x, Real y)
41 {
42   return abs (x - y);
43 }
44
45 #endif