work on missing value handling
[pspp] / src / math / interaction.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 2011 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 _INTERACTION_H__
19 #define _INTERACTION_H__ 1
20
21 #include <stdbool.h>
22 #include "libpspp/compiler.h"
23 #include "data/missing-values.h"
24
25 struct ccase;
26 struct interaction;
27 struct string;
28 struct variable;
29
30 #include <stddef.h>
31
32 /* An interaction is a structure containing a "product" of other variables.
33    The variables can be either string or numeric.
34
35    Interaction is commutative.  That means, that from a mathematical point of
36    view, the order of the variables is irrelevant.  However, for display
37    purposes, and for matching with an interaction's value the order is
38    pertinent.  Therefore, when using these functions, make sure the orders of
39    variables and values match when appropriate.
40
41    Some functions for interactions will not work properly for interactions that
42    contain a given variable more than once, so this should be regarded as an
43    invariant.  The functions to modify interactions don't check for this
44    invariant. */
45 struct interaction
46   {
47     const struct variable **vars;
48     size_t n_vars;
49   };
50
51 struct interaction *interaction_create (const struct variable *);
52 struct interaction *interaction_clone (const struct interaction *);
53 void interaction_destroy (struct interaction *);
54 void interaction_add_variable (struct interaction *, const struct variable *);
55 void interaction_dump (const struct interaction *);
56 void interaction_to_string (const struct interaction *, struct string *str);
57 bool interaction_is_proper_subset (const struct interaction *,
58                                    const struct interaction *);
59 bool interaction_is_subset (const struct interaction *,
60                             const struct interaction *);
61
62
63 unsigned int interaction_case_hash (const struct interaction *,
64                                     const struct ccase *,
65                                     unsigned int base) WARN_UNUSED_RESULT;
66 bool interaction_case_equal (const struct interaction *, const struct ccase *,
67                              const struct ccase *);
68 bool interaction_case_is_missing (const struct interaction *,
69                                   const struct ccase *, enum mv_class);
70 int interaction_case_cmp_3way (const struct interaction *,
71                                const struct ccase *, const struct ccase *);
72
73 #endif