1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 Create design matrices for procedures that need them.
21 #ifndef DESIGN_MATRIX_H
22 #define DESIGN_MATRIX_H
24 #include <gsl/gsl_matrix.h>
26 #include <data/category.h>
28 struct design_matrix_var
30 size_t first_column; /* First column for this variable in
31 the design_matix. If this variable
32 is categorical, its values are
33 stored in multiple, contiguous
34 columns, as dictated by its vector
35 encoding in the variable's struct
39 const struct variable *v;
45 struct design_matrix_var *vars; /* Element i corresponds to
46 the variable whose values
47 are stored in at least one
49 variable is categorical
51 categories, its values are
53 contiguous columns. The
54 variable's values are then
61 size_t *n_cases; /* Element i is the number of valid cases for this
68 struct design_matrix *design_matrix_create (int, const struct variable *[],
71 void design_matrix_destroy (struct design_matrix *);
73 void design_matrix_set_categorical (struct design_matrix *, size_t,
74 const struct variable *,
77 void design_matrix_set_numeric (struct design_matrix *, size_t,
78 const struct variable *,
81 struct design_matrix *design_matrix_clone (const struct design_matrix *);
83 size_t design_matrix_var_to_column (const struct design_matrix *,
84 const struct variable *);
86 const struct variable *design_matrix_col_to_var (const struct design_matrix *,
88 void design_matrix_increment_case_count (struct design_matrix *, const struct variable *);
90 void design_matrix_set_case_count (struct design_matrix *, const struct variable *, size_t);
92 size_t design_matrix_get_case_count (const struct design_matrix *, const struct variable *);
93 size_t design_matrix_get_n_cols (const struct design_matrix *);
94 size_t design_matrix_get_n_rows (const struct design_matrix *);
95 double design_matrix_get_element (const struct design_matrix *, size_t, size_t);
96 void design_matrix_set_element (const struct design_matrix *, size_t, size_t, double);
97 size_t dm_get_exact_subscript (const struct design_matrix *, const struct variable *,