/* PSPP - Binary encodings for categorical variables.
Copyright (C) 2005 Free Software Foundation, Inc.
- Written by Jason H Stover <jason@sakla.net>.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
/*
Functions and data structures to recode categorical variables into
vectors and sub-rows of matrices.
-
+
To fit many types of statistical models, it is necessary
to change each value of a categorical variable to a vector with binary
entries. These vectors are then stored as sub-rows within a matrix
*/
-#ifndef CAT_H
-#define CAT_H
-#define CAT_VALUE_NOT_FOUND -2
-#include <stdbool.h>
+#ifndef CATEGORY_H
+#define CATEGORY_H
+
#include <stddef.h>
+struct cat_vals;
+struct variable ;
union value;
-struct variable ;
-/*
- This structure contains the observed values of a
- categorical variable.
- */
-struct cat_vals
-{
- union value *vals;
- size_t n_categories;
- size_t n_allocated_categories; /* This is used only during
- initialization to keep
- track of the number of
- values stored.
- */
-};
+void cat_stored_values_create (const struct variable *);
+void cat_stored_values_destroy (struct cat_vals *);
+
+size_t cat_value_find (const struct variable *, const union value *);
+
+const union value *cat_subscript_to_value (const size_t,
+ const struct variable *);
+
+
+void cat_value_update (const struct variable *, const union value *);
+
/*
Return the number of categories of a categorical variable.