1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2010 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/>. */
17 #ifndef OUTPUT_PIVOT_TABLE_H
18 #define OUTPUT_PIVOT_TABLE_H 1
20 #include "data/format.h"
21 #include "data/subcase.h"
22 #include "output/table.h"
27 struct pivot_cell **cells; /* cells[y][x] */
32 struct casereader *data;
33 struct dictionary *dict;
35 struct subcase dimensions[TABLE_N_AXES];
36 struct pivot_pane pane;
37 struct pivot_pane *summaries[TABLE_N_AXES];
40 void pivot_table_dump (struct pivot_table *);
42 enum pivot_comparison_type
44 PIVOT_RAW, /* No comparison. */
46 /* 1-dimensional comparisons. */
47 PIVOT_FRACTION, /* Fraction of an aggregate. */
48 PIVOT_PERCENT, /* Percentage of an aggregate. */
50 /* 2-dimensional comparisons. */
51 PIVOT_EXPECTED, /* row_sum * col_sum / grand_total */
52 PIVOT_RESIDUAL, /* value - expected */
53 PIVOT_SRESIDUAL, /* (value - expected) / sqrt(expected) */
54 PIVOT_ASRESIDUAL /* (value - expected)
56 * (1 - row_sum / grand_total)
57 * (1 - col_sum / grand_total)) */
60 /* A value, possibly compared against other values. */
63 struct pivot_value *base;
66 enum pivot_comparison_type cmp;
67 struct pivot_value *cmp_args[3];
71 struct fmt_spec format;
74 void pivot_cell_init (struct pivot_cell *, struct pivot_value *);
76 /* How to combine potentially multiple values. */
79 PIVOT_EXACTLY_ONE, /* SYSMIS if no values or more than one. */
99 enum pivot_value_include
101 PIVOT_INCLUDE_VALID = 1 << 0,
102 PIVOT_INCLUDE_SYSTEM_MISSING = 1 << 1,
103 PIVOT_INCLUDE_USER_MISSING = 1 << 2,
104 PIVOT_INCLUDE_ALL = 7
107 /* A pivot_value specifies a function whose arguments are the values of:
109 - The split and dimension variables of the pivot table.
111 - The variable specified as part of the pivot_value. (PIVOT_N does not
114 A pivot_value is notionally evaluated as:
116 Given a value for every variable:
117 For every row in the input data:
118 If the row's split variable equal their assigned values:
119 and the row's dimension variables equal their assigned values,
120 except that the aggregate variables, if any, are ignored,
121 and that the cumulative variables are equal or lexicographically
122 less than the assigned values,
123 and the value variable is included according to "include":
124 Submit the value to the operator.
128 const struct variable *var;
129 enum pivot_operator operator;
130 int n_agg_vars[TABLE_N_AXES];
131 int n_cum_vars[TABLE_N_AXES];
132 enum pivot_value_include include;
135 struct pivot_value *pivot_value_create (const struct variable *,
139 enum pivot_value_include);
142 #endif /* output/pivot-table.h */