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
20 /* AIX requires this to be the first thing in the file. */
23 #define alloca __builtin_alloca
31 #ifndef alloca /* predefined by HP cc +Olibcalls */
46 #include "debug-print.h"
50 vec_init (struct long_vec * v)
56 /* Deletes the contents of V. */
58 vec_clear (struct long_vec * v)
65 /* Inserts ELEM into V. */
67 vec_insert (struct long_vec * v, long elem)
71 v->m = (v->m == 0 ? 16 : 2 * v->m);
72 v->vec = xrealloc (v->vec, v->m * sizeof *v->vec);
74 v->vec[v->n++] = elem;
77 /* Deletes all occurrences of values A through B exclusive from V. */
79 vec_delete (struct long_vec * v, long a, long b)
83 for (i = v->n - 1; i >= 0; i--)
84 if (v->vec[i] >= a && v->vec[i] < b)
85 v->vec[i] = v->vec[--v->n];
88 /* Sticks V->FV in the proper vector. */
90 envector (const struct variable *v)
92 if (v->type == NUMERIC)
95 vec_insert (&init_zero, v->fv);
97 vec_insert (&reinit_sysmis, v->fv);
104 for (i = v->fv; i < v->fv + v->nv; i++)
105 vec_insert (&init_blanks, i);
107 for (i = v->fv; i < v->fv + v->nv; i++)
108 vec_insert (&reinit_blanks, i);
112 /* Removes V->FV from the proper vector. */
114 devector (const struct variable *v)
116 if (v->type == NUMERIC)
119 vec_delete (&init_zero, v->fv, v->fv + 1);
121 vec_delete (&reinit_sysmis, v->fv, v->fv + 1);
124 vec_delete (&init_blanks, v->fv, v->fv + v->nv);
126 vec_delete (&reinit_blanks, v->fv, v->fv + v->nv);