2 misc.cc -- implement various stuff
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 Jan Nieuwenhuizen <janneke@gnu.org>
29 return log (x) /log (2.0);
34 comp (Real const &a, Real const &b)
40 quantise_iv (Array<Real> positions, Real x)
42 positions.sort (comp);
43 Real period = positions.top () - positions[0];
45 int n = int ((x - positions[0]) / period);
46 Real frac = (x - positions[0] ) - n * period;
54 Real px = frac + positions[0];
55 assert ( positions[0] <= px && px <= positions.top ());
57 for (; i < positions.size () - 1; i++)
59 if (positions[i] <= px && px <= positions[i+1])
63 return Interval (positions[i] , positions[i+1]) + period * n;