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 */
47 /*#define DEBUGGING 1*/
48 #include "debug-print.h"
52 vec_init (struct long_vec * v)
58 /* Deletes the contents of V. */
60 vec_clear (struct long_vec * v)
67 /* Inserts ELEM into V. */
69 vec_insert (struct long_vec * v, long elem)
73 v->m = (v->m == 0 ? 16 : 2 * v->m);
74 v->vec = xrealloc (v->vec, v->m * sizeof *v->vec);
76 v->vec[v->n++] = elem;
79 /* Deletes all occurrences of values A through B exclusive from V. */
81 vec_delete (struct long_vec * v, long a, long b)
85 for (i = v->n - 1; i >= 0; i--)
86 if (v->vec[i] >= a && v->vec[i] < b)
87 v->vec[i] = v->vec[--v->n];
90 /* Sticks V->FV in the proper vector. */
92 envector (const struct variable *v)
94 if (v->type == NUMERIC)
97 vec_insert (&init_zero, v->fv);
99 vec_insert (&reinit_sysmis, v->fv);
106 for (i = v->fv; i < v->fv + v->nv; i++)
107 vec_insert (&init_blanks, i);
109 for (i = v->fv; i < v->fv + v->nv; i++)
110 vec_insert (&reinit_blanks, i);
114 /* Removes V->FV from the proper vector. */
116 devector (const struct variable *v)
118 if (v->type == NUMERIC)
121 vec_delete (&init_zero, v->fv, v->fv + 1);
123 vec_delete (&reinit_sysmis, v->fv, v->fv + 1);
126 vec_delete (&init_blanks, v->fv, v->fv + v->nv);
128 vec_delete (&reinit_blanks, v->fv, v->fv + v->nv);