Constness
[pspp] / 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 *const *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 /*
46   Return the total number of variables which participated in these categoricals.
47   Due to the possibility of missing values, this is NOT necessarily
48   equal to the number of variables passed in when the object was
49   created.
50 */
51 size_t categoricals_get_n_variables (const struct categoricals *cat);
52
53 void categoricals_done (struct categoricals *cat);
54
55 const struct variable * categoricals_get_variable_by_subscript (const struct categoricals *cat, int subscript);
56
57 const union value * categoricals_get_value_by_subscript (const struct categoricals *cat, int subscript);
58
59 double categoricals_get_weight_by_subscript (const struct categoricals *cat, int subscript);
60
61 double categoricals_get_sum_by_subscript (const struct categoricals *cat, int subscript);
62
63 double categoricals_get_binary_by_subscript (const struct categoricals *cat, int subscript,
64                                              const struct ccase *c);
65
66
67
68
69
70 #endif