struct hmap_node node;
/* The domains that contain this cell. */
+ bool contributes_to_domains;
struct ctables_domain *domains[N_CTDTS];
bool hide;
cell = xmalloc (sizeof *cell);
cell->hide = false;
cell->sv = sv;
+ cell->contributes_to_domains = true;
for (enum pivot_axis_type a = 0; a < PIVOT_N_AXES; a++)
{
const struct ctables_nest *nest = &t->stacks[a].nests[ix[a]];
: NULL);
for (size_t i = 0; i < nest->n; i++)
{
+ const struct ctables_category *cat = cats[a][i];
+
if (i != nest->scale_idx)
{
- const struct ctables_category *subtotal = cats[a][i]->subtotal;
+ const struct ctables_category *subtotal = cat->subtotal;
if (subtotal && subtotal->type == CCT_HSUBTOTAL)
cell->hide = true;
+
+ if (cat->type == CCT_TOTAL || cat->type == CCT_SUBTOTAL || cat->type == CCT_HSUBTOTAL)
+ cell->contributes_to_domains = false;
}
- cell->axes[a].cvs[i].category = cats[a][i];
+ cell->axes[a].cvs[i].category = cat;
value_clone (&cell->axes[a].cvs[i].value, case_data (c, nest->vars[i]),
var_get_width (nest->vars[i]));
}
for (size_t i = 0; i < specs->n; i++)
ctables_summary_add (&cell->summaries[i], &specs->specs[i], specs->var,
case_data (c, specs->var), weight);
- for (enum ctables_domain_type dt = 0; dt < N_CTDTS; dt++)
- cell->domains[dt]->valid += weight;
+ if (cell->contributes_to_domains)
+ for (enum ctables_domain_type dt = 0; dt < N_CTDTS; dt++)
+ cell->domains[dt]->valid += weight;
}
static void
}
}
+static void
+recurse_subtotals (struct ctables_table *t, const struct ccase *c,
+ size_t ix[PIVOT_N_AXES],
+ const struct ctables_category *cats[PIVOT_N_AXES][10],
+ double weight,
+ enum pivot_axis_type start_axis, size_t start_nest)
+{
+ for (enum pivot_axis_type a = start_axis; a < PIVOT_N_AXES; a++)
+ {
+ const struct ctables_nest *nest = &t->stacks[a].nests[ix[a]];
+ for (size_t i = start_nest; i < nest->n; i++)
+ {
+ if (i == nest->scale_idx)
+ continue;
+
+ const struct ctables_category *save = cats[a][i];
+ if (save->subtotal)
+ {
+ cats[a][i] = save->subtotal;
+ ctables_cell_add__ (t, c, ix, cats, weight);
+ recurse_subtotals (t, c, ix, cats, weight, a, i + 1);
+ cats[a][i] = save;
+ }
+ }
+ start_nest = 0;
+ }
+}
+
static void
ctables_cell_insert (struct ctables_table *t,
const struct ccase *c,
ctables_cell_add__ (t, c, ix, cats, weight);
recurse_totals (t, c, ix, cats, weight, 0, 0);
-
- for (enum pivot_axis_type a = 0; a < PIVOT_N_AXES; a++)
- {
- const struct ctables_nest *nest = &t->stacks[a].nests[ix[a]];
- for (size_t i = 0; i < nest->n; i++)
- {
- if (i == nest->scale_idx)
- continue;
-
- const struct ctables_category *save = cats[a][i];
- if (save->subtotal)
- {
- cats[a][i] = save->subtotal;
- ctables_cell_add__ (t, c, ix, cats, weight);
- cats[a][i] = save;
- }
- }
- }
+ recurse_subtotals (t, c, ix, cats, weight, 0, 0);
}
struct merge_item