+2008-03-01 Jason Stover <jhs@math.gcsu.edu>
+
+ * coefficient.c (pspp_coeff_init): Ensure first arg is not a null
+ pointer.
+
+ * coefficient.c (pspp_linreg_get_coeff): Make sure we don't return
+ a result beyond the last coefficient, or start with a coefficient
+ beyond the last one if there is only one.
+
2007-06-06 Ben Pfaff <blp@gnu.org>
Adapt case sources, sinks, and clients of procedure code to the
size_t i;
int n_vals = 1;
+ assert (c != NULL);
for (i = 0; i < X->m->size2; i++)
{
c[i] = xmalloc (sizeof (*c[i]));
pspp_linreg_get_coeff (const pspp_linreg_cache * c,
const struct variable *v, const union value *val)
{
- int i = 1;
+ int i;
struct pspp_coeff *result = NULL;
const struct variable *tmp = NULL;
{
return NULL;
}
-
+ /*
+ C->N_COEFFS == 1 means regression through the origin.
+ */
+ i = (c->n_coeffs > 1) ? 1 : 0;
result = c->coeff[i];
tmp = pspp_coeff_get_var (result, 0);
while (tmp != v && i < c->n_coeffs)
tmp = pspp_coeff_get_var (result, 0);
i++;
}
- if (i > c->n_coeffs)
+ if (i >= c->n_coeffs)
{
return NULL;
}