f->domains[dt]->valid += weight;
}
+static void
+recurse_totals (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_a, size_t start_va)
+{
+ for (enum pivot_axis_type a = start_a; a < PIVOT_N_AXES; a++)
+ {
+ const struct var_array *va = &t->vaas[a].vas[ix[a]];
+ for (size_t i = start_va; i < va->n; i++)
+ {
+ if (i == va->scale_idx)
+ continue;
+
+ const struct variable *var = va->vars[i];
+
+ const struct ctables_category *total = ctables_categories_total (
+ t->categories[var_get_dict_index (var)]);
+ if (total)
+ {
+ const struct ctables_category *save = cats[a][i];
+ cats[a][i] = total;
+ ctables_cell_insert__ (t, c, ix, cats, weight);
+ recurse_totals (t, c, ix, cats, weight, a, i + 1);
+ cats[a][i] = save;
+ }
+ }
+ start_va = 0;
+ }
+}
+
static void
ctables_cell_insert (struct ctables_table *t,
const struct ccase *c,
ctables_cell_insert__ (t, c, ix, cats, weight);
- for (enum pivot_axis_type a = 0; a < PIVOT_N_AXES; a++)
- {
- const struct var_array *va = &t->vaas[a].vas[ix[a]];
- for (size_t i = 0; i < va->n; i++)
- {
- if (i == va->scale_idx)
- continue;
-
- const struct variable *var = va->vars[i];
-
- const struct ctables_category *total = ctables_categories_total (
- t->categories[var_get_dict_index (var)]);
- if (total)
- {
- const struct ctables_category *save = cats[a][i];
- cats[a][i] = total;
- ctables_cell_insert__ (t, c, ix, cats, weight);
- cats[a][i] = save;
- }
- }
- }
+ recurse_totals (t, c, ix, cats, weight, 0, 0);
}
static bool