cateoricals.c categoricals.h clean up.
[pspp] / src / math / linreg.c
index 63d1a0f976ee420ca52b476e67aa85cd94ff4a5e..47d21cf8f5fdfed7f357f96f45038493374b6aab 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2005, 2010 Free Software Foundation, Inc. 
+   Copyright (C) 2005, 2010, 2011 Free Software Foundation, Inc. 
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
 #include <config.h>
+
+#include "math/linreg.h"
+
 #include <gsl/gsl_blas.h>
 #include <gsl/gsl_cblas.h>
 #include <gsl/gsl_errno.h>
 #include <gsl/gsl_fit.h>
 #include <gsl/gsl_linalg.h>
 #include <gsl/gsl_multifit.h>
-#include <linreg/sweep.h>
-#include <math/linreg.h>
-#include <src/data/variable.h>
-#include <src/data/value.h>
-#include <gl/xalloc.h>
+
+#include "data/value.h"
+#include "data/variable.h"
+#include "linreg/sweep.h"
+
+#include "gl/xalloc.h"
 
 /*
   Find the least-squares estimate of b for the linear model:
@@ -103,23 +107,29 @@ linreg_alloc (const struct variable *depvar, const struct variable **indep_vars,
   c->pred = NULL;
   c->resid = NULL;
 
+  c->refcnt = 1;
   return c;
 }
 
-bool
-linreg_free (void *m)
+void
+linreg_ref (linreg *c)
+{
+  c->refcnt++;
+}
+
+void
+linreg_unref (linreg *c)
 {
-  linreg *c = m;
-  if (c != NULL)
+  if (c && --c->refcnt == 0)
     {
       gsl_vector_free (c->indep_means);
       gsl_vector_free (c->indep_std);
+      gsl_vector_free (c->ss_indeps);
       gsl_matrix_free (c->cov);
       free (c->indep_vars);
       free (c->coeff);
       free (c);
     }
-  return true;
 }
 
 static void