const struct matrix_state *s = cmd->state;
struct pivot_table *table = pivot_table_create (N_("Matrix Variables"));
- pivot_dimension_create (
- table, PIVOT_AXIS_COLUMN, N_("Property"),
- N_("Rows"), N_("Columns"), N_("Size (kB)"));
+ struct pivot_dimension *attr_dimension
+ = pivot_dimension_create (table, PIVOT_AXIS_COLUMN, N_("Attribute"));
+ pivot_category_create_group (attr_dimension->root, N_("Dimension"),
+ N_("Rows"), N_("Columns"));
+ pivot_category_create_leaves (attr_dimension->root, N_("Size (kB)"));
const struct matrix_var **vars = xmalloc (hmap_count (&s->vars) * sizeof *vars);
size_t n_vars = 0;
matrix_mget_commit_var (struct ccase **rows, size_t n_rows,
const struct dictionary *d,
const struct variable *rowtype_var,
- struct matrix_state *s, size_t si, size_t fi,
+ struct matrix_state *s,
+ size_t ss, size_t sn, size_t si,
+ size_t fs, size_t fn, size_t fi,
size_t cs, size_t cn,
struct pivot_table *pt,
struct pivot_dimension *var_dimension)
int var_index = pivot_category_create_leaf (
var_dimension->root, pivot_value_new_user_text (ds_cstr (&name), SIZE_MAX));
double values[] = { n_rows, cn };
+ for (size_t j = 0; j < sn; j++)
+ {
+ struct variable *var = dict_get_var (d, ss + j);
+ pivot_table_put2 (pt, j, var_index,
+ pivot_value_new_number (case_num (rows[0], var)));
+ }
+ for (size_t j = 0; j < fn; j++)
+ {
+ struct variable *var = dict_get_var (d, fs + j);
+ pivot_table_put2 (pt, j + sn, var_index,
+ pivot_value_new_number (case_num (rows[0], var)));
+ }
for (size_t j = 0; j < sizeof values / sizeof *values; j++)
- pivot_table_put2 (pt, j, var_index, pivot_value_new_integer (values[j]));
+ pivot_table_put2 (pt, j + sn + fn, var_index,
+ pivot_value_new_integer (values[j]));
if (n_missing)
msg (SE, ngettext ("Matrix data file variable %s contains a missing "
static void
matrix_cmd_execute_mget__ (struct mget_command *mget,
- struct casereader *r, const struct dictionary *d,
- struct pivot_table *pt,
- struct pivot_dimension *var_dimension)
+ struct casereader *r, const struct dictionary *d)
{
const struct variable *rowtype_ = get_a8_var (d, "ROWTYPE_");
const struct variable *varname_ = get_a8_var (d, "VARNAME_");
size_t cn = dict_get_var_cnt (d) - cs;
struct ccase *cc = NULL;
+ /* Pivot table. */
+ struct pivot_table *pt = pivot_table_create (
+ N_("Matrix Variables Created by MGET"));
+ struct pivot_dimension *attr_dimension = pivot_dimension_create (
+ pt, PIVOT_AXIS_COLUMN, N_("Attribute"));
+ struct pivot_dimension *var_dimension = pivot_dimension_create (
+ pt, PIVOT_AXIS_ROW, N_("Variable"));
+ if (sn > 0)
+ {
+ struct pivot_category *splits = pivot_category_create_group (
+ attr_dimension->root, N_("Split Values"));
+ for (size_t i = 0; i < sn; i++)
+ pivot_category_create_leaf (splits, pivot_value_new_variable (
+ dict_get_var (d, ss + i)));
+ }
+ if (fn > 0)
+ {
+ struct pivot_category *factors = pivot_category_create_group (
+ attr_dimension->root, N_("Factor Values"));
+ for (size_t i = 0; i < fn; i++)
+ pivot_category_create_leaf (factors, pivot_value_new_variable (
+ dict_get_var (d, fs + i)));
+ }
+ pivot_category_create_group (attr_dimension->root, N_("Dimensions"),
+ N_("Rows"), N_("Columns"));
+
/* Matrix. */
struct ccase **rows = NULL;
size_t allocated_rows = 0;
if (change != NOTHING_CHANGED)
{
matrix_mget_commit_var (rows, n_rows, d, rowtype_,
- mget->state, si, fi, cs, cn,
+ mget->state,
+ ss, sn, si,
+ fs, fn, fi,
+ cs, cn,
pt, var_dimension);
n_rows = 0;
case_unref (cc);
}
}
matrix_mget_commit_var (rows, n_rows, d, rowtype_,
- mget->state, si, fi, cs, cn,
+ mget->state,
+ ss, sn, si,
+ fs, fn, fi,
+ cs, cn,
pt, var_dimension);
free (rows);
case_unref (sc);
case_unref (fc);
case_unref (cc);
+
+ if (var_dimension->n_leaves)
+ pivot_table_submit (pt);
+ else
+ pivot_table_unref (pt);
}
static void
if (matrix_open_casereader ("MGET", mget->file, mget->encoding,
mget->state->dataset, &r, &d))
{
- struct pivot_table *pt = pivot_table_create (
- N_("Matrix Variables Created by MGET"));
- pivot_dimension_create (pt, PIVOT_AXIS_COLUMN, N_("Dimension"),
- N_("Rows"), N_("Columns"));
- struct pivot_dimension *var_dimension = pivot_dimension_create (
- pt, PIVOT_AXIS_ROW, N_("Variable"));
- matrix_cmd_execute_mget__ (mget, r, d, pt, var_dimension);
- if (var_dimension->n_leaves)
- pivot_table_submit (pt);
- else
- pivot_table_unref (pt);
-
+ matrix_cmd_execute_mget__ (mget, r, d);
matrix_close_casereader (mget->file, mget->state->dataset, r, d);
}
}