lilypond-0.1.56
[lilypond.git] / src / misc.cc
blob093af7f0d4b89b80264671dd2eaab4c85961be2c
1 #include <math.h>
3 #include "item.hh"
4 #include "misc.hh"
5 #include "glob.hh"
6 #include "moment.hh"
9 // depreciated, see struct Duration*
10 Moment
11 wholes(int dur, int dots)
13 if (!dur)
14 return 0;
16 Moment f = Rational(1)/Moment(dur);
17 Moment delta = f;
19 while (dots--) {
20 delta /= 2.0;
21 f += delta;
23 return f;
25 int
26 intlog2(int d) {
27 int i=0;
28 while (!(d&1)) {
29 d/= 2;
30 i++;
32 assert(!(d/2));
33 return i;
36 double
37 log_2(double x) {
38 return log(x) /log(2.0);
41 Interval
42 itemlist_width(const Array<Item*> &its)
44 Interval iv ;
45 iv.set_empty();
47 for (int j =0; j < its.size(); j++){
48 iv.unite (its[j]->width());
51 return iv;