MATRIX DATA: Fully implement.
[pspp] / src / language / data-io / matrix-reader.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 2017 Free Software Foundation, Inc.
3
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.
8
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.
13
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/>. */
16
17 #ifndef MATRIX_READER_H
18 #define MATRIX_READER_H
19
20 #include <gsl/gsl_matrix.h>
21 #include <stdbool.h>
22
23 struct matrix_material
24 {
25   gsl_matrix *corr;             /* The correlation matrix */
26   gsl_matrix *cov;              /* The covariance matrix */
27
28   /* Moment matrices */
29   gsl_matrix *n;                /* MOMENT 0 */
30   gsl_matrix *mean_matrix;      /* MOMENT 1 */
31   gsl_matrix *var_matrix;       /* MOMENT 2 */
32 };
33
34 #define MATRIX_MATERIAL_INIT { .corr = NULL }
35 void matrix_material_uninit (struct matrix_material *);
36
37 struct dictionary;
38 struct variable;
39 struct casereader;
40
41
42 struct matrix_reader;
43
44 struct matrix_reader *create_matrix_reader_from_case_reader (const struct dictionary *dict,
45                                                              struct casereader *in_reader,
46                                                              const struct variable ***vars, size_t *n_vars);
47
48 bool destroy_matrix_reader (struct matrix_reader *mr);
49
50 bool next_matrix_from_reader (struct matrix_material *mm,
51                               struct matrix_reader *mr,
52                               const struct variable **vars, int n_vars);
53
54
55 #endif