From: Jason H Stover Date: Wed, 3 Jun 2009 19:54:19 +0000 (-0400) Subject: Moved static is_origin from design_matrix.c to category.c: cat_is_origin. X-Git-Tag: v0.7.3~110 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=124dea11f9542304e35bef92b7f3a46d5afca4d7;p=pspp-builds.git Moved static is_origin from design_matrix.c to category.c: cat_is_origin. --- diff --git a/src/data/category.c b/src/data/category.c index 6771b583..3aaf5c55 100644 --- a/src/data/category.c +++ b/src/data/category.c @@ -31,16 +31,14 @@ #include #include +#include +#include +#include +#include +#include #include #include -#include -#include "category.h" -#include "value.h" -#include "variable.h" - -#include "xalloc.h" - #define CAT_VALUE_NOT_FOUND -1 #define N_INITIAL_CATEGORIES 1 @@ -182,3 +180,20 @@ cat_get_n_categories (const struct variable *v) return var_get_obs_vals (v)->n_categories; } +/* + If VAR is categorical with d categories, its first category should + correspond to the origin in d-dimensional Euclidean space. + */ +bool +cat_is_origin (const struct variable *var, const union value *val) +{ + if (var_is_numeric (var)) + { + return false; + } + if (cat_value_find (var, val) == 0) + { + return true; + } + return false; +} diff --git a/src/data/category.h b/src/data/category.h index db4bb339..f90ae7cd 100644 --- a/src/data/category.h +++ b/src/data/category.h @@ -32,7 +32,7 @@ #ifndef CATEGORY_H #define CATEGORY_H - +#include #include struct cat_vals; @@ -61,5 +61,9 @@ cat_get_category_count (const size_t, const struct variable *); */ size_t cat_get_n_categories (const struct variable *v); - +/* + If VAR is categorical with d categories, its first category should + correspond to the origin in d-dimensional Euclidean space. + */ +bool cat_is_origin (const struct variable *, const union value *); #endif diff --git a/src/math/design-matrix.c b/src/math/design-matrix.c index 030efd7a..8f125c58 100644 --- a/src/math/design-matrix.c +++ b/src/math/design-matrix.c @@ -281,23 +281,6 @@ design_matrix_set_element (const struct design_matrix *d, size_t row, size_t col { gsl_matrix_set (d->m, row, col, x); } -/* - If VAR is categorical with d categories, its first category should - correspond to the origin in d-dimensional Euclidean space. - */ -static bool -is_origin (const struct variable *var, const union value *val) -{ - if (var_is_numeric (var)) - { - return false; - } - if (cat_value_find (var, val) == 0) - { - return true; - } - return false; -} /* Return the subscript of the column of the design matrix @@ -314,7 +297,7 @@ dm_get_exact_subscript (const struct design_matrix *dm, const struct variable *v result = design_matrix_var_to_column (dm, var); if (var_is_alpha (var)) { - if (is_origin (var, val)) + if (cat_is_origin (var, val)) { return -1u; }