Fixed some bugs related to empty parentheses
[pspp] / src / language / stats / quick-cluster.c
index 4f34e4f0a8ef0eabcb955d4eb1588d634264f33e..61f0cea02ade6c2477c19f3855371ec9df866a9c 100644 (file)
@@ -20,7 +20,6 @@
 #include <gsl/gsl_permutation.h>
 #include <gsl/gsl_sort_vector.h>
 #include <gsl/gsl_statistics.h>
-#include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -187,21 +186,7 @@ matrix_mindist (const gsl_matrix *m, int *mn, int *mm)
        }
     }
 
-  return sqrt (mindist);
-}
-
-
-static void
-dump_matrix (const gsl_matrix *m)
-{
-  size_t i, j;
-
-  for (i = 0 ; i < m->size1; ++i)
-    {
-      for (j = 0 ; j < m->size2; ++j)
-       printf ("%02f ", gsl_matrix_get (m, i, j));
-      printf ("\n");
-    }
+  return mindist;
 }
 
 
@@ -220,7 +205,7 @@ dist_from_case (const struct Kmeans *kmeans, const struct ccase *c, const struct
       dist += pow2 (gsl_matrix_get (kmeans->centers, which, j) - val->f);
     }
  
-  return sqrt (dist);
+  return dist;
 }
 
 /* Return the minimum distance of the group WHICH and all other groups */
@@ -247,7 +232,7 @@ min_dist_from (const struct Kmeans *kmeans, const struct qc *qc, int which)
        }
     }
 
-  return sqrt (mindist);
+  return mindist;
 }
 
 
@@ -349,7 +334,6 @@ kmeans_get_nearest_group (const struct Kmeans *kmeans, struct ccase *c, const st
 
          dist += pow2 (gsl_matrix_get (kmeans->centers, i, j) - val->f);
        }
-      dist = sqrt (dist);
 
       if (dist < mindist0)
        {
@@ -754,9 +738,9 @@ cmd_quick_cluster (struct lexer *lexer, struct dataset *ds)
            {
              if (lex_match_id (lexer, "CLUSTERS"))
                {
-                 if (lex_force_match (lexer, T_LPAREN))
+                 if (lex_force_match (lexer, T_LPAREN) &&
+                     lex_force_int (lexer))
                    {
-                     lex_force_int (lexer);
                      qc.ngroups = lex_integer (lexer);
                      if (qc.ngroups <= 0)
                        {
@@ -769,9 +753,9 @@ cmd_quick_cluster (struct lexer *lexer, struct dataset *ds)
                }
              else if (lex_match_id (lexer, "CONVERGE"))
                {
-                 if (lex_force_match (lexer, T_LPAREN))
+                 if (lex_force_match (lexer, T_LPAREN) &&
+                     lex_force_num (lexer))
                    {
-                     lex_force_num (lexer);
                      qc.epsilon = lex_number (lexer);
                      if (qc.epsilon <= 0)
                        {
@@ -784,9 +768,9 @@ cmd_quick_cluster (struct lexer *lexer, struct dataset *ds)
                }
              else if (lex_match_id (lexer, "MXITER"))
                {
-                 if (lex_force_match (lexer, T_LPAREN))
+                 if (lex_force_match (lexer, T_LPAREN) &&
+                     lex_force_int (lexer))
                    {
-                     lex_force_int (lexer);
                      qc.maxiter = lex_integer (lexer);
                      if (qc.maxiter <= 0)
                        {