X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flevene.c;h=7877c7ec6aa5fc039efb7fbedff900096977c8a8;hb=28d7aaf2db476de5d62eb90787fef50fec444287;hp=0e36b87a8c12b59817c944be0e14bf14430cb2f6;hpb=df1db8c1d8e330a3c179738ae001aff42079c2e3;p=pspp-builds.git diff --git a/src/levene.c b/src/levene.c index 0e36b87a..7877c7ec 100644 --- a/src/levene.c +++ b/src/levene.c @@ -16,14 +16,16 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ #include #include "levene.h" #include "error.h" #include "case.h" #include "casefile.h" +#include "dictionary.h" +#include "group_proc.h" #include "hash.h" #include "str.h" #include "var.h" @@ -75,8 +77,7 @@ struct levene_info enum lev_missing missing; /* Function to test for missing values */ - is_missing_func is_missing; - + is_missing_func *is_missing; }; /* First pass */ @@ -162,17 +163,18 @@ levene_precalc (const struct levene_info *l) for(i = 0; i < l->n_dep ; ++i ) { struct variable *var = l->v_dep[i]; + struct group_proc *gp = group_proc_get (var); struct group_statistics *gs; struct hsh_iterator hi; lz[i].grand_total = 0; lz[i].total_n = 0; - lz[i].n_groups = var->p.grp_data.n_groups ; + lz[i].n_groups = gp->n_groups ; - for ( gs = hsh_first(var->p.grp_data.group_hash, &hi); + for ( gs = hsh_first(gp->group_hash, &hi); gs != 0; - gs = hsh_next(var->p.grp_data.group_hash, &hi)) + gs = hsh_next(gp->group_hash, &hi)) { gs->lz_total = 0; } @@ -199,7 +201,7 @@ levene_calc (const struct ccase *c, void *_l) struct variable *v = l->v_dep[i]; const union value *val = case_data (c, v->fv); - if (l->is_missing(val,v) ) + if (l->is_missing (&v->miss, val) ) { return 0; } @@ -212,16 +214,17 @@ levene_calc (const struct ccase *c, void *_l) for (i = 0; i < l->n_dep; ++i) { struct variable *var = l->v_dep[i]; + struct group_proc *gp = group_proc_get (var); double levene_z; const union value *v = case_data (c, var->fv); struct group_statistics *gs; - gs = hsh_find(var->p.grp_data.group_hash,(void *) &key ); + gs = hsh_find(gp->group_hash,(void *) &key ); if ( 0 == gs ) continue ; - if ( ! l->is_missing(v,var)) + if ( ! l->is_missing(&var->miss, v)) { levene_z= fabs(v->f - gs->mean); lz[i].grand_total += levene_z * weight; @@ -271,7 +274,7 @@ levene2_precalc (void *_l) struct group_statistics *g; struct variable *var = l->v_dep[v] ; - struct hsh_table *hash = var->p.grp_data.group_hash; + struct hsh_table *hash = group_proc_get (var)->group_hash; for(g = (struct group_statistics *) hsh_first(hash,&hi); @@ -305,7 +308,7 @@ levene2_calc (const struct ccase *c, void *_l) struct variable *v = l->v_dep[i]; const union value *val = case_data (c, v->fv); - if (l->is_missing(val,v) ) + if (l->is_missing(&v->miss, val) ) { return 0; } @@ -321,12 +324,12 @@ levene2_calc (const struct ccase *c, void *_l) const union value *v = case_data (c, var->fv); struct group_statistics *gs; - gs = hsh_find(var->p.grp_data.group_hash,(void *) &key ); + gs = hsh_find(group_proc_get (var)->group_hash,(void *) &key ); if ( 0 == gs ) continue; - if ( ! l->is_missing(v,var) ) + if ( ! l->is_missing (&var->miss, v) ) { levene_z = fabs(v->f - gs->mean); lz_denominator[i] += weight * pow2(levene_z - gs->lz_mean); @@ -351,7 +354,8 @@ levene2_postcalc (void *_l) struct group_statistics *g; struct variable *var = l->v_dep[v] ; - struct hsh_table *hash = var->p.grp_data.group_hash; + struct group_proc *gp = group_proc_get (var); + struct hsh_table *hash = gp->group_hash; for(g = (struct group_statistics *) hsh_first(hash,&hi); g != 0 ; @@ -359,12 +363,11 @@ levene2_postcalc (void *_l) { lz_numerator += g->n * pow2(g->lz_mean - lz[v].grand_mean ); } - lz_numerator *= ( l->v_dep[v]->p.grp_data.ugs.n - - l->v_dep[v]->p.grp_data.n_groups ); + lz_numerator *= ( gp->ugs.n - gp->n_groups ); - lz_denominator[v] *= (l->v_dep[v]->p.grp_data.n_groups - 1); + lz_denominator[v] *= (gp->n_groups - 1); - l->v_dep[v]->p.grp_data.levene = lz_numerator / lz_denominator[v] ; + gp->levene = lz_numerator / lz_denominator[v] ; }