{
struct ctables_freqtab *ft = t->fts[j];
- size_t hash = 0;
+#if 0
+ for (size_t k = 0; k < ft->vars.n; k++)
+ {
+ const struct variable *var = ft->vars.vars[k];
+ if (
+
+ }
+#endif
+ size_t hash = 0;
for (size_t k = 0; k < ft->vars.n; k++)
{
const struct variable *var = ft->vars.vars[k];
{
struct ctables_table *t = &ct->tables[i];
+ struct pivot_table *pt = pivot_table_create (N_("Custom Tables"));
+ struct pivot_dimension *d = pivot_dimension_create (
+ pt, PIVOT_AXIS_ROW, N_("Rows"));
for (size_t j = 0; j < t->n_fts; j++)
{
struct ctables_freqtab *ft = t->fts[j];
size_t n = 0;
HMAP_FOR_EACH (f, struct freq, node, &ft->data)
ft->sorted[n++] = f;
- sort (ft->sorted, ft->data.count, sizeof *ft->sorted,
+ assert (n == ft->data.count);
+ sort (ft->sorted, n, sizeof *ft->sorted,
compare_freq_3way, &ft->vars);
+
+ struct pivot_category **groups = xnmalloc (ft->vars.n,
+ sizeof *groups);
+ for (size_t k = 0; k < n; k++)
+ {
+ struct freq *prev = k > 0 ? ft->sorted[k - 1] : NULL;
+ struct freq *f = ft->sorted[k];
+
+ size_t n_common = 0;
+ if (prev)
+ for (; n_common + 1 < ft->vars.n; n_common++)
+ if (!value_equal (&prev->values[n_common],
+ &f->values[n_common],
+ var_get_type (ft->vars.vars[n_common])))
+ break;
+
+ for (size_t m = n_common; m + 1 < ft->vars.n; m++)
+ groups[m] = pivot_category_create_group__ (
+ m > 0 ? groups[m - 1] : d->root,
+ pivot_value_new_var_value (ft->vars.vars[m], &f->values[m]));
+
+ int leaf = pivot_category_create_leaf (
+ ft->vars.n > 1 ? groups[ft->vars.n - 2] : d->root,
+ pivot_value_new_var_value (ft->vars.vars[ft->vars.n - 1],
+ &f->values[ft->vars.n - 1]));
+
+ pivot_table_put1 (pt, leaf, pivot_value_new_number (f->count));
+ }
+ free (groups);
}
+ pivot_table_submit (pt);
}
for (size_t i = 0; i < ct->n_tables; i++)