-AT_BANNER([MATRIX DATA])
+dnl PSPP - a program for statistical analysis.
+dnl Copyright (C) 2017 Free Software Foundation, Inc.
+dnl
+dnl This program is free software: you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation, either version 3 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
+dnl AT_BANNER([MATRIX DATA])
AT_SETUP([Matrix data (lower file)])
])
AT_CLEANUP
+
+
+
+AT_SETUP([Matrix reader - read integrity])
+
+dnl Check that matrices presented are read correctly.
+dnl The example below is an unlikely one since all
+dnl covariance/correlation matrices must be symetrical
+dnl but it serves a purpose for this test.
+AT_DATA([matrix-reader.pspp], [dnl
+matrix data
+ variables = rowtype_ var01 to var9
+ /format = full.
+
+begin data
+n 1 2 3 4 5 6 7 8 9
+sd 100 200 300 400 500 600 700 800 900
+corr 11 12 13 14 15 16 17 18 19
+corr 21 22 23 24 25 26 27 28 29
+corr 31 32 33 34 35 36 37 38 39
+corr 41 42 43 44 45 46 47 48 49
+corr 51 52 53 54 55 56 57 58 59
+corr 61 62 63 64 65 66 67 68 69
+corr 71 72 73 74 75 76 77 78 79
+corr 81 82 83 84 85 86 87 88 89
+corr 91 92 93 94 95 96 97 98 99
+end data.
+
+factor /matrix = in (corr = *)
+ /analysis var02 var04 var06
+ /method = correlation
+ /rotation = norotate
+ /print correlation.
+])
+
+AT_CHECK([pspp -O format=csv matrix-reader.pspp], [0], [dnl
+Table: Correlation Matrix
+,,var02,var04,var06
+Correlations,var02,22.00,24.00,26.00
+,var04,42.00,44.00,46.00
+,var06,62.00,64.00,66.00
+
+Table: Component Matrix
+,Component,
+,1,2
+var02,6.73,-2.23
+var04,6.95,2.15
+var06,9.22,.01
+])
+
+AT_CLEANUP
+
+
+AT_SETUP([Matrix data - too many rows])
+
+dnl Test for a crash which occurred when the matrix had more rows declared
+dnl than variables to hold them.
+AT_DATA([matrix-data.pspp], [dnl
+matrix data
+ variables = rowtype_
+ var01 var02 var03 var04
+ / format = upper diagonal .
+begin data
+ mean 21.4 5.0 72.9 17.4
+ sd 6.5 1.6 22.8 5.7
+ n 106 106 106 106
+ corr 1.00 .32 .48 .28
+ corr 1.00 .72 .54 .44
+ corr 1.00 .50 .59 .64
+ corr 1.00 .62 .49 -.30
+ corr 1.00 .56 -.38 .52
+ corr 1.00 -.73 .91 .80
+ corr 1.00 -.65 -.60
+ corr 1.00 .70
+ corr 1.00
+end data .
+
+execute.
+])
+
+
+AT_CHECK([pspp -O format=csv matrix-data.pspp], [1], [dnl
+matrix-data.pspp:13: error: MATRIX DATA: There are 4 variable declared but the data has at least 5 matrix rows.
+
+matrix-data.pspp:20: error: EXECUTE: EXECUTE is allowed only after the active dataset has been defined.
+])
+
+
+AT_CLEANUP
+
+
+
+
+AT_SETUP([Matrix data (badly formed)])
+
+AT_DATA([data.pspp], [dnl
+data list list /ROWTYPE_ (a8) VARNAME_(a4) v1 v2 v3 v4xxxxxxxxxxxxxxxxxxxxxzzzzzzzzzzzzzxxxxxxxxx.
+begin data
+mean "" 1 2 3 4
+sd "" 5 6 7 8
+n "" 2 3 4 5
+corr v1 11 22 33 44
+corr v2 55 66 77 88
+corr v3 111 222 333 444
+corr v4 4 3 21 1
+end data.
+
+list.
+
+factor matrix=in(corr = *)
+ .
+])
+
+AT_CHECK([pspp -O format=csv data.pspp], [1], [ignore])
+
+AT_CLEANUP
+
+
+
+
+AT_SETUP([Matrix data (N subcommand)])
+
+AT_DATA([matrix-data.pspp], [dnl
+matrix data
+ variables = rowtype_ var01 var02 var03 var04
+ /n = 99
+ /format = upper nodiagonal.
+begin data
+mean 34 35 36 37
+sd 22 11 55 66
+n_vector 1 2 3 4
+corr 9 8 7
+corr 6 5
+corr 4
+end data.
+
+list.
+])
+
+AT_CHECK([pspp -O format=csv matrix-data.pspp], [0], [dnl
+"matrix-data.pspp:12: warning: MATRIX DATA: The N subcommand was specified, but a N record was also found in the data. The N record will be ignored."
+
+Table: Data List
+ROWTYPE_,VARNAME_,var01,var02,var03,var04
+N ,,99.0000,99.0000,99.0000,99.0000
+mean ,,34.0000,35.0000,36.0000,37.0000
+STDDEV ,,22.0000,11.0000,55.0000,66.0000
+corr ,var01,1.0000,9.0000,8.0000,7.0000
+corr ,var02,9.0000,1.0000,6.0000,5.0000
+corr ,var03,8.0000,6.0000,1.0000,4.0000
+corr ,var04,7.0000,5.0000,4.0000,1.0000
+])
+
+AT_CLEANUP