X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmath%2Fcoefficient.c;h=fed45b64675cd3e763775ad1ac38838d7325addb;hb=b5b474193e450bba97610065df0518c08074a7fb;hp=44b7c0d3219b764b827f704a6b807c60a9adf2e0;hpb=43b1296aafe7582e7dbe6c2b6a8b478d7d9b0fcf;p=pspp-builds.git diff --git a/src/math/coefficient.c b/src/math/coefficient.c index 44b7c0d3..fed45b64 100644 --- a/src/math/coefficient.c +++ b/src/math/coefficient.c @@ -19,7 +19,6 @@ */ #include #include -#include #include "src/math/design-matrix.h" #include @@ -47,7 +46,7 @@ pspp_coeff_free (struct pspp_coeff *c) /* Initialize the variable and value pointers inside the - coefficient structures for the linear model. + coefficient structures for the model. */ void pspp_coeff_init (struct pspp_coeff ** c, const struct design_matrix *X) @@ -55,6 +54,7 @@ pspp_coeff_init (struct pspp_coeff ** c, const struct design_matrix *X) size_t i; int n_vals = 1; + assert (c != NULL); for (i = 0; i < X->m->size2; i++) { c[i] = xmalloc (sizeof (*c[i])); @@ -174,62 +174,3 @@ pspp_coeff_get_value (struct pspp_coeff *c, return NULL; } -/* - Which coefficient is associated with V? The VAL argument is relevant - only to categorical variables. - */ -const struct pspp_coeff * -pspp_linreg_get_coeff (const pspp_linreg_cache * c, - const struct variable *v, const union value *val) -{ - int i = 1; - struct pspp_coeff *result = NULL; - const struct variable *tmp = NULL; - - if (c == NULL) - { - return NULL; - } - if (c->coeff == NULL || c->n_indeps == 0 || v == NULL) - { - return NULL; - } - - result = c->coeff[i]; - tmp = pspp_coeff_get_var (result, 0); - while (tmp != v && i < c->n_coeffs) - { - result = c->coeff[i]; - tmp = pspp_coeff_get_var (result, 0); - i++; - } - if (i > c->n_coeffs) - { - return NULL; - } - if (var_is_numeric (v)) - { - return result; - } - else if (val != NULL) - { - /* - If v is categorical, we need to ensure the coefficient - matches the VAL. - */ - while (tmp != v && i < c->n_coeffs - && compare_values (pspp_coeff_get_value (result, tmp), - val, var_get_width (v))) - { /* FIX THIS */ - i++; - result = c->coeff[i]; - tmp = pspp_coeff_get_var (result, 0); - } - if (i == c->n_coeffs) - { - return NULL; - } - return result; - } - return NULL; -}