/* PSPP - a program for statistical analysis.
- Copyright (C) 2011 Free Software Foundation, Inc.
+ Copyright (C) 2011, 2012, 2015 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
{
const union value *val = case_data (c, qc->vars[v]);
double x = val->f * weight;
+ double curval;
if ( var_is_value_missing (qc->vars[v], val, qc->exclude))
continue;
- double curval = gsl_matrix_get (kmeans->centers, index, v);
+ curval = gsl_matrix_get (kmeans->centers, index, v);
gsl_matrix_set (kmeans->centers, index, v, curval + x);
}
i++;
quick_cluster_show_centers (struct Kmeans *kmeans, bool initial, const struct qc *qc)
{
struct tab_table *t;
- int nc, nr, heading_columns, currow;
+ int nc, nr, currow;
int i, j;
nc = qc->ngroups + 1;
nr = qc->n_vars + 4;
- heading_columns = 1;
t = tab_create (nc, nr);
tab_headers (t, 0, nc - 1, 0, 1);
currow = 0;
tab_double (t, i + 1, j + 4, TAB_CENTER,
gsl_matrix_get (kmeans->centers,
kmeans->group_order->data[i], j),
- var_get_print_format (qc->vars[j]));
+ var_get_print_format (qc->vars[j]), RC_OTHER);
}
else
{
tab_double (t, i + 1, j + 4, TAB_CENTER,
gsl_matrix_get (kmeans->initial_centers,
kmeans->group_order->data[i], j),
- var_get_print_format (qc->vars[j]));
+ var_get_print_format (qc->vars[j]), RC_OTHER);
}
}
}
{
qc.exclude = MV_SYSTEM;
}
+ else if (lex_match_id (lexer, "EXCLUDE"))
+ {
+ qc.exclude = MV_ANY;
+ }
else
goto error;
}
{
lex_force_int (lexer);
qc.ngroups = lex_integer (lexer);
+ if (qc.ngroups <= 0)
+ {
+ lex_error (lexer, _("The number of clusters must be positive"));
+ goto error;
+ }
lex_get (lexer);
lex_force_match (lexer, T_RPAREN);
}
{
lex_force_int (lexer);
qc.maxiter = lex_integer (lexer);
+ if (qc.maxiter <= 0)
+ {
+ lex_error (lexer, _("The number of iterations must be positive"));
+ goto error;
+ }
lex_get (lexer);
lex_force_match (lexer, T_RPAREN);
}
goto error;
}
}
+ else
+ {
+ lex_error (lexer, NULL);
+ goto error;
+ }
}
qc.wv = dict_get_weight (dict);