projects
/
pspp-builds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added checks for pointers to coefficient
[pspp-builds.git]
/
src
/
math
/
coefficient.c
diff --git
a/src/math/coefficient.c
b/src/math/coefficient.c
index 44b7c0d3219b764b827f704a6b807c60a9adf2e0..1868bda4aa6ceb30b85a4b77191c70c4fc83f6f7 100644
(file)
--- a/
src/math/coefficient.c
+++ b/
src/math/coefficient.c
@@
-55,6
+55,7
@@
pspp_coeff_init (struct pspp_coeff ** c, const struct design_matrix *X)
size_t i;
int n_vals = 1;
size_t i;
int n_vals = 1;
+ assert (c != NULL);
for (i = 0; i < X->m->size2; i++)
{
c[i] = xmalloc (sizeof (*c[i]));
for (i = 0; i < X->m->size2; i++)
{
c[i] = xmalloc (sizeof (*c[i]));
@@
-182,7
+183,7
@@
const struct pspp_coeff *
pspp_linreg_get_coeff (const pspp_linreg_cache * c,
const struct variable *v, const union value *val)
{
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;
struct pspp_coeff *result = NULL;
const struct variable *tmp = NULL;
@@
-194,7
+195,10
@@
pspp_linreg_get_coeff (const pspp_linreg_cache * c,
{
return 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)
result = c->coeff[i];
tmp = pspp_coeff_get_var (result, 0);
while (tmp != v && i < c->n_coeffs)
@@
-203,7
+207,7
@@
pspp_linreg_get_coeff (const pspp_linreg_cache * c,
tmp = pspp_coeff_get_var (result, 0);
i++;
}
tmp = pspp_coeff_get_var (result, 0);
i++;
}
- if (i > c->n_coeffs)
+ if (i >
=
c->n_coeffs)
{
return NULL;
}
{
return NULL;
}