From: John Darrington Date: Mon, 11 Jul 2011 06:58:46 +0000 (+0200) Subject: GLM: get_ssq: replace hardcoded 1 with cmd->n_dep_vars X-Git-Tag: v0.7.9~198 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9067e08a4cbccfef01305ce66d4295905bbd78c4;p=pspp-builds.git GLM: get_ssq: replace hardcoded 1 with cmd->n_dep_vars --- diff --git a/src/language/stats/glm.c b/src/language/stats/glm.c index 2a2cbd54..54e60c05 100644 --- a/src/language/stats/glm.c +++ b/src/language/stats/glm.c @@ -324,25 +324,22 @@ not_dropped (size_t j, size_t * dropped, size_t n_dropped) static void get_ssq (struct covariance *cov, gsl_vector * ssq, const struct glm_spec *cmd) { - const struct variable **vars; - gsl_matrix *small_cov = NULL; gsl_matrix *cm = covariance_calculate_unnormalized (cov); size_t i; size_t j; size_t k; - size_t n; - size_t m; - size_t *dropped; - size_t n_dropped; + size_t *dropped = xcalloc (covariance_dim (cov), sizeof (*dropped)); + const struct variable **vars = xcalloc (covariance_dim (cov), sizeof (*vars)); - dropped = xcalloc (covariance_dim (cov), sizeof (*dropped)); - vars = xcalloc (covariance_dim (cov), sizeof (*vars)); covariance_get_var_indices (cov, vars); for (k = 0; k < cmd->n_interactions; k++) { - n_dropped = 0; - for (i = 1; i < covariance_dim (cov); i++) + size_t n = 0; + size_t m = 0; + gsl_matrix *small_cov = NULL; + size_t n_dropped = 0; + for (i = cmd->n_dep_vars; i < covariance_dim (cov); i++) { if (vars[i] == cmd->interactions[k]->vars[0]) { @@ -353,8 +350,6 @@ get_ssq (struct covariance *cov, gsl_vector * ssq, const struct glm_spec *cmd) small_cov = gsl_matrix_alloc (cm->size1 - n_dropped, cm->size2 - n_dropped); gsl_matrix_set (small_cov, 0, 0, gsl_matrix_get (cm, 0, 0)); - n = 0; - m = 0; for (i = 0; i < cm->size1; i++) { if (not_dropped (i, dropped, n_dropped))