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
23 #include "file-handle.h"
31 #include "debug-print.h"
36 struct variable **v1, **v2;
40 struct cor_set *cor_list, *cor_last;
42 struct file_handle *matrix_file;
44 static void free_correlations_state (void);
45 static int internal_cmd_correlations (void);
48 cmd_correlations (void)
50 int result = internal_cmd_correlations ();
51 free_correlations_state ();
56 "CORRELATIONS" (cor_):
58 +missing=miss:!pairwise/listwise,
60 +print=tail:!twotail/onetail,
62 +format=fmt:!matrix/serial;
64 +statistics[st_]=descriptives,xprod,all.
70 internal_cmd_correlations (void)
72 struct cmd_correlations cmd;
74 cor_list = cor_last = NULL;
77 lex_match_id ("PEARSON");
78 lex_match_id ("CORRELATIONS");
80 if (!parse_correlations (&cmd))
82 free_correlations (&cmd);
88 cor_custom_variables (struct cmd_correlations *cmd unused)
90 struct variable **v1, **v2;
94 /* Ensure that this is a VARIABLES subcommand. */
95 if (!lex_match_id ("VARIABLES") && (token != T_ID || !is_varname (tokid))
100 if (!parse_variables (&default_dict, &v1, &nv1,
101 PV_NO_DUPLICATE | PV_NUMERIC))
104 if (lex_match (T_WITH))
106 if (!parse_variables (&default_dict, &v2, &nv2,
107 PV_NO_DUPLICATE | PV_NUMERIC))
119 cor = xmalloc (sizeof *cor);
126 cor_last = cor_last->next = cor;
128 cor_list = cor_last = cor;
134 cor_custom_matrix (struct cmd_correlations *cmd unused)
136 if (!lex_force_match ('('))
140 matrix_file = inline_file;
142 matrix_file = fh_parse_file_handle ();
147 if (!lex_force_match (')'))
154 free_correlations_state (void)
156 struct cor_set *cor, *next;
158 for (cor = cor_list; cor != NULL; cor = next)
161 if (cor->v1 != cor->v2)