]> git.donarmstrong.com Git - lilypond.git/blob - lily/misc.cc
093af7f0d4b89b80264671dd2eaab4c85961be2c
[lilypond.git] / lily / misc.cc
1 #include <math.h>
2
3 #include "item.hh"
4 #include "misc.hh"
5 #include "glob.hh"
6 #include "moment.hh"
7
8
9 // depreciated, see struct Duration*
10 Moment
11 wholes(int dur, int dots)
12 {
13     if (!dur)
14         return 0;
15
16     Moment f = Rational(1)/Moment(dur);
17     Moment delta = f;
18
19     while (dots--) {
20         delta /= 2.0;
21         f += delta;
22     }
23     return f;    
24 }
25 int
26 intlog2(int d) {
27     int i=0;
28     while (!(d&1)) {
29         d/= 2;
30         i++;
31     }
32     assert(!(d/2));
33     return i;
34 }
35
36 double
37 log_2(double x) {
38     return log(x)  /log(2.0);
39 }
40
41 Interval
42 itemlist_width(const Array<Item*> &its)
43 {
44     Interval iv ;
45     iv.set_empty();
46      
47     for (int j =0; j < its.size(); j++){
48         iv.unite (its[j]->width());
49
50     }
51     return iv;
52 }
53