1 /* PSPP - computes sample statistics.
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
29 #include "debug-print.h"
33 vec_init (struct long_vec * v)
39 /* Deletes the contents of V. */
41 vec_clear (struct long_vec * v)
48 /* Inserts ELEM into V. */
50 vec_insert (struct long_vec * v, long elem)
54 v->m = (v->m == 0 ? 16 : 2 * v->m);
55 v->vec = xrealloc (v->vec, v->m * sizeof *v->vec);
57 v->vec[v->n++] = elem;
60 /* Deletes all occurrences of values A through B exclusive from V. */
62 vec_delete (struct long_vec * v, long a, long b)
66 for (i = v->n - 1; i >= 0; i--)
67 if (v->vec[i] >= a && v->vec[i] < b)
68 v->vec[i] = v->vec[--v->n];
71 /* Sticks V->FV in the proper vector. */
73 envector (const struct variable *v)
75 if (v->type == NUMERIC)
78 vec_insert (&init_zero, v->fv);
80 vec_insert (&reinit_sysmis, v->fv);
87 for (i = v->fv; i < v->fv + v->nv; i++)
88 vec_insert (&init_blanks, i);
90 for (i = v->fv; i < v->fv + v->nv; i++)
91 vec_insert (&reinit_blanks, i);
95 /* Removes V->FV from the proper vector. */
97 devector (const struct variable *v)
99 if (v->type == NUMERIC)
102 vec_delete (&init_zero, v->fv, v->fv + 1);
104 vec_delete (&reinit_sysmis, v->fv, v->fv + 1);
107 vec_delete (&init_blanks, v->fv, v->fv + v->nv);
109 vec_delete (&reinit_blanks, v->fv, v->fv + v->nv);