]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/least-squares.cc
Fix some bugs in the dynamic engraver and PostScript backend
[lilypond.git] / lily / least-squares.cc
index 2e0bcab3c61a8e6fb7bcd36a903db2a6244882be..c7ca185bbfa4ea8de4763339bbaf30c65dab0edb 100644 (file)
@@ -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;
     }
 }