Fixed a bug in the Mann-Whitney test vs. missing=analysis.
[pspp] / src / language / stats / quick-cluster.c
index f4c64b09977fff52caa8f83e9f172ad75dff14a5..ff008db08aa73e7dec233a6dac0515f6d9f37ad5 100644 (file)
@@ -459,13 +459,12 @@ kmeans_cluster (struct Kmeans *kmeans, struct casereader *reader, const struct q
 
       {
        kmeans->n = 0;
-       int i;
        /* Step 3 */
        gsl_vector_long_set_all (kmeans->num_elements_groups, 0.0);
        gsl_matrix_set_all (kmeans->updated_centers, 0.0);
        struct ccase *c;
        struct casereader *cs = casereader_clone (reader);
-       for (; (c = casereader_read (cs)) != NULL; i++, case_unref (c))
+       for (; (c = casereader_read (cs)) != NULL; case_unref (c))
          {
            int group = -1; 
            kmeans_get_nearest_group (kmeans, c, qc, &group, NULL, NULL, NULL);
@@ -483,8 +482,6 @@ kmeans_cluster (struct Kmeans *kmeans, struct casereader *reader, const struct q
            long *n = gsl_vector_long_ptr (kmeans->num_elements_groups, group);
            *n += qc->wv ? case_data (c, qc->wv)->f : 1.0;
            kmeans->n++;
-
-
          }
        casereader_destroy (cs);
 
@@ -738,9 +735,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)
                        {
@@ -748,14 +745,15 @@ cmd_quick_cluster (struct lexer *lexer, struct dataset *ds)
                          goto error;
                        }
                      lex_get (lexer);
-                     lex_force_match (lexer, T_RPAREN);
+                     if (!lex_force_match (lexer, T_RPAREN))
+                       goto error;
                    }
                }
              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)
                        {
@@ -763,14 +761,15 @@ cmd_quick_cluster (struct lexer *lexer, struct dataset *ds)
                          goto error;
                        }
                      lex_get (lexer);
-                     lex_force_match (lexer, T_RPAREN);
+                     if (!lex_force_match (lexer, T_RPAREN))
+                       goto error;
                    }
                }
              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)
                        {
@@ -778,7 +777,8 @@ cmd_quick_cluster (struct lexer *lexer, struct dataset *ds)
                          goto error;
                        }
                      lex_get (lexer);
-                     lex_force_match (lexer, T_RPAREN);
+                     if (!lex_force_match (lexer, T_RPAREN))
+                       goto error;
                    }
                }
              else if (lex_match_id (lexer, "NOINITIAL"))