[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pspp-cvs] pspp/src/math automake.mk ChangeLog interaction...
From: |
Jason H Stover |
Subject: |
[Pspp-cvs] pspp/src/math automake.mk ChangeLog interaction... |
Date: |
Thu, 31 May 2007 23:09:22 +0000 |
CVSROOT: /sources/pspp
Module name: pspp
Changes by: Jason H Stover <jstover> 07/05/31 23:09:22
Modified files:
src/math : automake.mk ChangeLog
Added files:
src/math : interaction.c interaction.h
Log message:
Initial version of interaction
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/src/math/automake.mk?cvsroot=pspp&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/pspp/src/math/ChangeLog?cvsroot=pspp&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/pspp/src/math/interaction.c?cvsroot=pspp&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/pspp/src/math/interaction.h?cvsroot=pspp&rev=1.1
Patches:
Index: automake.mk
===================================================================
RCS file: /sources/pspp/pspp/src/math/automake.mk,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- automake.mk 4 Jul 2006 04:39:04 -0000 1.4
+++ automake.mk 31 May 2007 23:09:21 -0000 1.5
@@ -13,8 +13,10 @@
src/math/coefficient.c \
src/math/coefficient.h \
src/math/group.c src/math/group.h \
- src/math/histogram.c src/math/histogram.h \
src/math/group-proc.h \
+ src/math/histogram.c src/math/histogram.h \
+ src/math/interaction.c \
+ src/math/interaction.h \
src/math/levene.c \
src/math/levene.h \
src/math/moments.c src/math/moments.h \
Index: ChangeLog
===================================================================
RCS file: /sources/pspp/pspp/src/math/ChangeLog,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- ChangeLog 5 Feb 2007 23:43:23 -0000 1.13
+++ ChangeLog 31 May 2007 23:09:21 -0000 1.14
@@ -1,3 +1,8 @@
+2007-05-31 Jason Stover <address@hidden>
+
+ * interaction.c: New file.
+ * interaction.h : New file.
+
Mon Feb 5 15:42:14 2007 Ben Pfaff <address@hidden>
* moments.c (moments_pass_two): Reduce number of multiplications.
Index: interaction.c
===================================================================
RCS file: interaction.c
diff -N interaction.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ interaction.c 31 May 2007 23:09:21 -0000 1.1
@@ -0,0 +1,103 @@
+/* PSPP - Creates data structures to store interactions for
+ statistical routines.
+
+ Copyright (C) 2007 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 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
+ 02110-1301, USA. */
+
+/*
+ An interaction is a gsl_vector containing a "product" of other
+ variables. The variables can be either categorical or numeric.
+ If the variables are all numeric, the interaction is just the
+ scalar product. If any of the variables are categorical, their
+ product is a vector containing 0's in all but one entry. This entry
+ is found by combining the vectors corresponding to the variables'
+ OBS_VALS member. If there are K categorical variables, each with
+ N_1, N_2, ..., N_K categories, then the interaction will have
+ N_1 * N_2 * N_3 *...* N_K - 1 entries.
+ */
+#include <assert.h>
+#include <libpspp/alloc.h>
+#include <gsl/gsl_math.h>
+#include <gsl/gsl_vector.h>
+#include <data/category.h>
+#include <data/variable.h>
+
+/*
+ Convert a list of values to a binary vector. The order of VALS must
+ correspond to the order of V.
+ */
+gsl_vector *
+get_interaction (union value **vals, const struct variable **v, size_t n_vars)
+{
+ gsl_vector *result = NULL;
+ size_t *subs = NULL;
+ size_t length = 1;
+ size_t i;
+ size_t j;
+ double tmp = 1.0;
+
+ assert (n_vars > 0);
+ for (i = 0; i < n_vars; i++)
+ {
+ if (var_is_alpha (v[i]))
+ {
+ length *= cat_get_n_categories (v[i]);
+ }
+ else
+ {
+ length = (length > 0) ? length : 1;
+ }
+ }
+ if (length > 0)
+ {
+ length--;
+ }
+
+ result = gsl_vector_calloc (length);
+ subs = xnmalloc (n_vars, sizeof (*subs));
+ for (j = 0; j < n_vars; j++)
+ {
+ if (var_is_alpha (v[j]))
+ {
+ subs[j] = cat_value_find (v[j], vals[j]);
+ }
+ }
+ j = subs[0];
+ for (i = 1; i < n_vars; i++)
+ {
+ j = j * cat_get_n_categories (v[i]) + subs[i];
+ }
+ gsl_vector_set (result, j, 1.0);
+ /*
+ If any of the variables are numeric, the interaction of that
+ variable with another is just a scalar product.
+ */
+ for (i = 1; i < n_vars; i++)
+ {
+ if (var_is_numeric (v[i]))
+ {
+ tmp *= vals[i]->f;
+ }
+ }
+ if (fabs (tmp - 1.0) > GSL_DBL_EPSILON)
+ {
+ gsl_vector_set (result, j, tmp);
+ }
+ free (subs);
+
+ return result;
+}
Index: interaction.h
===================================================================
RCS file: interaction.h
diff -N interaction.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ interaction.h 31 May 2007 23:09:21 -0000 1.1
@@ -0,0 +1,21 @@
+/* PSPP - Creates data structures to store interactions for
+ statistical routines.
+
+ Copyright (C) 2007 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 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
+ 02110-1301, USA. */
+gsl_vector *
+get_interaction (union value **, const struct variable **, size_t);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pspp-cvs] pspp/src/math automake.mk ChangeLog interaction...,
Jason H Stover <=