X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmath%2Flinreg.c;h=f5ae33e5823f4f79cfaccd73637316baa2f96d0f;hb=c024275ff35e579eddef18b23b1d9c7dc81c4ca8;hp=306ef31306d0ceca972d344313b44ebec2795fec;hpb=6c1c66790acdd2c12cf2cca4555f70f20a4d21d7;p=pspp-builds.git diff --git a/src/math/linreg.c b/src/math/linreg.c index 306ef313..f5ae33e5 100644 --- a/src/math/linreg.c +++ b/src/math/linreg.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -96,10 +95,10 @@ 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 -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 variable *tmp; + const struct variable *tmp; int i; int j; int result = 0; @@ -661,15 +660,18 @@ void pspp_linreg_set_indep_variable_mean (pspp_linreg_cache *c, const struct var only variables in the model are in the covariance matrix. */ static struct design_matrix * -rearrange_covariance_matrix (const struct design_matrix *cov, pspp_linreg_cache *c) +rearrange_covariance_matrix (const struct covariance_matrix *cm, pspp_linreg_cache *c) { - struct variable **model_vars; + const struct variable **model_vars; + struct design_matrix *cov; struct design_matrix *result; size_t *permutation; size_t i; size_t j; size_t k; + assert (cm != NULL); + cov = covariance_to_design (cm); assert (cov != NULL); assert (c != NULL); assert (cov->m->size1 > 0); @@ -719,8 +721,8 @@ rearrange_covariance_matrix (const struct design_matrix *cov, pspp_linreg_cache having to alter it. The problem is that this means the caller must set CACHE->N_COEFFS. */ -int -pspp_linreg_with_cov (const struct design_matrix *full_cov, +void +pspp_linreg_with_cov (const struct covariance_matrix *full_cov, pspp_linreg_cache * cache) { struct design_matrix *cov; @@ -732,6 +734,12 @@ pspp_linreg_with_cov (const struct design_matrix *full_cov, cache_init (cache); reg_sweep (cov->m); post_sweep_computations (cache, cov, cov->m); - covariance_matrix_destroy (cov); + design_matrix_destroy (cov); +} + +double pspp_linreg_mse (const pspp_linreg_cache *c) +{ + assert (c != NULL); + return (c->sse / c->dfe); }