From: John Darrington Date: Tue, 5 Jul 2011 17:45:31 +0000 (+0200) Subject: Categoricals to take interactions instead of variables. X-Git-Tag: v0.7.9~204 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aff9a24395db38ed772be3c3d15cfed0f3b4914b;p=pspp-builds.git Categoricals to take interactions instead of variables. This change alters the API of categoricals_create, so as to accept an array of interactions instead of an array of variables. Currently, however only interactions which contain exactly one variable will run correctly. --- diff --git a/src/language/stats/glm.c b/src/language/stats/glm.c index 0c85965e..4ba93150 100644 --- a/src/language/stats/glm.c +++ b/src/language/stats/glm.c @@ -402,7 +402,8 @@ run_glm (struct glm_spec *cmd, struct casereader *input, struct glm_workspace ws; struct covariance *cov; - ws.cats = categoricals_create (cmd->design_vars, cmd->n_design_vars, + + ws.cats = categoricals_create (cmd->interactions, cmd->n_interactions, cmd->wv, cmd->exclude, NULL, NULL, NULL, NULL); diff --git a/src/language/stats/oneway.c b/src/language/stats/oneway.c index 78bd2150..447bdad1 100644 --- a/src/language/stats/oneway.c +++ b/src/language/stats/oneway.c @@ -651,7 +651,8 @@ run_oneway (const struct oneway_spec *cmd, for (v = 0; v < cmd->n_vars; ++v) { - ws.vws[v].cat = categoricals_create (&cmd->indep_var, 1, cmd->wv, + struct interaction *inter = interaction_create (cmd->indep_var); + ws.vws[v].cat = categoricals_create (&inter, 1, cmd->wv, cmd->exclude, makeit, updateit, CONST_CAST (struct variable *, cmd->vars[v]), diff --git a/src/math/categoricals.c b/src/math/categoricals.c index 78944fca..2d65f8ae 100644 --- a/src/math/categoricals.c +++ b/src/math/categoricals.c @@ -17,6 +17,7 @@ #include #include "math/categoricals.h" +#include "math/interaction.h" #include @@ -215,7 +216,7 @@ lookup_value (const struct hmap *map, const struct variable *var, const union va struct categoricals * -categoricals_create (const struct variable *const *v, size_t n_vars, +categoricals_create (const struct interaction **inter, size_t n_inter, const struct variable *wv, enum mv_class exclude, user_data_create_func *udf, update_func *update, void *aux1, void *aux2 @@ -224,7 +225,7 @@ categoricals_create (const struct variable *const *v, size_t n_vars, size_t i; struct categoricals *cat = xmalloc (sizeof *cat); - cat->n_vp = n_vars; + cat->n_vp = n_inter; cat->wv = wv; cat->n_cats_total = 0; cat->n_vars = 0; @@ -244,7 +245,7 @@ categoricals_create (const struct variable *const *v, size_t n_vars, for (i = 0 ; i < cat->n_vp; ++i) { hmap_init (&cat->vp[i].map); - cat->vp[i].var = v[i]; + cat->vp[i].var = inter[i]->vars[0]; } return cat; diff --git a/src/math/categoricals.h b/src/math/categoricals.h index cd887f09..6ab451d7 100644 --- a/src/math/categoricals.h +++ b/src/math/categoricals.h @@ -24,6 +24,7 @@ struct categoricals; struct variable; struct ccase; +struct interaction; union value ; @@ -36,7 +37,7 @@ typedef void update_func (void *user_data, typedef void *user_data_create_func (void *aux1, void *aux2); -struct categoricals *categoricals_create (const struct variable *const *v, size_t n_vars, +struct categoricals *categoricals_create (const struct interaction **, size_t n_int, const struct variable *wv, enum mv_class exclude, user_data_create_func *udf, update_func *update, void *aux1, void *aux2);