1 /* PSPP - computes sample statistics. -*- C -*-
2 Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
3 Written by Ben Pfaff <blp@gnu.org>.
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 /* Included by frequencies.q. */
24 #define FUNCNAME calc_weighting
25 #else /* !WEIGHTING */
27 #define FUNCNAME calc_no_weight
28 #endif /* !WEIGHTING */
31 FUNCNAME (struct ccase *c)
37 w = c->data[default_dict.var[default_dict.weight_index]->fv].f;
40 for (i = 0; i < n_variables; i++)
42 struct variable *v = v_variables[i];
43 union value *val = &c->data[v->fv];
44 struct freq_tab *ft = &v->p.frq.tab;
46 switch (v->p.frq.tab.mode)
50 /* General mode. This declaration and initialization are
51 strictly conforming: see C89 section 6.5.2.1. */
52 struct freq *fp = avl_find (ft->tree, (struct freq *) val);
58 fp = pool_alloc (gen_pool, sizeof *fp);
61 avl_insert (ft->tree, fp);
62 if (is_missing (val, v))
63 v->p.frq.tab.n_missing++;
70 v->p.frq.tab.sysmis += WEIGHT;
71 else if (val->f > INT_MIN+1 && val->f < INT_MAX-1)
74 if (i >= v->p.frq.tab.min && i <= v->p.frq.tab.max)
75 v->p.frq.tab.vector[i - v->p.frq.tab.min] += WEIGHT;
78 v->p.frq.tab.out_of_range += WEIGHT;