added automake.mk files in src/language
[pspp] / src / levene.c
index 833a65e08df056e6c76ea1d6a3fac652c313f041..5de5220588564cb6674fd20aa04e21279dd3f0bf 100644 (file)
@@ -68,7 +68,7 @@ struct levene_info
   struct variable *v_indep; 
 
   /* Number of dependent variables */
-  int n_dep;
+  size_t n_dep;
 
   /* The dependent variables */
   struct variable  **v_dep;
@@ -77,8 +77,7 @@ struct levene_info
   enum lev_missing missing;
 
   /* Function to test for missing values */
-  is_missing_func is_missing;
-
+  is_missing_func *is_missing;
 };
 
 /* First pass */
@@ -95,7 +94,7 @@ static void levene2_postcalc (void *);
 
 void  
 levene(const struct casefile *cf,
-       struct variable *v_indep, int n_dep, struct variable **v_dep,
+       struct variable *v_indep, size_t n_dep, struct variable **v_dep,
             enum lev_missing missing,   is_missing_func value_is_missing)
 {
   struct casereader *r;
@@ -157,9 +156,9 @@ static struct lz_stats *lz;
 static void 
 levene_precalc (const struct levene_info *l)
 {
-  int i;
+  size_t i;
 
-  lz  = xmalloc (sizeof (struct lz_stats ) * l->n_dep ) ;
+  lz = xnmalloc (l->n_dep, sizeof *lz);
 
   for(i = 0; i < l->n_dep ; ++i ) 
     {
@@ -187,7 +186,7 @@ levene_precalc (const struct levene_info *l)
 static int 
 levene_calc (const struct ccase *c, void *_l)
 {
-  int i;
+  size_t i;
   int warn = 0;
   struct levene_info *l = (struct levene_info *) _l;
   const union value *gv = case_data (c, l->v_indep->fv);
@@ -202,7 +201,7 @@ levene_calc (const struct ccase *c, void *_l)
          struct variable *v = l->v_dep[i];
          const union value *val = case_data (c, v->fv);
 
-         if (l->is_missing(val,v) )
+         if (l->is_missing (&v->miss, val) )
            {
              return 0;
            }
@@ -225,7 +224,7 @@ levene_calc (const struct ccase *c, void *_l)
       if ( 0 == gs ) 
        continue ;
 
-      if ( ! l->is_missing(v,var))
+      if ( ! l->is_missing(&var->miss, v))
        {
          levene_z= fabs(v->f - gs->mean);
          lz[i].grand_total += levene_z * weight;
@@ -242,7 +241,7 @@ levene_calc (const struct ccase *c, void *_l)
 static void 
 levene_postcalc (void *_l)
 {
-  int v;
+  size_t v;
 
   struct levene_info *l = (struct levene_info *) _l;
 
@@ -262,11 +261,11 @@ static double *lz_denominator;
 static void 
 levene2_precalc (void *_l)
 {
-  int v;
+  size_t v;
 
   struct levene_info *l = (struct levene_info *) _l;
 
-  lz_denominator = (double *) xmalloc(sizeof(double) * l->n_dep);
+  lz_denominator = xnmalloc (l->n_dep, sizeof *lz_denominator);
 
   /* This stuff could go in the first post calc . . . */
   for (v = 0; v < l->n_dep; ++v) 
@@ -291,7 +290,7 @@ levene2_precalc (void *_l)
 static int 
 levene2_calc (const struct ccase *c, void *_l)
 {
-  int i;
+  size_t i;
   int warn = 0;
 
   struct levene_info *l = (struct levene_info *) _l;
@@ -309,7 +308,7 @@ levene2_calc (const struct ccase *c, void *_l)
          struct variable *v = l->v_dep[i];
          const union value *val = case_data (c, v->fv);
 
-         if (l->is_missing(val,v) )
+         if (l->is_missing(&v->miss, val) )
            {
              return 0;
            }
@@ -330,7 +329,7 @@ levene2_calc (const struct ccase *c, void *_l)
       if ( 0 == gs ) 
        continue;
 
-      if ( ! l->is_missing(v,var) )
+      if ( ! l->is_missing (&var->miss, v) )
        {
          levene_z = fabs(v->f - gs->mean); 
          lz_denominator[i] += weight * pow2(levene_z - gs->lz_mean);
@@ -344,7 +343,7 @@ levene2_calc (const struct ccase *c, void *_l)
 static void 
 levene2_postcalc (void *_l)
 {
-  int v;
+  size_t v;
 
   struct levene_info *l = (struct levene_info *) _l;