1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2009 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 #ifndef _CATEGORICALS__
19 #define _CATEGORICALS__
22 #include <data/missing-values.h>
30 typedef void update_func (void *user_data,
31 enum mv_class exclude,
32 const struct variable *wv,
33 const struct variable *catvar,
34 const struct ccase *c,
35 void *aux1, void *aux2);
37 typedef void *user_data_create_func (void *aux1, void *aux2);
39 struct categoricals *categoricals_create (const struct variable *const *v, size_t n_vars,
40 const struct variable *wv, enum mv_class exclude,
41 user_data_create_func *udf,
42 update_func *update, void *aux1, void *aux2);
44 void categoricals_destroy (struct categoricals *);
46 void categoricals_update (struct categoricals *cat, const struct ccase *c);
49 /* Return the number of categories (distinct values) for variable N */
50 size_t categoricals_n_count (const struct categoricals *cat, size_t n);
53 /* Return the total number of categories */
54 size_t categoricals_total (const struct categoricals *cat);
57 Return the total number of variables which participated in these categoricals.
58 Due to the possibility of missing values, this is NOT necessarily
59 equal to the number of variables passed in when the object was
62 size_t categoricals_get_n_variables (const struct categoricals *cat);
64 void categoricals_done (struct categoricals *cat);
66 const struct variable * categoricals_get_variable_by_subscript (const struct categoricals *cat, int subscript);
68 const union value * categoricals_get_value_by_subscript (const struct categoricals *cat, int subscript);
70 double categoricals_get_weight_by_subscript (const struct categoricals *cat, int subscript);
72 double categoricals_get_sum_by_subscript (const struct categoricals *cat, int subscript);
74 double categoricals_get_binary_by_subscript (const struct categoricals *cat, int subscript,
75 const struct ccase *c);
77 void * categoricals_get_user_data_by_subscript (const struct categoricals *cat, int subscript);