9e58f59eb0c2890bc6260089a1369b4cf9cb5629
[pspp-builds.git] / src / math / categoricals.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 2009 Free Software Foundation, Inc.
3
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.
8
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.
13
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/>. */
16
17
18 #ifndef _CATEGORICALS__
19 #define _CATEGORICALS__
20
21 #include <stddef.h>
22 #include <data/missing-values.h>
23
24 struct categoricals;
25 struct variable;
26 struct ccase;
27
28 union value ;
29
30 struct categoricals *categoricals_create (const struct variable **v, size_t n_vars,
31                                           const struct variable *wv, enum mv_class exclude);
32
33 void categoricals_destroy (struct categoricals *);
34
35 void categoricals_update (struct categoricals *cat, const struct ccase *c);
36
37
38 /* Return the number of categories (distinct values) for variable N */
39 size_t categoricals_n_count (const struct categoricals *cat, size_t n);
40
41
42 /* Return the total number of categories */
43 size_t categoricals_total (const struct categoricals *cat);
44
45 /* Return the index for variable N */
46 int categoricals_index (const struct categoricals *cat, size_t n, const union value *val);
47
48 void categoricals_done (struct categoricals *cat);
49
50 const struct variable * categoricals_get_variable_by_subscript (const struct categoricals *cat, int subscript);
51
52 const union value * categoricals_get_value_by_subscript (const struct categoricals *cat, int subscript);
53
54 double categoricals_get_weight_by_subscript (const struct categoricals *cat, int subscript);
55
56 double categoricals_get_sum_by_subscript (const struct categoricals *cat, int subscript);
57
58 double categoricals_get_binary_by_subscript (const struct categoricals *cat, int subscript,
59                                              const struct ccase *c);
60
61
62
63
64 #endif