Sat Dec 27 16:16:49 2003 Ben Pfaff <blp@gnu.org>
[pspp-builds.git] / src / t-test.q
index 05797744ab669e945bec8249ab5e11984f54ef9d..89270bf8857f8056407461ab5ee32c4f9caee6f5 100644 (file)
@@ -1,6 +1,6 @@
 /* PSPP - computes sample statistics.
    Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
-   Written by Ben Pfaff <blp@gnu.org>.
+   Written by John Williams <johnr.williams@stonebow.otago.ac.nz>.
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -29,6 +29,7 @@
 #include "lexer.h"
 #include "error.h"
 #include "magic.h"
+#include "value-labels.h"
 #include "var.h"
 #include "vfm.h"
 
@@ -182,17 +183,12 @@ groups_calc (struct ccase * c)
   double X = c->data[v->fv].f;
 
   /* Get the weight for this case. */
-  if (default_dict.weight_index == -1)
-    w = 1.0;
-  else
+  w = dict_get_case_weight (default_dict, c);
+  if (w <= 0.0 || w == SYSMIS)
     {
-      w = c->data[default_dict.weight_index].f;
-      if (w <= 0.0 || w == SYSMIS)
-       {
-         w = 0.0;
-         bad_weight = 1;
-         printf ("Bad weight\n");
-       }
+      w = 0.0;
+      bad_weight = 1;
+      printf ("Bad weight\n");
     }
 
   if (X == SYSMIS || X == 0.0) /* FIXME: should be USER_MISSING? */
@@ -233,7 +229,6 @@ g_postcalc (void)
 int                            /* this pass generates the z-zcores */
 z_calc (struct ccase * c)
 {
-  int bad_weight;
   double group, z, w;
   struct variable *v = cmd.v_variables[cur_var];
   double X = c->data[v->fv].f;
@@ -241,17 +236,7 @@ z_calc (struct ccase * c)
   z = 0.0;
 
   /* Get the weight for this case. */
-  if (default_dict.weight_index == -1)
-    w = 1.0;
-  else
-    {
-      w = c->data[default_dict.weight_index].f;
-      if (w <= 0.0 || w == SYSMIS)
-       {
-         w = 0.0;
-         bad_weight = 1;
-       }
-    }
+  w = dict_get_case_weight (default_dict, c);
 
   if (X == SYSMIS || X == 0.0) /* FIXME: how to specify user missing? */
     {
@@ -547,9 +532,10 @@ tts_custom_pairs (struct cmd_t_test *cmd unused)
   int n_predicted;
 #endif
 
-  if ((token != T_ID || !is_varname (tokid)) && token != T_ALL)
+  if ((token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)
+      && token != T_ALL)
     return 2;
-  if (!parse_variables (&default_dict, &vars, &n_vars,
+  if (!parse_variables (default_dict, &vars, &n_vars,
                        PV_DUPLICATE | PV_NUMERIC | PV_NO_SCRATCH))
     return 0;
 
@@ -558,7 +544,7 @@ tts_custom_pairs (struct cmd_t_test *cmd unused)
     {
       n_before_WITH = n_vars;
 
-      if (!parse_variables (&default_dict, &vars, &n_vars,
+      if (!parse_variables (default_dict, &vars, &n_vars,
                            PV_DUPLICATE | PV_APPEND
                            | PV_NUMERIC | PV_NO_SCRATCH))
        {
@@ -1061,9 +1047,9 @@ print_t_groups (struct variable * grps, union value * g1, union value * g2,
   printf ("-----------------------------------------------------------\n");
   printf ("   %s %s\n\n", cmd.v_variables[cur_var]->name, cmd.v_variables[cur_var]->label);
   printf ("%s %8.4f %8.0f    %8.4f  %8.3f    %8.3f\n",
-         get_val_lab (grps, *g1, 0), g1->f, n1, mean1, sd1, se1);
+         val_labs_find (grps->val_labs, *g1), g1->f, n1, mean1, sd1, se1);
   printf ("%s %8.4f %8.0f    %8.4f  %8.3f    %8.3f\n",
-         get_val_lab (grps, *g2, 0), g2->f, n2, mean2, sd2, se2);
+         val_labs_find (grps->val_labs, *g2), g2->f, n2, mean2, sd2, se2);
   printf ("-----------------------------------------------------------\n");
   printf ("\n   Mean Difference = %8.4f\n", diff);
   printf ("\n   Levene's Test for Equality of Variances: F= %.3f  P= %.3f\n",