Fixed bug 23567. Added accessor functions to get/set means and standard deviations...
[pspp-builds.git] / src / math / coefficient.h
index 7569463baefe8843973891aa90ddebd953b9a2e2..dda2ae30cf292cb5008f0bf7e14a8440daeaf76e 100644 (file)
@@ -1,29 +1,24 @@
-/*
-  src/math/coefficient.c
-  
-  Copyright (C) 2005 Free Software Foundation, Inc. Written by Jason H Stover.
-  
-  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 the Free
-  Software Foundation; either version 2 of the License, or (at your option)
-  any later version.
-  
-  This program is distributed in the hope that it will be useful, but WITHOUT
-  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
-  more details.
-  
-  You should have received a copy of the GNU General Public License along with
-  this program; if not, write to the Free Software Foundation, Inc., 51
-  Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
-*/
+/* PSPP - a program for statistical analysis.
+   Copyright (C) 2005 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
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
 
 #ifndef COEFFICIENT_H
 #define COEFFICIENT_H
 
 #include <assert.h>
-#include <math/linreg/linreg.h>
 #include <src/data/variable.h>
 #include <src/data/value.h>
 
@@ -64,7 +59,7 @@ struct pspp_coeff
                                   interaction terms will have more than one
                                   variable. */
 };
-
+typedef struct pspp_coeff coefficient;
 
 void pspp_coeff_free (struct pspp_coeff *);
 
@@ -72,7 +67,7 @@ void pspp_coeff_free (struct pspp_coeff *);
   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 **, const struct design_matrix *);
 
 
 void
@@ -100,6 +95,15 @@ double pspp_coeff_get_std_err (const struct pspp_coeff *);
  */
 int pspp_coeff_get_n_vars (struct pspp_coeff *);
 
+/*
+  Which coefficient does this variable match? If the variable is
+  categorical, and has more than one coefficient, report the first
+  coefficient found. Note that in this case, the result will depend on
+  the order of COEFS.
+ */
+const struct pspp_coeff *
+pspp_coeff_var_to_coeff (const struct variable *, struct pspp_coeff **, size_t, const union value *);
+
 /*
   Which variable does this coefficient match? The int argument is usually
   0, unless the coefficient refers to an interaction.
@@ -112,9 +116,15 @@ const struct variable *pspp_coeff_get_var (struct pspp_coeff *,
 const union value *pspp_coeff_get_value (struct pspp_coeff *,
                                                const struct variable *);
 
-const struct pspp_coeff *pspp_linreg_get_coeff (const pspp_linreg_cache
-                                                      *,
-                                                      const struct variable
-                                                      *,
-                                                      const union value *);
+/*
+  Get or set the standard deviation of the variable associated with this coefficient.
+ */
+double pspp_coeff_get_sd (const struct pspp_coeff *);
+void pspp_coeff_set_sd (struct pspp_coeff *, double);
+
+/*
+  Get or set the mean for the variable associated with this coefficient.
+*/
+double pspp_coeff_get_mean (const struct pspp_coeff *);
+void pspp_coeff_set_mean (struct pspp_coeff *, double);
 #endif