pspp-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pspp-cvs] pspp/src math/ChangeLog math/coefficient.h math...


From: Jason H Stover
Subject: [Pspp-cvs] pspp/src math/ChangeLog math/coefficient.h math...
Date: Fri, 14 Jul 2006 19:17:50 +0000

CVSROOT:        /sources/pspp
Module name:    pspp
Changes by:     Jason H Stover <jstover>        06/07/14 19:17:50

Modified files:
        src/math       : ChangeLog coefficient.h coefficient.c 
        src/language/stats: regression.q ChangeLog 

Log message:
        moved knowledge of pspp_linreg_cache out of pspp_coeff_init

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/src/math/ChangeLog?cvsroot=pspp&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/pspp/src/math/coefficient.h?cvsroot=pspp&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/pspp/src/math/coefficient.c?cvsroot=pspp&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/stats/regression.q?cvsroot=pspp&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/pspp/src/language/stats/ChangeLog?cvsroot=pspp&r1=1.26&r2=1.27

Patches:
Index: math/ChangeLog
===================================================================
RCS file: /sources/pspp/pspp/src/math/ChangeLog,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- math/ChangeLog      19 May 2006 21:08:20 -0000      1.7
+++ math/ChangeLog      14 Jul 2006 19:17:50 -0000      1.8
@@ -1,3 +1,8 @@
+2006-07-14  Jason Stover  <address@hidden>
+
+       * coefficient.c (pspp_coeff_init): Removed use of
+       pspp_linreg_cache to make the routines more generally useful.
+
 2006-05-19  Jason Stover  <address@hidden>
 
        * coefficient.h: Renamed pspp_linreg_coeff to pspp_coeff.

Index: math/coefficient.h
===================================================================
RCS file: /sources/pspp/pspp/src/math/coefficient.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- math/coefficient.h  5 Jun 2006 00:21:05 -0000       1.4
+++ math/coefficient.h  14 Jul 2006 19:17:50 -0000      1.5
@@ -72,7 +72,7 @@
   Initialize the variable and value pointers inside the
   coefficient structures for the linear model.
  */
-void pspp_coeff_init (pspp_linreg_cache *, struct design_matrix *);
+void pspp_coeff_init (struct pspp_coeff **, struct design_matrix *);
 
 
 void

Index: math/coefficient.c
===================================================================
RCS file: /sources/pspp/pspp/src/math/coefficient.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- math/coefficient.c  19 May 2006 21:08:20 -0000      1.2
+++ math/coefficient.c  14 Jul 2006 19:17:50 -0000      1.3
@@ -53,39 +53,32 @@
   coefficient structures for the linear model.
  */
 void
-pspp_coeff_init (pspp_linreg_cache * c, struct design_matrix *X)
+pspp_coeff_init (struct pspp_coeff ** c, struct design_matrix *X)
 {
   size_t i;
-  size_t j;
   int n_vals = 1;
-  struct pspp_coeff *coeff;
 
-  c->coeff = xnmalloc (X->m->size2 + 1, sizeof (*c->coeff));
-  c->coeff[0] = xmalloc (sizeof (*c->coeff[0]));
-  c->coeff[0]->v_info = NULL;  /* Intercept has no associated variable. */
   for (i = 0; i < X->m->size2; i++)
     {
-      j = i + 1;               /* The first coefficient is the intercept. */
-      c->coeff[j] = xmalloc (sizeof (*c->coeff[j]));
-      coeff = c->coeff[j];
-      coeff->n_vars = n_vals;  /* Currently, no procedures allow
+      c[i] = xmalloc (sizeof (*c[i]));
+      c[i]->n_vars = n_vals;   /* Currently, no procedures allow
                                   interactions.  This line will have to
                                   change when procedures that allow
                                   interaction terms are written. 
                                 */
-      coeff->v_info = xnmalloc (coeff->n_vars, sizeof (*coeff->v_info));
-      assert (coeff->v_info != NULL);
-      coeff->v_info->v =
+      c[i]->v_info = xnmalloc (c[i]->n_vars, sizeof (*c[i]->v_info));
+      assert (c[i]->v_info != NULL);
+      c[i]->v_info->v =
        (const struct variable *) design_matrix_col_to_var (X, i);
 
-      if (coeff->v_info->v->type == ALPHA)
+      if (c[i]->v_info->v->type == ALPHA)
        {
          size_t k;
-         k = design_matrix_var_to_column (X, coeff->v_info->v);
+         k = design_matrix_var_to_column (X, c[i]->v_info->v);
          assert (k <= i);
          k = i - k;
-         coeff->v_info->val =
-           cat_subscript_to_value (k, (struct variable *) coeff->v_info->v);
+         c[i]->v_info->val =
+           cat_subscript_to_value (k, (struct variable *) c[i]->v_info->v);
        }
     }
 }

Index: language/stats/regression.q
===================================================================
RCS file: /sources/pspp/pspp/src/language/stats/regression.q,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- language/stats/regression.q 5 Jul 2006 05:14:31 -0000       1.28
+++ language/stats/regression.q 14 Jul 2006 19:17:50 -0000      1.29
@@ -1078,7 +1078,14 @@
 
   return n_data;
 }
-
+static void
+coeff_init (pspp_linreg_cache *c, struct design_matrix *dm)
+{
+  c->coeff = xnmalloc (dm->m->size2 + 1, sizeof (*c->coeff));
+  c->coeff[0] = xmalloc (sizeof (*(c->coeff[0]))); /* The first coefficient is 
the intercept. */
+  c->coeff[0]->v_info = NULL;  /* Intercept has no associated variable. */
+  pspp_coeff_init (c->coeff + 1, dm);
+}
 static bool
 run_regression (const struct ccase *first,
                 const struct casefile *cf, void *cmd_ UNUSED)
@@ -1213,7 +1220,7 @@
          and store pointers to the variables that correspond to the
          coefficients.
        */
-      pspp_coeff_init (models[k], X);
+      coeff_init (models[k], X);
 
       /* 
          Find the least-squares estimates and other statistics.

Index: language/stats/ChangeLog
===================================================================
RCS file: /sources/pspp/pspp/src/language/stats/ChangeLog,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- language/stats/ChangeLog    5 Jul 2006 05:14:31 -0000       1.26
+++ language/stats/ChangeLog    14 Jul 2006 19:17:50 -0000      1.27
@@ -1,3 +1,8 @@
+2006-07-14  Jason Stover  <address@hidden>
+
+       * regression.q (run_regression): New function to move knowledge of
+       pspp_linreg_cache out of math/coefficient.[ch].
+
 Sat Jul  1 17:41:46 2006  Ben Pfaff  <address@hidden>
 
        Fix bug #11612, "q2c documentation does not agree with code".




reply via email to

[Prev in Thread] Current Thread [Next in Thread]