Add reverse map entries to categoricals.
[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
23 struct categoricals;
24 struct variable;
25 struct ccase;
26
27 union value ;
28
29 struct categoricals *categoricals_create (const struct variable **v, size_t n_vars,
30                                           const struct variable *wv);
31
32 void categoricals_destroy (struct categoricals *);
33
34 void categoricals_update (struct categoricals *cat, const struct ccase *c);
35
36
37 /* Return the number of categories (distinct values) for variable N */
38 size_t categoricals_n_count (const struct categoricals *cat, size_t n);
39
40
41 /* Return the total number of categories */
42 size_t categoricals_total (const struct categoricals *cat);
43
44 /* Return the index for variable N */
45 int categoricals_index (const struct categoricals *cat, size_t n, const union value *val);
46
47 void categoricals_done (struct categoricals *cat);
48
49 const struct variable * categoricals_get_variable_by_subscript (const struct categoricals *cat, int subscript);
50
51 const union value * categoricals_get_value_by_subscript (const struct categoricals *cat, int subscript);
52
53 double categoricals_get_binary_by_subscript (const struct categoricals *cat, int subscript,
54                                              const struct ccase *c);
55
56
57 #endif