#include "libpspp/assertion.h"
#include "libpspp/misc.h"
#include "math/categoricals.h"
+#include "math/interaction.h"
#include "math/moments.h"
#include "gl/xalloc.h"
{
const struct variable *var = i < cov->n_vars ?
cov->vars[i] :
- categoricals_get_variable_by_subscript (cov->categoricals, i - cov->n_vars);
+ categoricals_get_interaction_by_subscript (cov->categoricals, i - cov->n_vars)->vars[0];
const union value *val = case_data (c, var);
assert (cov->state == 1);
cov->state = 2;
+ if (cov->categoricals)
+ categoricals_done (cov->categoricals);
+
cov->dim = cov->n_vars;
if (cov->categoricals)
- cov->dim += categoricals_total (cov->categoricals)
- - categoricals_get_n_variables (cov->categoricals);
+ cov->dim += categoricals_df_total (cov->categoricals);
cov->n_cm = (cov->dim * (cov->dim - 1) ) / 2;
cov->cm = xcalloc (sizeof *cov->cm, cov->n_cm);
cov->moments[i] = resize_matrix (cov->moments[i], cov->dim);
}
- if (cov->categoricals)
- categoricals_done (cov->categoricals);
-
/* Populate the moments matrices with the categorical value elements */
for (i = cov->n_vars; i < cov->dim; ++i)
{
return (cov->dim);
}
-/*
- Returns an array of variables corresponding to rows of the covariance matrix.
- In other words, element i of the array is the variable corresponding to
- row (and column) i of the covariance matrix.
- */
-void
-covariance_get_var_indices (const struct covariance *cov, const struct variable **vars)
-{
- int i;
- for (i = 0; i < cov->n_vars; i++)
- {
- vars[i] = cov->vars[i];
- }
- for (i = cov->n_vars; i < cov->dim; i++)
- {
- vars[i] = categoricals_get_variable_by_subscript (cov->categoricals, i - cov->n_vars);
- }
-}
+