X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmath%2Fcovariance.c;h=f64e89d1eb2ffbee673c2179e6d2e48b78d066f3;hb=dc29c57e7908b0bdc6ab84f8aa4b7cb8a780026c;hp=a7a5f131651963716ee0b0b5e8b8589a26579b2f;hpb=fe8dc2171009e90d2335f159d05f7e6660e24780;p=pspp-builds.git diff --git a/src/math/covariance.c b/src/math/covariance.c index a7a5f131..f64e89d1 100644 --- a/src/math/covariance.c +++ b/src/math/covariance.c @@ -25,6 +25,7 @@ #include "libpspp/assertion.h" #include "libpspp/misc.h" #include "math/categoricals.h" +#include "math/interaction.h" #include "math/moments.h" #include "gl/xalloc.h" @@ -247,7 +248,7 @@ is_missing (const struct covariance *cov, int i, const struct ccase *c) { 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); @@ -346,11 +347,13 @@ covariance_accumulate_pass2 (struct covariance *cov, const struct ccase *c) 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); @@ -362,9 +365,6 @@ covariance_accumulate_pass2 (struct covariance *cov, const struct ccase *c) 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) { @@ -738,21 +738,4 @@ covariance_dim (const struct covariance * cov) 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, 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); - } -} +