X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fleast-squares.cc;h=492f5ff65d47c9694f22fcc2b967d5f934eb879e;hb=5b4b0d6e9a197e8f9eb085b7c2ad78b8be3e5cfc;hp=c7ca185bbfa4ea8de4763339bbaf30c65dab0edb;hpb=31568c504806f35aac420a394c9eab07abd9faa7;p=lilypond.git diff --git a/lily/least-squares.cc b/lily/least-squares.cc index c7ca185bbf..492f5ff65d 100644 --- a/lily/least-squares.cc +++ b/lily/least-squares.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1996--2006 Han-Wen Nienhuys + (c) 1996--2008 Han-Wen Nienhuys */ #include "least-squares.hh" @@ -28,22 +28,25 @@ minimise_least_squares (Real *coef, Real *offset, sqx += sqr (x); sxy += x*y; } - int N = input.size (); + + int count = input.size (); *coef = 0.0; *offset = 0.; - Real den = (N * sqx - sqr (sx)); - if (!N || !den) + Real den = (count * sqx - sqr (sx)); + if (!count || !den) { - programming_error ("minimise_least_squares (): Nothing to minimise"); + programming_error ("minimise_least_squares (): Nothing to minimise\n" + "This means that vertical spacing is triggered\n" + "before line breaking\n"); *coef = 0.0; - *offset = N ? sy / N : 0.0; + *offset = count ? sy / count : 0.0; } else { - *coef = (N *sxy - sx * sy) / den; - *offset = (sy - (*coef) * sx) / N; + *coef = (count * sxy - sx * sy) / den; + *offset = (sy - (*coef) * sx) / count; } }