Update all #include directives to the currently preferred style.
[pspp-builds.git] / src / math / interaction.c
index 46d7e13ece35439ec7c35df74270db09e7c5cca5..87f4836da23479ced8fa9a2069841ada800408d9 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2009 Free Software Foundation, Inc.
+   Copyright (C) 2009, 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
@@ -15,7 +15,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
 /*
-  An interaction is a gsl_vector containing a "product" of other
+  An interaction is a structure 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
  */
 
 #include <config.h>
+
+#include "math/interaction.h"
+
 #include <assert.h>
-#include <gsl/gsl_math.h>
-#include <gsl/gsl_vector.h>
-#include <data/value.h>
-#include <data/variable.h>
-#include <math/interaction.h>
 #include <string.h>
-#include <xalloc.h>
+#include <unistr.h>
+
+#include "data/dictionary.h"
+#include "data/value.h"
+#include "data/variable.h"
+
+#include "gl/xalloc.h"
 
 struct interaction_variable
 {
@@ -85,14 +89,14 @@ interaction_variable_create (const struct variable **vars, int n_vars)
              width += var_get_width (vars[i]);
            }
        }
-      result->intr = var_create_internal (0, width);
+      result->intr = dict_create_internal_var (0, width);
     }
 
   return result;
 }
 void interaction_variable_destroy (struct interaction_variable *iv)
 {
-  var_destroy (iv->intr);
+  dict_destroy_internal_var (iv->intr);
   free (iv->members);
   free (iv);
 }
@@ -143,26 +147,23 @@ struct interaction_value *
 interaction_value_create (const struct interaction_variable *var, const union value **vals)
 {
   struct interaction_value *result = NULL;
-  const struct variable *member;
-  size_t i;
-  size_t n_vars;
   
   if (var != NULL)
     {
+      size_t i;
       int val_width = var_get_width (interaction_get_variable (var));
-      int offset;
+      int offset = 0;
+      size_t n_vars = interaction_get_n_vars (var);
 
       result = xmalloc (sizeof (*result));
       result->intr = var;
-      n_vars = interaction_get_n_vars (var);
 
       value_init (&result->val, val_width);
 
-      offset = 0;
       result->f = 1.0;
       for (i = 0; i < n_vars; i++)
        {
-         member = interaction_get_member (var, i);
+          const struct variable *member = interaction_get_member (var, i);
 
          if (var_is_value_missing (member, vals[i], MV_ANY))
            {
@@ -174,9 +175,9 @@ interaction_value_create (const struct interaction_variable *var, const union va
            {
              if (var_is_alpha (var->members[i]))
                {
-                 char *val = value_str_rw (&result->val, val_width);
+                 uint8_t *val = value_str_rw (&result->val, val_width);
                   int w = var_get_width (var->members[i]);
-                  memcpy (val + offset, value_str (vals[i], w), w);
+                  u8_cpy (val + offset, value_str (vals[i], w), w);
                   offset += w;
                }
              else if (var_is_numeric (var->members[i]))
@@ -271,7 +272,7 @@ is_interaction (const struct variable *var, const struct interaction_variable **
   for (i = 0; i < n_intr; i++)
     {
       intr = interaction_get_variable (iv[i]);
-      if (var_get_dict_index (intr) == var_get_dict_index (var))
+      if (intr == var)
        {
          return true;
        }