projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add ability for reverse iteration to tower code, and corresponding
[pspp]
/
src
/
math
/
linreg
/
linreg.c
diff --git
a/src/math/linreg/linreg.c
b/src/math/linreg/linreg.c
index 6bbd94c50cb8e742d6ec011d2a768d1685f6e47f..558f6646fe33dde8e2ed19bcac22fd2614e76bb1 100644
(file)
--- a/
src/math/linreg/linreg.c
+++ b/
src/math/linreg/linreg.c
@@
-18,6
+18,7
@@
Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
*/
Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
*/
+#include <config.h>
#include <gsl/gsl_fit.h>
#include <gsl/gsl_multifit.h>
#include <gsl/gsl_fit.h>
#include <gsl/gsl_multifit.h>
@@
-94,7
+95,7
@@
linreg_mean_std (gsl_vector_const_view v, double *mp, double *sp, double *ssp)
The return value is the number of distinct variables found.
*/
int
The return value is the number of distinct variables found.
*/
int
-pspp_linreg_get_vars (const void *c_, struct variable **v)
+pspp_linreg_get_vars (const void *c_,
const
struct variable **v)
{
const pspp_linreg_cache *c = c_;
struct pspp_coeff *coef = NULL;
{
const pspp_linreg_cache *c = c_;
struct pspp_coeff *coef = NULL;
@@
-113,7
+114,7
@@
pspp_linreg_get_vars (const void *c_, struct variable **v)
/*
Start at c->coeff[1] to avoid the intercept.
*/
/*
Start at c->coeff[1] to avoid the intercept.
*/
- v[result] =
(struct variable *)
pspp_coeff_get_var (c->coeff[1], 0);
+ v[result] = pspp_coeff_get_var (c->coeff[1], 0);
result = (v[result] == NULL) ? 0 : 1;
for (coef = c->coeff[2]; coef < c->coeff[c->n_coeffs]; coef++)
result = (v[result] == NULL) ? 0 : 1;
for (coef = c->coeff[2]; coef < c->coeff[c->n_coeffs]; coef++)
@@
-129,7
+130,7
@@
pspp_linreg_get_vars (const void *c_, struct variable **v)
}
if (i < 0 && result < c->n_coeffs)
{
}
if (i < 0 && result < c->n_coeffs)
{
- v[result] =
(struct variable *)
tmp;
+ v[result] = tmp;
result++;
}
}
result++;
}
}
@@
-181,15
+182,18
@@
pspp_linreg_cache_free (void *m)
int i;
pspp_linreg_cache *c = m;
int i;
pspp_linreg_cache *c = m;
- gsl_vector_free (c->indep_means);
- gsl_vector_free (c->indep_std);
- gsl_vector_free (c->ss_indeps);
- gsl_matrix_free (c->cov);
- for (i = 0; i < c->n_coeffs; i++)
+ if (c != NULL)
{
{
- pspp_coeff_free (c->coeff[i]);
+ gsl_vector_free (c->indep_means);
+ gsl_vector_free (c->indep_std);
+ gsl_vector_free (c->ss_indeps);
+ gsl_matrix_free (c->cov);
+ for (i = 0; i < c->n_coeffs; i++)
+ {
+ pspp_coeff_free (c->coeff[i]);
+ }
+ free (c);
}
}
- free (c);
return true;
}
return true;
}