X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmath%2Fcoefficient.c;h=156c782d5a03e4a750437fa43e9588f35f472f19;hb=09907ebe926441d6a6834f358844e10358ea86e2;hp=1868bda4aa6ceb30b85a4b77191c70c4fc83f6f7;hpb=7db1398e16e52bd5da6eb828d4e28fe5b5c2fdf0;p=pspp-builds.git diff --git a/src/math/coefficient.c b/src/math/coefficient.c index 1868bda4..156c782d 100644 --- a/src/math/coefficient.c +++ b/src/math/coefficient.c @@ -195,11 +195,8 @@ pspp_linreg_get_coeff (const pspp_linreg_cache * c, { return NULL; } - /* - C->N_COEFFS == 1 means regression through the origin. - */ - i = (c->n_coeffs > 1) ? 1 : 0; - result = c->coeff[i]; + i = 0; + result = c->coeff[0]; tmp = pspp_coeff_get_var (result, 0); while (tmp != v && i < c->n_coeffs) { @@ -207,8 +204,11 @@ pspp_linreg_get_coeff (const pspp_linreg_cache * c, tmp = pspp_coeff_get_var (result, 0); i++; } - if (i >= c->n_coeffs) + if (tmp != v) { + /* + Not found. + */ return NULL; } if (var_is_numeric (v)) @@ -229,7 +229,7 @@ pspp_linreg_get_coeff (const pspp_linreg_cache * c, result = c->coeff[i]; tmp = pspp_coeff_get_var (result, 0); } - if (i == c->n_coeffs) + if (i == c->n_coeffs && tmp != v) { return NULL; }