X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fleast-squares.cc;h=c7ca185bbfa4ea8de4763339bbaf30c65dab0edb;hb=9f3572d98bb948c9689cd1f75401a029451fa001;hp=2e0bcab3c61a8e6fb7bcd36a903db2a6244882be;hpb=04265f11d1f21416ccebd2dcaa1d903dc781b36e;p=lilypond.git diff --git a/lily/least-squares.cc b/lily/least-squares.cc index 2e0bcab3c6..c7ca185bbf 100644 --- a/lily/least-squares.cc +++ b/lily/least-squares.cc @@ -28,23 +28,22 @@ minimise_least_squares (Real *coef, Real *offset, sqx += sqr (x); sxy += x*y; } - - int count = input.size (); + int N = input.size (); *coef = 0.0; *offset = 0.; - Real den = (count * sqx - sqr (sx)); - if (!count || !den) + Real den = (N * sqx - sqr (sx)); + if (!N || !den) { programming_error ("minimise_least_squares (): Nothing to minimise"); *coef = 0.0; - *offset = count ? sy / count : 0.0; + *offset = N ? sy / N : 0.0; } else { - *coef = (count * sxy - sx * sy) / den; - *offset = (sy - (*coef) * sx) / count; + *coef = (N *sxy - sx * sy) / den; + *offset = (sy - (*coef) * sx) / N; } }