]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/misc.hh
72da2c90e969341fd16cdd30fbea94aacd0c0179
[lilypond.git] / lily / include / misc.hh
1 /*
2   misc.hh -- declare miscellaneous functions.
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
7
8 */
9
10 #ifndef MISC_HH
11 #define MISC_HH
12
13 #include <cstdlib>
14
15 #include "array.hh"
16 #include "interval.hh"
17
18 double log_2 (double x) ;
19 int intlog2 (int d);
20
21 inline int
22 sign (int i)
23 {
24   if (i<0)
25     return -1;
26   else if (i)
27     return 1;
28   else return 0;
29 }
30
31 Array<String> split_string (String s, char c);
32
33 inline Real
34 linear_interpolate (Real x, Real x1, Real x2,  Real y1, Real  y2)
35 {
36   return (x2 - x) / (x2 - x1) * y1 +
37     (x - x1) / (x2 - x1) * y2 ;
38 }
39
40 #endif
41