Mercurial > octave
annotate test/mk-sparse-tst.sh @ 32064:5f5d8edbeb4f
* mk-sparse-tst.sh: Fix name of script in comments and messages.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 27 Apr 2023 13:26:53 -0400 |
parents | 3b9305e62bb7 |
children | c9e496db7951 |
rev | line source |
---|---|
20303
3c87bcf7e0f9
* build-sparse-tests.sh: Fix name of file in comments to match file name.
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
1 #! /bin/sh |
5590 | 2 |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
3 ######################################################################## |
29357
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
29261
diff
changeset
|
4 ## |
31706
597f3ee61a48
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
5 ## Copyright (C) 2006-2023 The Octave Project Developers |
29357
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
29261
diff
changeset
|
6 ## |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
29261
diff
changeset
|
7 ## See the file COPYRIGHT.md in the top-level directory of this |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
29261
diff
changeset
|
8 ## distribution or <https://octave.org/copyright/>. |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
29261
diff
changeset
|
9 ## |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
29261
diff
changeset
|
10 ## This file is part of Octave. |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
29261
diff
changeset
|
11 ## |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
29261
diff
changeset
|
12 ## Octave is free software: you can redistribute it and/or modify it |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
29261
diff
changeset
|
13 ## under the terms of the GNU General Public License as published by |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
29261
diff
changeset
|
14 ## the Free Software Foundation, either version 3 of the License, or |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
29261
diff
changeset
|
15 ## (at your option) any later version. |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
29261
diff
changeset
|
16 ## |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
29261
diff
changeset
|
17 ## Octave is distributed in the hope that it will be useful, but |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
29261
diff
changeset
|
18 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
29261
diff
changeset
|
19 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
29261
diff
changeset
|
20 ## GNU General Public License for more details. |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
29261
diff
changeset
|
21 ## |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
29261
diff
changeset
|
22 ## You should have received a copy of the GNU General Public License |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
29261
diff
changeset
|
23 ## along with Octave; see the file COPYING. If not, see |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
29261
diff
changeset
|
24 ## <https://www.gnu.org/licenses/>. |
bbbe4dcc7200
use the same comment style for copyright headers in .m files and shell scripts
John W. Eaton <jwe@octave.org>
parents:
29261
diff
changeset
|
25 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
26 ######################################################################## |
7019 | 27 |
5590 | 28 # Some tests are commented out because they are known to be broken! |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
29 # Search for "# fails" |
5590 | 30 |
32064
5f5d8edbeb4f
* mk-sparse-tst.sh: Fix name of script in comments and messages.
John W. Eaton <jwe@octave.org>
parents:
32063
diff
changeset
|
31 # ./mk-sparse-tst.sh preset |
16030
1af8d21608b7
rename all test files in the test directory from test_X.m to X.tst
John W. Eaton <jwe@octave.org>
parents:
16029
diff
changeset
|
32 # creates sparse.tst with preset tests. |
1af8d21608b7
rename all test files in the test directory from test_X.m to X.tst
John W. Eaton <jwe@octave.org>
parents:
16029
diff
changeset
|
33 # Use "test sparse.tst" from octave to run the tests. |
5590 | 34 # |
32064
5f5d8edbeb4f
* mk-sparse-tst.sh: Fix name of script in comments and messages.
John W. Eaton <jwe@octave.org>
parents:
32063
diff
changeset
|
35 # ./mk-sparse-tst.sh random |
16030
1af8d21608b7
rename all test files in the test directory from test_X.m to X.tst
John W. Eaton <jwe@octave.org>
parents:
16029
diff
changeset
|
36 # Creates sprandom.tst with randomly generated matrices. |
1af8d21608b7
rename all test files in the test directory from test_X.m to X.tst
John W. Eaton <jwe@octave.org>
parents:
16029
diff
changeset
|
37 # Use "test sprandom.tst" from octave to run the tests. |
5590 | 38 |
32064
5f5d8edbeb4f
* mk-sparse-tst.sh: Fix name of script in comments and messages.
John W. Eaton <jwe@octave.org>
parents:
32063
diff
changeset
|
39 # mk-sparse-tst.sh generates tests for real and complex sparse matrices. |
5590 | 40 # Also, we want to run both fixed tests with known outputs (quick tests) |
41 # and longer tests with unknown outputs (thorough tests). This requires | |
10013
25417bd9a3c7
Use lognrnd instead of deprecated lognormal_rnd in build_sparse_tests.sh
Rik <rdrider0-list@yahoo.com>
parents:
8954
diff
changeset
|
42 # two sets of tests -- one which uses preset matrices and another which |
5590 | 43 # uses randomly generated matrices. |
44 # | |
45 # The tests are mostly identical for each case but the code is different, | |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
46 # so it is important that the tests be run on all cases. Because our test |
5590 | 47 # harness doesn't have support for looping or macros (it is only needed |
48 # for new data types), but sh does, we use sh to generate inline versions of | |
49 # the tests for each case. | |
50 # | |
51 # Our 'macros' use shared variables as parameters. This allows us to | |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
52 # for example define A complex and include all the unary ops tests, |
5590 | 53 # then set A=real(A) and include all the unary ops tests. Thus the |
54 # same tests work for real and complex. For binary tests it is even | |
55 # more complicated because we want full X sparse, sparse X full and | |
56 # sparse X sparse tested. | |
57 # | |
58 # We use the following macros: | |
59 # | |
60 # gen_section | |
61 # place a separator in the test file | |
62 # gen_function | |
63 # define the function definion | |
64 # helper gen_specific | |
65 # specific tests such as error handling and null input | |
66 # helper gen_eat_zeros | |
67 # make sure sparse-scalar ops which generate 0 work | |
68 # gen_specific_tests | |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
69 # specific and eat zeros tests |
5590 | 70 # helper gen_ordering_tests |
71 # ordered comparison operators for real valued tests | |
72 # helper gen_sparsesparse_ordering_tests | |
73 # ordered comparison operators for real valued sparse-sparse tests | |
74 # helper gen_elementop_tests | |
75 # element-wise matrix binary operators, including scalar-matrix ops. | |
76 # horizontal/vertical concatenation are here as well. | |
77 # helper gen_sparsesparse_elementop_tests | |
78 # element-wise matrix binary operators, for sparse-sparse ops. | |
79 # horizontal/vertical concatenation are here as well. | |
80 # helper gen_divop_tests | |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
81 # left and right matrix division operators of rectangular matrices. |
5590 | 82 # Needs QR solvers |
83 # helper gen_square_divop_tests | |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
84 # left and right matrix division operators of square matrices. |
5590 | 85 # helper gen_matrixop_tests |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
86 # rectangular matrix binary operators: * |
5590 | 87 # helper gen_matrixdiag_tests |
88 # Tests extract of diag and creation of diagonal matrices using | |
89 # diag and spdiags functions | |
90 # helper gen_matrixreshape_tests | |
91 # Test the reshape function on sparse matrices | |
92 # helper print_mapper_test | |
93 # sub-helper function of gen_mapper_tests to print individual tests | |
94 # helper gen_mapper_tests | |
95 # Tests all of the one argument mapper functions. There are a few | |
96 # specific tests that abs, real and imag return real values. | |
97 # helper gen_unaryop_tests | |
98 # functions and operators which transform a single matrix | |
99 # helper gen_save_tests | |
100 # Tests the load/save functionality for ascii/binary and hdf5 formats | |
101 # gen_scalar_tests | |
102 # element ops for real and complex scalar and sparse | |
103 # gen_rectangular_tests | |
104 # unary, element, and matrix tests for a and full/sparse b | |
105 # gen_square_tests | |
106 # operations which require square matrices: lu, inv, \ | |
107 # A square non-singular matrix is defined from the rectangular | |
108 # inputs A and B. | |
109 # gen_assembly_tests | |
110 # test for sparse constructors with 'sum' vs. 'unique' | |
111 # gen_select_tests | |
12757
824c60c8f7b9
preserve type when assigning values to sparse logical
John W. Eaton <jwe@octave.org>
parents:
12329
diff
changeset
|
112 # indexing and assignment tests |
5590 | 113 # gen_solver_tests |
114 # Tests the solve function with triangular/banded, etc matrices | |
115 | |
116 case $1 in | |
117 random) preset=false ;; | |
118 preset) preset=true ;; | |
119 '') preset=true ;; | |
32064
5f5d8edbeb4f
* mk-sparse-tst.sh: Fix name of script in comments and messages.
John W. Eaton <jwe@octave.org>
parents:
32063
diff
changeset
|
120 *) echo "mk-sparse-tst.sh random|preset" && exit 1 ;; |
5590 | 121 esac |
122 | |
123 # create initial file | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
124 cat <<EOF |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
125 ## !!! DO NOT EDIT !!! |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
126 ## THIS IS AN AUTOMATICALLY GENERATED FILE |
32064
5f5d8edbeb4f
* mk-sparse-tst.sh: Fix name of script in comments and messages.
John W. Eaton <jwe@octave.org>
parents:
32063
diff
changeset
|
127 ## modify mk-sparse-tst.sh to generate the tests you need. |
5590 | 128 EOF |
129 | |
130 | |
131 # define all functions | |
132 | |
133 | |
134 # ======================================================= | |
135 # Section separator | |
136 | |
137 gen_section() { | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
138 cat <<EOF |
5590 | 139 |
140 # ============================================================== | |
141 | |
142 EOF | |
143 } | |
144 | |
145 | |
146 # ======================================================= | |
147 # Specific preset tests | |
148 | |
149 # ======================================================= | |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
150 # If a sparse operation yields zeros, then those elements |
5590 | 151 # of the returned sparse matrix should be eaten. |
152 gen_eat_zeros() { | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
153 cat <<EOF |
5590 | 154 %% Make sure newly introduced zeros get eaten |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
155 %!assert (nnz (sparse ([bf,bf,1]).^realmax), 1) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
156 %!assert (nnz (sparse ([1,bf,bf]).^realmax), 1) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
157 %!assert (nnz (sparse ([bf,bf,bf]).^realmax), 0) |
5590 | 158 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
159 %!assert (nnz (sparse ([bf;bf;1]).^realmax), 1) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
160 %!assert (nnz (sparse ([1;bf;bf]).^realmax), 1) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
161 %!assert (nnz (sparse ([0.5;bf;bf]).^realmax), 0) |
5590 | 162 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
163 %!assert (nnz (sparse ([bf,bf,1])*realmin), 1) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
164 %!assert (nnz (sparse ([1,bf,bf])*realmin), 1) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
165 %!assert (nnz (sparse ([bf,bf,bf])*realmin), 0) |
5590 | 166 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
167 %!assert (nnz (sparse ([bf;bf;1])*realmin), 1) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
168 %!assert (nnz (sparse ([1;bf;bf])*realmin), 1) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
169 %!assert (nnz (sparse ([bf;bf;bf])*realmin), 0) |
5590 | 170 |
171 EOF | |
172 } | |
173 | |
174 gen_specific() { | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
175 cat <<EOF |
5590 | 176 |
32058
e242124f1240
Overhaul input validation of sparse() function.
Rik <rik@octave.org>
parents:
32002
diff
changeset
|
177 %% error handling in constructor |
e242124f1240
Overhaul input validation of sparse() function.
Rik <rik@octave.org>
parents:
32002
diff
changeset
|
178 %!error <Invalid call> sparse () |
e242124f1240
Overhaul input validation of sparse() function.
Rik <rik@octave.org>
parents:
32002
diff
changeset
|
179 %!error <Invalid call> sparse (1,2,3,4,5,6,7) |
e242124f1240
Overhaul input validation of sparse() function.
Rik <rik@octave.org>
parents:
32002
diff
changeset
|
180 %!warning <input array cast to double> |
e242124f1240
Overhaul input validation of sparse() function.
Rik <rik@octave.org>
parents:
32002
diff
changeset
|
181 %! warning ("on", "Octave:sparse:double-conversion", "local"); |
e242124f1240
Overhaul input validation of sparse() function.
Rik <rik@octave.org>
parents:
32002
diff
changeset
|
182 %! s = sparse (single ([1 2])); |
e242124f1240
Overhaul input validation of sparse() function.
Rik <rik@octave.org>
parents:
32002
diff
changeset
|
183 %!error <wrong type argument 'uint8 matrix'> |
e242124f1240
Overhaul input validation of sparse() function.
Rik <rik@octave.org>
parents:
32002
diff
changeset
|
184 %! s = sparse (uint8 ([1 2])); |
32059
bade9602c5a1
Validate M and N dimension inputs to sparse().
Rik <rik@octave.org>
parents:
32058
diff
changeset
|
185 %!error <M must be a non-negative integer> sparse ({1}, 2) |
bade9602c5a1
Validate M and N dimension inputs to sparse().
Rik <rik@octave.org>
parents:
32058
diff
changeset
|
186 %!error <N must be a non-negative integer> sparse (1, {2}) |
bade9602c5a1
Validate M and N dimension inputs to sparse().
Rik <rik@octave.org>
parents:
32058
diff
changeset
|
187 %!error <dimensions M and N must be non-negative> sparse (-1, 2) |
bade9602c5a1
Validate M and N dimension inputs to sparse().
Rik <rik@octave.org>
parents:
32058
diff
changeset
|
188 %!error <dimensions M and N must be non-negative> sparse (1, -2) |
32058
e242124f1240
Overhaul input validation of sparse() function.
Rik <rik@octave.org>
parents:
32002
diff
changeset
|
189 %!error <dimension mismatch> sparse (1,[2,3],[1,2,3]) |
e242124f1240
Overhaul input validation of sparse() function.
Rik <rik@octave.org>
parents:
32002
diff
changeset
|
190 %!error <invalid option: foobar> sparse ([1,1],[1,1],[1,2],"foobar") |
e242124f1240
Overhaul input validation of sparse() function.
Rik <rik@octave.org>
parents:
32002
diff
changeset
|
191 %% negative subscripts are disallowed |
e242124f1240
Overhaul input validation of sparse() function.
Rik <rik@octave.org>
parents:
32002
diff
changeset
|
192 %!error <subscripts must be> sparse ([1,3],[1,-4],[3,5],2,2) |
e242124f1240
Overhaul input validation of sparse() function.
Rik <rik@octave.org>
parents:
32002
diff
changeset
|
193 %!error <subscripts must be> sparse ([1,3],[1,-4],[3,5i],2,2) |
32059
bade9602c5a1
Validate M and N dimension inputs to sparse().
Rik <rik@octave.org>
parents:
32058
diff
changeset
|
194 %!error <M must be a non-negative integer> sparse ([1,1],[1,1],[1,2], {1}, 2) |
bade9602c5a1
Validate M and N dimension inputs to sparse().
Rik <rik@octave.org>
parents:
32058
diff
changeset
|
195 %!error <N must be a non-negative integer> sparse ([1,1],[1,1],[1,2], 1, {2}) |
bade9602c5a1
Validate M and N dimension inputs to sparse().
Rik <rik@octave.org>
parents:
32058
diff
changeset
|
196 %!error <dimensions M and N must be non-negative> sparse ([1,1],[1,1],[1,2], -1, 2) |
bade9602c5a1
Validate M and N dimension inputs to sparse().
Rik <rik@octave.org>
parents:
32058
diff
changeset
|
197 %!error <dimensions M and N must be non-negative> sparse ([1,1],[1,1],[1,2], 1, -2) |
32058
e242124f1240
Overhaul input validation of sparse() function.
Rik <rik@octave.org>
parents:
32002
diff
changeset
|
198 %!warning <input array cast to double> |
e242124f1240
Overhaul input validation of sparse() function.
Rik <rik@octave.org>
parents:
32002
diff
changeset
|
199 %! warning ("on", "Octave:sparse:double-conversion", "local"); |
e242124f1240
Overhaul input validation of sparse() function.
Rik <rik@octave.org>
parents:
32002
diff
changeset
|
200 %! s = sparse ([1,1],[1,1], single ([1,2]), 2, 2); |
e242124f1240
Overhaul input validation of sparse() function.
Rik <rik@octave.org>
parents:
32002
diff
changeset
|
201 %!error <wrong type argument 'uint8 matrix'> |
e242124f1240
Overhaul input validation of sparse() function.
Rik <rik@octave.org>
parents:
32002
diff
changeset
|
202 %! s = sparse ([1,1],[1,1], uint8 ([1,2]), 2, 2); |
e242124f1240
Overhaul input validation of sparse() function.
Rik <rik@octave.org>
parents:
32002
diff
changeset
|
203 |
5590 | 204 %!test # segfault test from edd@debian.org |
205 %! n = 510; | |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
206 %! sparse (kron ((1:n)', ones (n,1)), kron (ones (n,1), (1:n)'), ones (n)); |
5590 | 207 |
208 %% segfault tests from Fabian@isas-berlin.de | |
209 %% Note that the last four do not fail, but rather give a warning | |
210 %% of a singular matrix, which is consistent with the full matrix | |
21308
c53bfd6d8e08
maint: Use American spelling for "behavior".
Rik <rik@octave.org>
parents:
20835
diff
changeset
|
211 %% behavior. They are therefore disabled. |
7243 | 212 %!testif HAVE_UMFPACK |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
213 %! assert (inv (sparse ([1,1;1,1+i])), sparse ([1-1i,1i;1i,-1i]), 10*eps); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
214 %#!error inv ( sparse ([1,1;1,1] ) ); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
215 %#!error inv ( sparse ([0,0;0,1] ) ); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
216 %#!error inv ( sparse ([0,0;0,1+i]) ); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
217 %#!error inv ( sparse ([0,0;0,0] ) ); |
5590 | 218 |
219 EOF | |
220 } | |
221 | |
222 | |
223 gen_specific_tests() { | |
224 gen_section | |
225 gen_specific | |
226 gen_section | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
227 echo '%!shared bf' |
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
228 echo '%!test bf=realmin;' |
5590 | 229 gen_eat_zeros |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
230 echo '%!test bf=realmin+realmin*1i;' |
5590 | 231 gen_eat_zeros |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
232 cat <<EOF |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
233 %!assert (nnz (sparse ([-1,realmin,realmin]).^1.5), 1) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
234 %!assert (nnz (sparse ([-1,realmin,realmin,1]).^1.5), 2) |
5590 | 235 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
236 ## Make sure scalar v==0 doesn't confuse matters |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
237 %!assert (nnz (sparse (1,1,0)), 0) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
238 %!assert (nnz (sparse (eye (3))*0), 0) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
239 %!assert (nnz (sparse (eye (3))-sparse (eye (3))), 0) |
28907
11f1207111c5
maint: Don't use semicolon at end of single-line BIST tests.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
240 %!assert (full (sparse (eye (3))/0), full (eye (3)/0)) |
5590 | 241 |
242 EOF | |
243 } | |
244 | |
245 | |
246 # ======================================================= | |
247 # Main function definition | |
248 | |
249 gen_function() { | |
250 if $preset; then | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
251 cat <<EOF |
5590 | 252 ## |
253 ## test_sparse | |
254 ## | |
255 ## run preset sparse tests. All should pass. | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
256 function [passes, tests] = test_sparse |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
257 disp ("writing test output to sptest.log"); |
16030
1af8d21608b7
rename all test files in the test directory from test_X.m to X.tst
John W. Eaton <jwe@octave.org>
parents:
16029
diff
changeset
|
258 test ("sparse.tst", "normal", "sptest.log"); |
5590 | 259 endfunction |
260 | |
261 EOF | |
262 else | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
263 cat <<EOF |
5590 | 264 ## |
265 ## test_sprandom | |
266 ## | |
267 ## total_passes=0; total_tests=0; | |
268 ## for i=1:10 | |
269 ## [passes,tests] = sprandomtest; | |
270 ## total_passes += passes; | |
271 ## total_tests += tests; | |
272 ## end | |
273 ## The test log is appended to sprandomtest.log | |
274 function [passes,total] = test_sprandom | |
32064
5f5d8edbeb4f
* mk-sparse-tst.sh: Fix name of script in comments and messages.
John W. Eaton <jwe@octave.org>
parents:
32063
diff
changeset
|
275 warning ("untested --- fix the source in mk-sparse-tst.sh"); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
276 disp ("appending test output to sprandomtest.log"); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
277 fid = fopen ("sprandomtest.log", "at"); |
16030
1af8d21608b7
rename all test files in the test directory from test_X.m to X.tst
John W. Eaton <jwe@octave.org>
parents:
16029
diff
changeset
|
278 test ("sprandom.tst", "normal", fid); |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
279 ##[passes, total] = test ("sprandomtest", "normal", fid); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
280 fclose (fid); |
5590 | 281 endfunction |
282 | |
283 EOF | |
284 fi | |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
285 |
5590 | 286 } |
287 | |
288 | |
289 # ======================================================= | |
290 # matrix ops | |
291 | |
292 # test ordered comparisons: uses as,af,bs,bf | |
293 gen_ordering_tests() { | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
294 cat <<EOF |
5590 | 295 %% real values can be ordered (uses as,af) |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
296 %!assert (as<=bf, sparse (af<=bf)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
297 %!assert (bf<=as, sparse (bf<=af)) |
5590 | 298 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
299 %!assert (as>=bf, sparse (af>=bf)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
300 %!assert (bf>=as, sparse (bf>=af)) |
5590 | 301 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
302 %!assert (as<bf, sparse (af<bf)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
303 %!assert (bf<as, sparse (bf<af)) |
5590 | 304 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
305 %!assert (as>bf, sparse (af>bf)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
306 %!assert (bf>as, sparse (bf>af)) |
5590 | 307 |
308 EOF | |
309 } | |
310 | |
311 gen_sparsesparse_ordering_tests() { | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
312 cat <<EOF |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
313 %!assert (as<=bs, sparse (af<=bf)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
314 %!assert (as>=bs, sparse (af>=bf)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
315 %!assert (as<bs, sparse (af<bf)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
316 %!assert (as>bs, sparse (af>bf)) |
5590 | 317 EOF |
318 } | |
319 | |
320 # test element-wise binary operations: uses as,af,bs,bf,scalar | |
321 gen_elementop_tests() { | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
322 cat <<EOF |
5590 | 323 %% Elementwise binary tests (uses as,af,bs,bf,scalar) |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
324 %!assert (as==bs, sparse (af==bf)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
325 %!assert (bf==as, sparse (bf==af)) |
5590 | 326 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
327 %!assert (as!=bf, sparse (af!=bf)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
328 %!assert (bf!=as, sparse (bf!=af)) |
5590 | 329 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
330 %!assert (as+bf, af+bf) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
331 %!assert (bf+as, bf+af) |
5590 | 332 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
333 %!assert (as-bf, af-bf) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
334 %!assert (bf-as, bf-af) |
5590 | 335 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
336 %!assert (as.*bf, sparse (af.*bf)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
337 %!assert (bf.*as, sparse (bf.*af)) |
5590 | 338 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
339 %!assert (as./bf, sparse (af./bf), 100*eps) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
340 %!assert (bf.\as, sparse (bf.\af), 100*eps) |
5590 | 341 |
342 %!test | |
343 %! sv = as.^bf; | |
344 %! fv = af.^bf; | |
17307
4448cc742880
Use '!' not operator rather than '~' in core m-files.
Rik <rik@octave.org>
parents:
16215
diff
changeset
|
345 %! idx = find (af!=0); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
346 %! assert (sv(:)(idx), sparse (fv(:)(idx)), 100*eps); |
5590 | 347 |
348 EOF | |
349 } | |
350 | |
351 gen_sparsesparse_elementop_tests() { | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
352 cat <<EOF |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
353 %!assert (as==bs, sparse (af==bf)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
354 %!assert (as!=bs, sparse (af!=bf)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
355 %!assert (as+bs, sparse (af+bf)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
356 %!assert (as-bs, sparse (af-bf)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
357 %!assert (as.*bs, sparse (af.*bf)) |
25218
164399071f4d
* mk-sparse-tst.sh: Don't use xtest in generated test.
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
358 %!assert (as./bs, sparse (af./bf), 100*eps) |
5590 | 359 %!test |
360 %! sv = as.^bs; | |
361 %! fv = af.^bf; | |
17307
4448cc742880
Use '!' not operator rather than '~' in core m-files.
Rik <rik@octave.org>
parents:
16215
diff
changeset
|
362 %! idx = find (af!=0); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
363 %! assert(sv(:)(idx), sparse (fv(:)(idx)), 100*eps); |
5590 | 364 |
365 EOF | |
366 } | |
367 | |
368 # test matrix-matrix left and right division: uses as,af,bs,bf | |
369 gen_divop_tests() { | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
370 cat <<EOF |
5590 | 371 %% Matrix-matrix operators (uses af,as,bs,bf) |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
372 %!assert (as/bf, af/bf, 100*eps) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
373 %!assert (af/bs, af/bf, 100*eps) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
374 %!assert (as/bs, sparse (af/bf), 100*eps) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
375 %!assert (bs\af', bf\af', 100*eps) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
376 %!assert (bf\as', bf\af', 100*eps) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
377 %!assert (bs\as', sparse (bf\af'), 100*eps) |
5590 | 378 |
379 EOF | |
380 } | |
381 | |
382 # test matrix-matrix left and right division: uses as,af,bs,bf | |
383 gen_square_divop_tests() { | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
384 cat <<EOF |
5590 | 385 %% Matrix-matrix operators (uses af,as,bs,bf) |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
386 %!assert (as/bf, af/bf, 100*eps) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
387 %!assert (af/bs, af/bf, 100*eps) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
388 %!assert (as/bs, sparse (af/bf), 100*eps) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
389 %!assert (bs\af', bf\af', 100*eps) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
390 %!assert (bf\as', bf\af', 100*eps) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
391 %!assert (bs\as', sparse (bf\af'), 100*eps) |
5590 | 392 |
393 EOF | |
394 } | |
395 | |
396 # test matrix-matrix operations: uses as,af,bs,bf | |
397 gen_matrixop_tests() { | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
398 cat <<EOF |
5590 | 399 %% Matrix-matrix operators (uses af,as,bs,bf) |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
400 %!assert (as*bf', af*bf') |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
401 %!assert (af*bs', af*bf') |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
402 %!assert (as*bs', sparse (af*bf')) |
5590 | 403 |
404 EOF | |
405 } | |
406 | |
407 # test diagonal operations | |
408 gen_matrixdiag_tests() { | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
409 cat <<EOF |
5590 | 410 %% Matrix diagonal tests (uses af,as,bf,bs) |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
411 %!assert (diag (as), sparse (diag (af))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
412 %!assert (diag (bs), sparse (diag (bf))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
413 %!assert (diag (as,1), sparse (diag (af,1))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
414 %!assert (diag (bs,1), sparse (diag (bf,1))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
415 %!assert (diag (as,-1), sparse (diag (af,-1))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
416 %!assert (diag (bs,-1), sparse (diag (bf,-1))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
417 %!assert (diag (as(:)), sparse (diag (af(:)))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
418 %!assert (diag (as(:),1), sparse (diag (af(:),1))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
419 %!assert (diag (as(:),-1), sparse (diag (af(:),-1))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
420 %!assert (diag (as(:)'), sparse (diag (af(:)'))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
421 %!assert (diag (as(:)',1), sparse (diag (af(:)',1))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
422 %!assert (diag (as(:)',-1), sparse (diag (af(:)',-1))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
423 %!assert (spdiags (as,[0,1]), [diag(af,0), diag(af,1)]) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
424 %!test |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
425 %! [tb,tc] = spdiags (as); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
426 %! assert (spdiags (tb,tc,sparse (zeros (size (as)))), as); |
30236
628f26e122d9
maint: use rows() or columns() instead of size(__, 1 | 2) for clarity.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
427 %! assert (spdiags (tb,tc,rows (as),columns (as)), as); |
5590 | 428 |
429 EOF | |
430 } | |
431 | |
432 # test matrix reshape operations | |
433 gen_matrixreshape_tests() { | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
434 cat <<EOF |
5590 | 435 %% Matrix diagonal tests (uses af,as,bf,bs) |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
436 %!assert (reshape (as,1,prod(size(as))), sparse (reshape (af,1,prod(size(af))))) |
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
437 %!assert (reshape (as,prod(size(as)),1), sparse (reshape (af,prod(size(af)),1))) |
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
438 %!assert (reshape (as,fliplr(size(as))), sparse (reshape (af,fliplr(size(af))))) |
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
439 %!assert (reshape (bs,1,prod(size(as))), sparse (reshape (bf,1,prod(size(af))))) |
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
440 %!assert (reshape (bs,prod(size(as)),1), sparse (reshape (bf,prod(size(af)),1))) |
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
441 %!assert (reshape (bs,fliplr(size(as))), sparse (reshape (bf,fliplr(size(af))))) |
5590 | 442 |
443 EOF | |
444 } | |
445 | |
446 # test mapper matrix operations: uses as,af | |
447 print_mapper_test() { | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
448 echo "%!assert ($1(as), sparse ($1(af)))" |
5590 | 449 } |
450 | |
451 print_real_mapper_test() { | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
452 cat <<EOF |
5590 | 453 %!test |
5781 | 454 %! wn2s = warning ("query", "Octave:num-to-str"); |
455 %! warning ("off", "Octave:num-to-str"); | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
456 %! if (isreal (af)) |
5953 | 457 %! if ($2) |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
458 %! assert ($1(as), sparse ($1(af))); |
5953 | 459 %! else |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
460 %! assert ($1(as), $1(af)); |
5953 | 461 %! endif |
5590 | 462 %! endif |
5781 | 463 %! warning (wn2s.state, "Octave:num-to-str"); |
5590 | 464 |
465 EOF | |
466 } | |
467 | |
468 gen_mapper_tests() { | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
469 echo "%% Unary matrix tests (uses af,as)" |
5590 | 470 print_mapper_test abs |
471 print_mapper_test acos | |
472 print_mapper_test acosh | |
473 print_mapper_test angle | |
474 print_mapper_test arg | |
475 print_mapper_test asin | |
476 print_mapper_test asinh | |
477 print_mapper_test atan | |
478 print_mapper_test atanh | |
479 print_mapper_test ceil | |
480 print_mapper_test conj | |
481 print_mapper_test cos | |
482 print_mapper_test cosh | |
483 print_mapper_test exp | |
19121
3cb64f94294f
build-sparse-tests.sh: Use isfinite rather than deprecated finite.
Rik <rik@octave.org>
parents:
18196
diff
changeset
|
484 print_mapper_test isfinite |
5590 | 485 print_mapper_test fix |
486 print_mapper_test floor | |
487 print_mapper_test imag | |
488 print_mapper_test isinf | |
489 print_mapper_test isna | |
490 print_mapper_test isnan | |
491 print_mapper_test log | |
492 #print_mapper_test log10 ## fails with different NaN, not a problem | |
493 print_mapper_test real | |
494 print_mapper_test round | |
495 print_mapper_test sign | |
496 print_mapper_test sin | |
497 print_mapper_test sinh | |
498 print_mapper_test sqrt | |
499 print_mapper_test tan | |
500 print_mapper_test tanh | |
501 | |
502 # Specific tests for certain mapper functions | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
503 cat <<EOF |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
504 %!assert (issparse (abs (as)) && isreal (abs (as))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
505 %!assert (issparse (real (as)) && isreal (real (as))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
506 %!assert (issparse (imag (as)) && isreal (imag (as))) |
5590 | 507 |
508 EOF | |
509 } | |
510 | |
511 gen_real_mapper_tests() { | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
512 echo "%% Unary matrix tests (uses af,as)" |
5953 | 513 print_real_mapper_test erf 1 |
514 print_real_mapper_test erfc 1 | |
515 #print_real_mapper_test gamma 1 | |
516 print_real_mapper_test isalnum 0 | |
517 print_real_mapper_test isalpha 0 | |
518 print_real_mapper_test isascii 0 | |
519 print_real_mapper_test iscntrl 0 | |
520 print_real_mapper_test isdigit 0 | |
521 print_real_mapper_test isgraph 0 | |
522 print_real_mapper_test islower 0 | |
523 print_real_mapper_test isprint 0 | |
524 print_real_mapper_test ispunct 0 | |
525 print_real_mapper_test isspace 0 | |
526 print_real_mapper_test isupper 0 | |
527 print_real_mapper_test isxdigit 0 | |
19275
653ed3a6ba83
Use gammaln in preference to lgamma in core Octave code.
Rik <rik@octave.org>
parents:
19121
diff
changeset
|
528 #print_real_mapper_test gammaln 1 |
5590 | 529 |
530 # Specific tests for certain mapper functions | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
531 cat <<EOF |
5590 | 532 |
533 %!test | |
5781 | 534 %! wn2s = warning ("query", "Octave:num-to-str"); |
535 %! warning ("off", "Octave:num-to-str"); | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
536 %! if (isreal (af)) |
32002
939e5d952675
Use upper/lower in preference to toupper/tolower to match Matlab.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
537 %! assert (lower (as), as); |
939e5d952675
Use upper/lower in preference to toupper/tolower to match Matlab.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
538 %! assert (upper (as), as); |
5590 | 539 %! endif |
5781 | 540 %! warning (wn2s.state, "Octave:num-to-str"); |
5590 | 541 |
542 EOF | |
543 } | |
544 | |
545 # test matrix operations: uses as,af | |
546 gen_unaryop_tests() { | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
547 cat <<EOF |
5590 | 548 %% Unary matrix tests (uses af,as) |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
549 %!assert (issparse (as)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
550 %!assert (!issparse (af)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
551 %!assert (! (issparse (af) && iscomplex (af))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
552 %!assert (! (issparse (af) && isreal (af))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
553 %!assert (sum (as), sparse (sum (af))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
554 %!assert (sum (as,1), sparse (sum (af,1))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
555 %!assert (sum (as,2), sparse (sum (af,2))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
556 %!assert (cumsum (as), sparse (cumsum (af))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
557 %!assert (cumsum (as,1), sparse (cumsum (af,1))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
558 %!assert (cumsum (as,2), sparse (cumsum (af,2))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
559 %!assert (sumsq (as), sparse (sumsq (af))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
560 %!assert (sumsq (as,1), sparse (sumsq (af,1))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
561 %!assert (sumsq (as,2), sparse (sumsq (af,2))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
562 %!assert (prod (as), sparse (prod (af))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
563 %!assert (prod (as,1), sparse (prod (af,1))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
564 %!assert (prod (as,2), sparse (prod (af,2))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
565 %!assert (cumprod (as), sparse (cumprod (af))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
566 %!assert (cumprod (as,1), sparse (cumprod (af,1))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
567 %!assert (cumprod (as,2), sparse (cumprod (af,2))) |
5590 | 568 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
569 %!assert (min (as), sparse (min (af))) |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
570 %!assert (full (min (as(:))), min (af(:))) |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
571 %!assert (min (as,[],1), sparse (min (af,[],1))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
572 %!assert (min (as,[],2), sparse (min (af,[],2))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
573 %!assert (min (as,[],1), sparse (min (af,[],1))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
574 %!assert (min (as,0), sparse (min (af,0))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
575 %!assert (min (as,bs), sparse (min (af,bf))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
576 %!assert (max (as), sparse (max (af))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
577 %!assert (full (max (as(:))), max (af(:))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
578 %!assert (max (as,[],1), sparse (max (af,[],1))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
579 %!assert (max (as,[],2), sparse (max (af,[],2))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
580 %!assert (max (as,[],1), sparse (max (af,[],1))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
581 %!assert (max (as,0), sparse (max (af,0))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
582 %!assert (max (as,bs), sparse (max (af,bf))) |
5590 | 583 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
584 %!assert (as==as) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
585 %!assert (as==af) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
586 %!assert (af==as) |
5590 | 587 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
588 %! [ii,jj,vv,nr,nc] = find (as); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
589 %! assert (af, full (sparse (ii,jj,vv,nr,nc))); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
590 %!assert (nnz (as), sum (af(:)!=0)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
591 %!assert (nnz (as), nnz (af)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
592 %!assert (issparse (as.')) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
593 %!assert (issparse (as')) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
594 %!assert (issparse (-as)) |
17307
4448cc742880
Use '!' not operator rather than '~' in core m-files.
Rik <rik@octave.org>
parents:
16215
diff
changeset
|
595 %!assert (!as, sparse (!af)) |
21317
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
596 %!assert (as.', sparse (af.')) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
597 %!assert (as', sparse (af')) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
598 %!assert (-as, sparse (-af)) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
599 %!assert (!as, sparse (!af)) |
28907
11f1207111c5
maint: Don't use semicolon at end of single-line BIST tests.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
600 %!error [i,j] = size (af);as(i-1,j+1) |
11f1207111c5
maint: Don't use semicolon at end of single-line BIST tests.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
601 %!error [i,j] = size (af);as(i+1,j-1) |
5590 | 602 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
603 %! [Is,Js,Vs] = find (as); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
604 %! [If,Jf,Vf] = find (af); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
605 %! assert (Is, If); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
606 %! assert (Js, Jf); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
607 %! assert (Vs, Vf); |
21581
6fab85c1538f
maint: Follow Octave conventions for use of semicolon in BIST tests.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
608 %!error as(0,1) |
6fab85c1538f
maint: Follow Octave conventions for use of semicolon in BIST tests.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
609 %!error as(1,0) |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
610 %!assert (find (as), find (af)) |
5590 | 611 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
612 %! [i,j,v] = find (as); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
613 %! [m,n] = size (as); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
614 %! x = sparse (i,j,v,m,n); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
615 %! assert (x, as); |
5590 | 616 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
617 %! [i,j,v,m,n] = find (as); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
618 %! x = sparse (i,j,v,m,n); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
619 %! assert (x, as); |
21317
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
620 %!assert (issparse (horzcat (as,as))) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
621 %!assert (issparse (vertcat (as,as))) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
622 %!assert (issparse (cat (1,as,as))) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
623 %!assert (issparse (cat (2,as,as))) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
624 %!assert (issparse ([as,as])) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
625 %!assert (issparse ([as;as])) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
626 %!assert (horzcat (as,as), sparse ([af,af])) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
627 %!assert (vertcat (as,as), sparse ([af;af])) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
628 %!assert (horzcat (as,as,as), sparse ([af,af,af])) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
629 %!assert (vertcat (as,as,as), sparse ([af;af;af])) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
630 %!assert ([as,as], sparse ([af,af])) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
631 %!assert ([as;as], sparse ([af;af])) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
632 %!assert ([as,as,as], sparse ([af,af,af])) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
633 %!assert ([as;as;as], sparse ([af;af;af])) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
634 %!assert (cat (2,as,as), sparse ([af,af])) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
635 %!assert (cat (1,as,as), sparse ([af;af])) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
636 %!assert (cat (2,as,as,as), sparse ([af,af,af])) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
637 %!assert (cat (1,as,as,as), sparse ([af;af;af])) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
638 %!assert (issparse ([as,af])) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
639 %!assert (issparse ([af,as])) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
640 %!assert ([as,af], sparse ([af,af])) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
641 %!assert ([as;af], sparse ([af;af])) |
5590 | 642 |
643 EOF | |
644 } | |
645 | |
646 # operations which require square matrices. | |
647 gen_square_tests() { | |
648 # The \ and / operator tests on square matrices | |
649 gen_square_divop_tests | |
650 | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
651 cat <<EOF |
7243 | 652 %!testif HAVE_UMFPACK |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
653 %! assert(det(bs+speye(size(bs))), det(bf+eye(size(bf))), 100*eps*abs(det(bf+eye(size(bf))))); |
5590 | 654 |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
655 %!testif HAVE_UMFPACK |
32063
3b9305e62bb7
avoid LU warnings in sparse tests (bug #64117)
John W. Eaton <jwe@octave.org>
parents:
32059
diff
changeset
|
656 %! ## Yes, we want to test lu with fewer than 4 output arguments |
3b9305e62bb7
avoid LU warnings in sparse tests (bug #64117)
John W. Eaton <jwe@octave.org>
parents:
32059
diff
changeset
|
657 %! ## and sparse input while also avoiding the warning. So use |
3b9305e62bb7
avoid LU warnings in sparse tests (bug #64117)
John W. Eaton <jwe@octave.org>
parents:
32059
diff
changeset
|
658 %! ## warning ("off", ...) insetead of additional outputs. |
3b9305e62bb7
avoid LU warnings in sparse tests (bug #64117)
John W. Eaton <jwe@octave.org>
parents:
32059
diff
changeset
|
659 %! warning ("off", "Octave:lu:sparse_input", "local"); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
660 %! [l,u] = lu (sparse ([1,1;1,1])); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
661 %! assert (l*u, [1,1;1,1], 10*eps); |
5590 | 662 |
7243 | 663 %!testif HAVE_UMFPACK |
32063
3b9305e62bb7
avoid LU warnings in sparse tests (bug #64117)
John W. Eaton <jwe@octave.org>
parents:
32059
diff
changeset
|
664 %! ## Yes, we want to test lu with fewer than 4 output arguments |
3b9305e62bb7
avoid LU warnings in sparse tests (bug #64117)
John W. Eaton <jwe@octave.org>
parents:
32059
diff
changeset
|
665 %! ## and sparse input while also avoiding the warning. So use |
3b9305e62bb7
avoid LU warnings in sparse tests (bug #64117)
John W. Eaton <jwe@octave.org>
parents:
32059
diff
changeset
|
666 %! ## warning ("off", ...) insetead of additional outputs. |
3b9305e62bb7
avoid LU warnings in sparse tests (bug #64117)
John W. Eaton <jwe@octave.org>
parents:
32059
diff
changeset
|
667 %! warning ("off", "Octave:lu:sparse_input", "local"); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
668 %! [l,u] = lu (sparse ([1,1;1,1+i])); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
669 %! assert (l, sparse ([1,2,2],[1,1,2],1), 10*eps); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
670 %! assert (u, sparse ([1,1,2],[1,2,2],[1,1,1i]), 10*eps); |
5590 | 671 |
14190
68fd9f95e1f9
Don't process comments in %!testif specifications.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
672 %!testif HAVE_UMFPACK # permuted LU |
32063
3b9305e62bb7
avoid LU warnings in sparse tests (bug #64117)
John W. Eaton <jwe@octave.org>
parents:
32059
diff
changeset
|
673 %! ## Yes, we want to test lu with fewer than 4 output arguments |
3b9305e62bb7
avoid LU warnings in sparse tests (bug #64117)
John W. Eaton <jwe@octave.org>
parents:
32059
diff
changeset
|
674 %! ## and sparse input while also avoiding the warning. So use |
3b9305e62bb7
avoid LU warnings in sparse tests (bug #64117)
John W. Eaton <jwe@octave.org>
parents:
32059
diff
changeset
|
675 %! ## warning ("off", ...) insetead of additional outputs. |
3b9305e62bb7
avoid LU warnings in sparse tests (bug #64117)
John W. Eaton <jwe@octave.org>
parents:
32059
diff
changeset
|
676 %! warning ("off", "Octave:lu:sparse_input", "local"); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
677 %! [L,U] = lu (bs); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
678 %! assert (L*U, bs, 1e-10); |
5590 | 679 |
14190
68fd9f95e1f9
Don't process comments in %!testif specifications.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
680 %!testif HAVE_UMFPACK # simple LU + row permutations |
32063
3b9305e62bb7
avoid LU warnings in sparse tests (bug #64117)
John W. Eaton <jwe@octave.org>
parents:
32059
diff
changeset
|
681 %! ## Yes, we want to test lu with fewer than 4 output arguments |
3b9305e62bb7
avoid LU warnings in sparse tests (bug #64117)
John W. Eaton <jwe@octave.org>
parents:
32059
diff
changeset
|
682 %! ## and sparse input while also avoiding the warning. So use |
3b9305e62bb7
avoid LU warnings in sparse tests (bug #64117)
John W. Eaton <jwe@octave.org>
parents:
32059
diff
changeset
|
683 %! ## warning ("off", ...) insetead of additional outputs. |
3b9305e62bb7
avoid LU warnings in sparse tests (bug #64117)
John W. Eaton <jwe@octave.org>
parents:
32059
diff
changeset
|
684 %! warning ("off", "Octave:lu:sparse_input", "local"); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
685 %! [L,U,P] = lu (bs); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
686 %! assert (P'*L*U, bs, 1e-10); |
17336
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
17307
diff
changeset
|
687 %! ## triangularity |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
688 %! [i,j,v] = find (L); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
689 %! assert (i-j>=0); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
690 %! [i,j,v] = find (U); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
691 %! assert (j-i>=0); |
5590 | 692 |
14190
68fd9f95e1f9
Don't process comments in %!testif specifications.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
693 %!testif HAVE_UMFPACK # simple LU + row/col permutations |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
694 %! [L,U,P,Q] = lu (bs); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
695 %! assert (P'*L*U*Q', bs, 1e-10); |
17336
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
17307
diff
changeset
|
696 %! ## triangularity |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
697 %! [i,j,v] = find (L); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
698 %! assert (i-j>=0); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
699 %! [i,j,v] = find (U); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
700 %! assert (j-i>=0); |
5590 | 701 |
14190
68fd9f95e1f9
Don't process comments in %!testif specifications.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
702 %!testif HAVE_UMFPACK # LU with vector permutations |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
703 %! [L,U,P,Q] = lu (bs,'vector'); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
704 %! assert (L(P,:)*U(:,Q), bs, 1e-10); |
17336
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
17307
diff
changeset
|
705 %! ## triangularity |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
706 %! [i,j,v] = find (L); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
707 %! assert (i-j>=0); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
708 %! [i,j,v] = find (U); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
709 %! assert (j-i>=0); |
5590 | 710 |
14190
68fd9f95e1f9
Don't process comments in %!testif specifications.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
711 %!testif HAVE_UMFPACK # LU with scaling |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
712 %! [L,U,P,Q,R] = lu (bs); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
713 %! assert (R*P'*L*U*Q', bs, 1e-10); |
17336
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
17307
diff
changeset
|
714 %! ## triangularity |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
715 %! [i,j,v] = find (L); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
716 %! assert (i-j>=0); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
717 %! [i,j,v] = find (U); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
718 %! assert (j-i>=0); |
5590 | 719 |
14190
68fd9f95e1f9
Don't process comments in %!testif specifications.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
720 %!testif HAVE_UMFPACK # inverse |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
721 %! assert (inv (bs)*bs, sparse (eye (rows (bs))), 1e-10); |
5590 | 722 |
21317
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
723 %!assert (bf\as', bf\af', 100*eps) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
724 %!assert (bs\af', bf\af', 100*eps) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
725 %!assert (bs\as', sparse (bf\af'), 100*eps) |
5590 | 726 |
727 EOF | |
728 } | |
729 | |
730 # Cholesky tests | |
731 gen_cholesky_tests() { | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
732 cat <<EOF |
7243 | 733 %!testif HAVE_CHOLMOD |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
734 %! assert (chol (bs)'*chol (bs), bs, 1e-10); |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
735 %!testif HAVE_CHOLMOD |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
736 %! assert (chol (bs,'lower')*chol (bs,'lower')', bs, 1e-10); |
7243 | 737 %!testif HAVE_CHOLMOD |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
738 %! assert (chol (bs,'lower'), chol (bs)', 1e-10); |
5590 | 739 |
14190
68fd9f95e1f9
Don't process comments in %!testif specifications.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
740 %!testif HAVE_CHOLMOD # Return Partial Cholesky factorization |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
741 %! [RS,PS] = chol (bs); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
742 %! assert (RS'*RS, bs, 1e-10); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
743 %! assert (PS, 0); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
744 %! [LS,PS] = chol (bs,'lower'); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
745 %! assert (LS*LS', bs, 1e-10); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
746 %! assert (PS, 0); |
5590 | 747 |
14190
68fd9f95e1f9
Don't process comments in %!testif specifications.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
748 %!testif HAVE_CHOLMOD # Permuted Cholesky factorization |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
749 %! [RS,PS,QS] = chol (bs); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
750 %! assert (RS'*RS, QS*bs*QS', 1e-10); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
751 %! assert (PS, 0); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
752 %! [LS,PS,QS] = chol (bs,'lower'); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
753 %! assert (LS*LS', QS*bs*QS', 1e-10); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
754 %! assert (PS, 0); |
5590 | 755 |
756 EOF | |
757 } | |
758 | |
759 # test scalar operations: uses af and real scalar bf; modifies as,bf,bs | |
760 gen_scalar_tests() { | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
761 echo '%!test as = sparse (af);' |
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
762 echo '%!test bs = bf;' |
5590 | 763 gen_elementop_tests |
764 gen_ordering_tests | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
765 echo '%!test bf = bf+1i;' |
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
766 echo '%!test bs = bf;' |
5590 | 767 gen_elementop_tests |
768 } | |
769 | |
770 # test matrix operations: uses af and bf; modifies as,bs | |
771 gen_rectangular_tests() { | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
772 echo '%!test as = sparse(af);' |
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
773 echo '%!test bs = sparse(bf);' |
5590 | 774 gen_mapper_tests |
775 gen_real_mapper_tests | |
776 gen_unaryop_tests | |
777 gen_elementop_tests | |
778 gen_sparsesparse_elementop_tests | |
779 gen_matrixop_tests | |
780 # gen_divop_tests # Disable rectangular \ and / for now | |
781 gen_matrixdiag_tests | |
782 gen_matrixreshape_tests | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
783 cat <<EOF |
14190
68fd9f95e1f9
Don't process comments in %!testif specifications.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
784 %!testif HAVE_UMFPACK # permuted LU |
32063
3b9305e62bb7
avoid LU warnings in sparse tests (bug #64117)
John W. Eaton <jwe@octave.org>
parents:
32059
diff
changeset
|
785 %! ## Yes, we want to test lu with fewer than 4 output arguments |
3b9305e62bb7
avoid LU warnings in sparse tests (bug #64117)
John W. Eaton <jwe@octave.org>
parents:
32059
diff
changeset
|
786 %! ## and sparse input while also avoiding the warning. So use |
3b9305e62bb7
avoid LU warnings in sparse tests (bug #64117)
John W. Eaton <jwe@octave.org>
parents:
32059
diff
changeset
|
787 %! ## warning ("off", ...) insetead of additional outputs. |
3b9305e62bb7
avoid LU warnings in sparse tests (bug #64117)
John W. Eaton <jwe@octave.org>
parents:
32059
diff
changeset
|
788 %! warning ("off", "Octave:lu:sparse_input", "local"); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
789 %! [L,U] = lu (bs); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
790 %! assert (L*U, bs, 1e-10); |
8954
97c84c4c2247
Make the column permutation vector in sparse LU cols()-long.
Jason Riedy <jason@acm.org>
parents:
8920
diff
changeset
|
791 |
14190
68fd9f95e1f9
Don't process comments in %!testif specifications.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
792 %!testif HAVE_UMFPACK # simple LU + row permutations |
32063
3b9305e62bb7
avoid LU warnings in sparse tests (bug #64117)
John W. Eaton <jwe@octave.org>
parents:
32059
diff
changeset
|
793 %! ## Yes, we want to test lu with fewer than 4 output arguments |
3b9305e62bb7
avoid LU warnings in sparse tests (bug #64117)
John W. Eaton <jwe@octave.org>
parents:
32059
diff
changeset
|
794 %! ## and sparse input while also avoiding the warning. So use |
3b9305e62bb7
avoid LU warnings in sparse tests (bug #64117)
John W. Eaton <jwe@octave.org>
parents:
32059
diff
changeset
|
795 %! ## warning ("off", ...) insetead of additional outputs. |
3b9305e62bb7
avoid LU warnings in sparse tests (bug #64117)
John W. Eaton <jwe@octave.org>
parents:
32059
diff
changeset
|
796 %! warning ("off", "Octave:lu:sparse_input", "local"); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
797 %! [L,U,P] = lu (bs); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
798 %! assert (P'*L*U, bs, 1e-10); |
17336
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
17307
diff
changeset
|
799 %! ## triangularity |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
800 %! [i,j,v] = find (L); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
801 %! assert (i-j>=0); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
802 %! [i,j,v] = find (U); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
803 %! assert (j-i>=0); |
8954
97c84c4c2247
Make the column permutation vector in sparse LU cols()-long.
Jason Riedy <jason@acm.org>
parents:
8920
diff
changeset
|
804 |
14190
68fd9f95e1f9
Don't process comments in %!testif specifications.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
805 %!testif HAVE_UMFPACK # simple LU + row/col permutations |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
806 %! [L,U,P,Q] = lu (bs); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
807 %! assert (P'*L*U*Q', bs, 1e-10); |
17336
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
17307
diff
changeset
|
808 %! ## triangularity |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
809 %! [i,j,v] = find (L); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
810 %! assert (i-j>=0); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
811 %! [i,j,v] = find (U); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
812 %! assert (j-i>=0); |
8954
97c84c4c2247
Make the column permutation vector in sparse LU cols()-long.
Jason Riedy <jason@acm.org>
parents:
8920
diff
changeset
|
813 |
14190
68fd9f95e1f9
Don't process comments in %!testif specifications.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
814 %!testif HAVE_UMFPACK # LU with vector permutations |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
815 %! [L,U,P,Q] = lu (bs,'vector'); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
816 %! assert (L (P,:)*U (:,Q), bs, 1e-10); |
17336
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
17307
diff
changeset
|
817 %! ## triangularity |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
818 %! [i,j,v] = find (L); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
819 %! assert (i-j>=0); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
820 %! [i,j,v] = find (U); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
821 %! assert (j-i>=0); |
8954
97c84c4c2247
Make the column permutation vector in sparse LU cols()-long.
Jason Riedy <jason@acm.org>
parents:
8920
diff
changeset
|
822 |
14190
68fd9f95e1f9
Don't process comments in %!testif specifications.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
823 %!testif HAVE_UMFPACK # LU with scaling |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
824 %! [L,U,P,Q,R] = lu (bs); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
825 %! assert (R*P'*L*U*Q', bs, 1e-10); |
17336
b81b9d079515
Use '##' for comments which stand alone on a line.
Rik <rik@octave.org>
parents:
17307
diff
changeset
|
826 %! ## triangularity |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
827 %! [i,j,v] = find (L); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
828 %! assert (i-j>=0); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
829 %! [i,j,v] = find (U); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
830 %! assert (j-i>=0); |
8954
97c84c4c2247
Make the column permutation vector in sparse LU cols()-long.
Jason Riedy <jason@acm.org>
parents:
8920
diff
changeset
|
831 |
97c84c4c2247
Make the column permutation vector in sparse LU cols()-long.
Jason Riedy <jason@acm.org>
parents:
8920
diff
changeset
|
832 EOF |
5590 | 833 } |
834 | |
835 | |
836 # ======================================================= | |
837 # sparse assembly tests | |
838 | |
839 gen_assembly_tests() { | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
840 cat <<EOF |
5590 | 841 %%Assembly tests |
842 %!test | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
843 %! m = max ([m;r(:)]); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
844 %! n = max ([n;c(:)]); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
845 %! funiq = fsum = zeros (m,n); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
846 %! funiq(r(:) + m*(c(:)-1) ) = ones (size (r(:))); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
847 %! funiq = sparse (funiq); |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
848 %! for k=1:length (r) |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
849 %! fsum(r(k),c(k)) += 1; |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
850 %! endfor |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
851 %! fsum = sparse (fsum); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
852 %!assert (sparse (r,c,1), sparse (fsum(1:max(r), 1:max(c)))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
853 %!assert (sparse (r,c,1,"sum"), sparse (fsum(1:max (r),1:max (c)))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
854 %!assert (sparse (r,c,1,"unique"), sparse (funiq(1:max (r),1:max (c)))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
855 %!assert (sparse (r,c,1,m,n), sparse (fsum)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
856 %!assert (sparse (r,c,1,m,n,"sum"), sparse (fsum)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
857 %!assert (sparse (r,c,1,m,n,"unique"), sparse (funiq)) |
5590 | 858 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
859 %!assert (sparse (r,c,1i), sparse (fsum(1:max (r),1:max (c))*1i)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
860 %!assert (sparse (r,c,1i,"sum"), sparse (fsum(1:max (r),1:max (c))*1i)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
861 %!assert (sparse (r,c,1i,"unique"), sparse (funiq(1:max (r),1:max (c))*1i)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
862 %!assert (sparse (r,c,1i,m,n), sparse (fsum*1i)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
863 %!assert (sparse (r,c,1i,m,n,"sum"), sparse (fsum*1i)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
864 %!assert (sparse (r,c,1i,m,n,"unique"), sparse (funiq*1i)) |
5590 | 865 |
866 %!test | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
867 %! if (issparse (funiq)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
868 %! assert (sparse (full (1i*funiq)), sparse (1i*funiq)); |
5590 | 869 %! endif |
870 | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
871 %!assert (sparse (full (funiq)), funiq) |
5590 | 872 |
873 | |
874 EOF | |
875 } | |
876 | |
877 # ======================================================= | |
878 # sparse selection tests | |
879 | |
7326 | 880 gen_scalar_select_tests () { |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
881 cat <<EOF |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
882 %!assert (sparse (42)([1,1]), sparse ([42,42])) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
883 %!assert (sparse (42*1i)([1,1]), sparse ([42,42].*1i)) |
7326 | 884 EOF |
885 } | |
886 | |
5590 | 887 gen_select_tests() { |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
888 cat <<EOF |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
889 %!test as = sparse (af); |
5590 | 890 |
891 %% Point tests | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
892 %!test idx = ridx(:) + rows (as) * (cidx (:)-1); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
893 %!assert (sparse (as(idx)), sparse (af(idx))) |
21317
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
894 %!assert (as(idx), sparse (af(idx))) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
895 %!assert (as(idx'), sparse (af(idx'))) |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
896 %!assert (as(flipud (idx(:))), sparse (af(flipud (idx(:))))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
897 %!assert (as([idx,idx]), sparse (af([idx,idx]))) |
19416
06b23f224f52
fix problem with changeset e354372e20f2 (bug #43855)
John W. Eaton <jwe@octave.org>
parents:
19278
diff
changeset
|
898 %!assert (as(reshape ([idx;idx], [1,length(idx),2])), sparse(af(reshape ([idx;idx], [1,length(idx),2])))) |
5590 | 899 |
900 %% Slice tests | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
901 %!assert (as(ridx,cidx), sparse (af(ridx,cidx))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
902 %!assert (as(ridx,:), sparse (af(ridx,:))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
903 %!assert (as(:,cidx), sparse (af(:,cidx))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
904 %!assert (as(:,:), sparse (af(:,:))) |
30236
628f26e122d9
maint: use rows() or columns() instead of size(__, 1 | 2) for clarity.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
905 %!assert (as((rows (as):-1:1),:), sparse (af((size (af,1):-1:1),:))) |
628f26e122d9
maint: use rows() or columns() instead of size(__, 1 | 2) for clarity.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
906 %!assert (as(:,(columns (as):-1:1)), sparse (af(:, (size (af,2):-1:1)))) |
5603 | 907 |
7322 | 908 %% Indexing tests |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
909 %!assert (full (as([1,1],:)), af([1,1],:)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
910 %!assert (full (as(:,[1,1])), af(:,[1,1])) |
7322 | 911 %!test |
912 %! [i,j,v] = find (as); | |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
913 %! assert (as(i(1),j(1))([1,1]), sparse ([v(1), v(1)])); |
7322 | 914 |
5603 | 915 %% Assignment test |
916 %!test | |
30236
628f26e122d9
maint: use rows() or columns() instead of size(__, 1 | 2) for clarity.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
917 %! ts = as; ts(:,:) = ts(fliplr (1:rows (as)),:); |
628f26e122d9
maint: use rows() or columns() instead of size(__, 1 | 2) for clarity.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
918 %! tf = af; tf(:,:) = tf(fliplr (1:rows (af)),:); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
919 %! assert (ts, sparse (tf)); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
920 %!test |
30236
628f26e122d9
maint: use rows() or columns() instead of size(__, 1 | 2) for clarity.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
921 %! ts = as; ts(fliplr (1:rows (as)),:) = ts; |
628f26e122d9
maint: use rows() or columns() instead of size(__, 1 | 2) for clarity.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
922 %! tf = af; tf(fliplr (1:rows (af)),:) = tf; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
923 %! assert (ts, sparse (tf)); |
5603 | 924 %!test |
30236
628f26e122d9
maint: use rows() or columns() instead of size(__, 1 | 2) for clarity.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
925 %! ts = as; ts(:,fliplr (1:columns (as))) = ts; |
628f26e122d9
maint: use rows() or columns() instead of size(__, 1 | 2) for clarity.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
926 %! tf = af; tf(:,fliplr (1:columns (af))) = tf; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
927 %! assert (ts, sparse (tf)); |
5603 | 928 %!test |
30236
628f26e122d9
maint: use rows() or columns() instead of size(__, 1 | 2) for clarity.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
929 %! ts(fliplr (1:rows (as))) = as(:,1); |
628f26e122d9
maint: use rows() or columns() instead of size(__, 1 | 2) for clarity.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
930 %! tf(fliplr (1:rows (af))) = af(:,1); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
931 %! assert (ts, sparse (tf)); |
5603 | 932 |
933 %% Deletion tests | |
934 %!test | |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
935 %! ts = as; ts(1,:) = []; tf = af; tf(1,:) = []; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
936 %! assert (ts, sparse (tf)); |
5603 | 937 %!test |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
938 %! ts = as; ts(:,1) = []; tf = af; tf(:,1) = []; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
939 %! assert (ts, sparse (tf)); |
5590 | 940 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
941 %% Test "end" keyword |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
942 %!assert (full (as(end)), af(end)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
943 %!assert (full (as(1,end)), af(1,end)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
944 %!assert (full (as(end,1)), af(end,1)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
945 %!assert (full (as(end,end)), af(end,end)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
946 %!assert (as(2:end,2:end), sparse (af(2:end,2:end))) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
947 %!assert (as(1:end-1,1:end-1), sparse (af(1:end-1,1:end-1))) |
5590 | 948 EOF |
949 } | |
950 | |
951 # ======================================================= | |
952 # sparse save and load tests | |
953 | |
954 gen_save_tests() { | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
955 cat <<EOF |
5590 | 956 %!test # save ascii |
19278
6ca096827123
Use tempname() rather than tmpnam() in core Octave.
Rik <rik@octave.org>
parents:
19275
diff
changeset
|
957 %! savefile = tempname (); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
958 %! as_save = as; |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
959 %! save ("-text", savefile, "bf", "as_save", "af"); |
5590 | 960 %! clear as_save; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
961 %! load (savefile, "as_save"); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
962 %! unlink (savefile); |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
963 %! assert (as_save, sparse (af)); |
5590 | 964 %!test # save binary |
19278
6ca096827123
Use tempname() rather than tmpnam() in core Octave.
Rik <rik@octave.org>
parents:
19275
diff
changeset
|
965 %! savefile = tempname (); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
966 %! as_save = as; |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
967 %! save ("-binary", savefile, "bf", "as_save", "af"); |
5590 | 968 %! clear as_save; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
969 %! load (savefile, "as_save"); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
970 %! unlink (savefile); |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
971 %! assert (as_save, sparse (af)); |
14190
68fd9f95e1f9
Don't process comments in %!testif specifications.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
972 %!testif HAVE_HDF5 # save hdf5 |
19278
6ca096827123
Use tempname() rather than tmpnam() in core Octave.
Rik <rik@octave.org>
parents:
19275
diff
changeset
|
973 %! savefile = tempname (); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
974 %! as_save = as; |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
975 %! save ("-hdf5", savefile, "bf", "as_save", "af"); |
5590 | 976 %! clear as_save; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
977 %! load (savefile, "as_save"); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
978 %! unlink (savefile); |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
979 %! assert (as_save, sparse (af)); |
22389
663e30242c4b
avoid using "expected failure" to describe known bugs
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
980 ## FIXME: We should skip (or mark as a known bug) the test for |
8871 | 981 ## saving sparse matrices to MAT files when using 64-bit indexing since |
982 ## that is not implemented yet. | |
5590 | 983 %!test # save matlab |
19278
6ca096827123
Use tempname() rather than tmpnam() in core Octave.
Rik <rik@octave.org>
parents:
19275
diff
changeset
|
984 %! savefile = tempname (); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
985 %! as_save = as; |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
986 %! save ("-mat", savefile, "bf", "as_save", "af"); |
5590 | 987 %! clear as_save; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
988 %! load (savefile, "as_save"); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
989 %! unlink (savefile); |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
990 %! assert (as_save, sparse (af)); |
5590 | 991 EOF |
992 } | |
993 | |
994 # ============================================================= | |
995 # Specific solver tests for matrices that will test all of the solver | |
996 # code. Uses alpha and beta | |
997 gen_solver_tests() { | |
998 | |
999 if $preset; then | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1000 cat <<EOF |
5590 | 1001 %! n=8; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1002 %! lf=diag (1:n); lf(n-1,1)=0.5*alpha; lf(n,2)=0.25*alpha; ls=sparse (lf); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1003 %! uf=diag (1:n); uf(1,n-1)=2*alpha; uf(2,n)=alpha; us=sparse (uf); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1004 %! ts=spdiags (ones (n,3),-1:1,n,n) + diag (1:n); tf = full (ts); |
5590 | 1005 EOF |
1006 else | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1007 cat <<EOF |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1008 %! n = floor (lognrnd (8,2)+1)'; |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1009 %! ls = tril (sprandn (8,8,0.2),-1).*alpha + n*speye (8); lf = full (ls); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1010 %! us = triu (sprandn (8,8,0.2),1).*alpha + n*speye (8); uf = full (us); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1011 %! ts = spdiags (randn (8,3),-1:1,8,8).*alpha; tf = full (ts); |
5590 | 1012 EOF |
1013 fi | |
1014 | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1015 cat <<EOF |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1016 %! df = diag (1:n).* alpha; ds = sparse (df); |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
1017 %! pdf = df(randperm (n), randperm (n)); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1018 %! pds = sparse (pdf); |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
1019 %! plf = lf(randperm (n), randperm (n)); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1020 %! pls = sparse (plf); |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
1021 %! puf = uf(randperm (n), randperm (n)); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1022 %! pus = sparse (puf); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1023 %! bs = spdiags (repmat ([1:n]',1,4),-2:1,n,n).*alpha; |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1024 %! bf = full (bs); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1025 %! cf = lf + lf'; cs = sparse (cf); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1026 %! bcf = bf + bf'; bcs = sparse (bcf); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1027 %! tcf = tf + tf'; tcs = sparse (tcf); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1028 %! xf = diag (1:n) + fliplr (diag (1:n)).*beta; |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1029 %! xs = sparse (xf); |
21317
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
1030 %!assert (ds\xf, df\xf, 1e-10) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
1031 %!assert (ds\xs, sparse (df\xf), 1e-10) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
1032 %!assert (pds\xf, pdf\xf, 1e-10) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
1033 %!assert (pds\xs, sparse (pdf\xf), 1e-10) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
1034 %!assert (ls\xf, lf\xf, 1e-10) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
1035 %!assert (sparse (ls\xs), sparse (lf\xf), 1e-10) |
7243 | 1036 %!testif HAVE_UMFPACK |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1037 %! assert (pls\xf, plf\xf, 1e-10); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1038 %!testif HAVE_UMFPACK |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1039 %! assert (sparse (pls\xs), sparse (plf\xf), 1e-10); |
21317
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
1040 %!assert (us\xf, uf\xf, 1e-10) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
1041 %!assert (sparse (us\xs), sparse (uf\xf), 1e-10) |
7243 | 1042 %!testif HAVE_UMFPACK |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1043 %! assert (pus\xf, puf\xf, 1e-10); |
7243 | 1044 %!testif HAVE_UMFPACK |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1045 %! assert (sparse (pus\xs), sparse (puf\xf), 1e-10); |
21317
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
1046 %!assert (bs\xf, bf\xf, 1e-10) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
1047 %!assert (sparse (bs\xs), sparse (bf\xf), 1e-10) |
7243 | 1048 %!testif HAVE_UMFPACK |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1049 %! assert (cs\xf, cf\xf, 1e-10); |
7243 | 1050 %!testif HAVE_UMFPACK |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1051 %! assert (sparse (cs\xs), sparse (cf\xf), 1e-10); |
7243 | 1052 %!testif HAVE_UMFPACK |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1053 %! assert (bcs\xf, bcf\xf, 1e-10); |
7254 | 1054 %!testif HAVE_UMFPACK |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1055 %! assert (sparse (bcs\xs), sparse (bcf\xf), 1e-10); |
21317
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
1056 %!assert (ts\xf, tf\xf, 1e-10) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
1057 %!assert (sparse (ts\xs), sparse (tf\xf), 1e-10) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
1058 %!assert (tcs\xf, tcf\xf, 1e-10) |
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
21308
diff
changeset
|
1059 %!assert (sparse (tcs\xs), sparse (tcf\xf), 1e-10) |
5590 | 1060 |
1061 EOF | |
5610 | 1062 |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1063 cat <<EOF |
5610 | 1064 %% QR solver tests |
1065 | |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
1066 %!function f (a, sz, feps) |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1067 %! b = randn (sz); |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
1068 %! x = a \ b; |
5610 | 1069 %! assert (a * x, b, feps); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1070 %! b = randn (sz) + 1i*randn (sz); |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
1071 %! x = a \ b; |
5610 | 1072 %! assert (a * x, b, feps); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1073 %! b = sprandn (sz(1),sz(2),0.2); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1074 %! x = a \ b; |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1075 %! assert (sparse (a * x), b, feps); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1076 %! b = sprandn (sz(1),sz(2),0.2) + 1i*sprandn (sz(1),sz(2),0.2); |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
1077 %! x = a \ b; |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1078 %! assert (sparse (a * x), b, feps); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1079 %!endfunction |
29261
f36ca61488e0
tests: Make tests that depend on CXSparse conditional.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
1080 %!testif HAVE_UMFPACK, HAVE_CXSPARSE |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1081 %! a = alpha*sprandn (10,11,0.2) + speye (10,11); |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
1082 %! f (a,[10,2],1e-10); |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
1083 %! ## Test this by forcing matrix_type, as can't get a certain |
5630 | 1084 %! ## result for over-determined systems. |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
1085 %! a = alpha*sprandn (10,10,0.2) + speye (10,10); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1086 %! matrix_type (a, "Singular"); |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
1087 %! f (a,[10,2],1e-10); |
5610 | 1088 |
5630 | 1089 %% Rectanguar solver tests that don't use QR |
1090 | |
1091 %!test | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1092 %! ds = alpha * spdiags ([1:11]',0,10,11); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1093 %! df = full (ds); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1094 %! xf = beta * ones (10,2); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1095 %! xs = speye (10,10); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1096 %!assert (ds\xf, df\xf, 100*eps) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1097 %!assert (ds\xs, sparse (df\xs), 100*eps) |
5630 | 1098 %!test |
1099 %! pds = ds([2,1,3:10],:); | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1100 %! pdf = full (pds); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1101 %!assert (pds\xf, pdf\xf, 100*eps) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1102 %!assert (pds\xs, sparse (pdf\xs), 100*eps) |
5630 | 1103 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1104 %! ds = alpha * spdiags ([1:11]',0,11,10); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1105 %! df = full (ds); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1106 %! xf = beta * ones (11,2); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1107 %! xs = speye (11,11); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1108 %!assert (ds\xf, df\xf, 100*eps) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1109 %!assert (ds\xs, sparse (df\xs), 100*eps) |
5630 | 1110 %!test |
1111 %! pds = ds([2,1,3:11],:); | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1112 %! pdf = full (pds); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1113 %!assert (pds\xf, pdf\xf, 100*eps) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1114 %!assert (pds\xs, sparse (pdf\xs), 100*eps) |
5630 | 1115 %!test |
1116 %! us = alpha*[[speye(10,10);sparse(1,10)],[[1,1];sparse(9,2);[1,1]]]; | |
29261
f36ca61488e0
tests: Make tests that depend on CXSparse conditional.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
1117 %!testif HAVE_UMFPACK, HAVE_CXSPARSE |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
1118 %! assert (us*(us\xf), xf, 100*eps); |
29261
f36ca61488e0
tests: Make tests that depend on CXSparse conditional.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
1119 %!testif HAVE_UMFPACK, HAVE_CXSPARSE |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
1120 %! assert (us*(us\xs), xs, 100*eps); |
5630 | 1121 %!test |
1122 %! pus = us(:,[2,1,3:12]); | |
29261
f36ca61488e0
tests: Make tests that depend on CXSparse conditional.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
1123 %!testif HAVE_UMFPACK, HAVE_CXSPARSE |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
1124 %! assert (pus*(pus\xf), xf, 100*eps); |
29261
f36ca61488e0
tests: Make tests that depend on CXSparse conditional.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
1125 %!testif HAVE_UMFPACK, HAVE_CXSPARSE |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
1126 %! assert (pus*(pus\xs), xs, 100*eps); |
5630 | 1127 %!test |
1128 %! us = alpha*[speye(11,9),[1;sparse(8,1);1;0]]; | |
7243 | 1129 %!testif HAVE_CXSPARSE |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7326
diff
changeset
|
1130 %! [c,r] = qr (us, xf); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
1131 %! assert (us\xf, r\c, 100*eps); |
29261
f36ca61488e0
tests: Make tests that depend on CXSparse conditional.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
1132 %!testif HAVE_UMFPACK, HAVE_CXSPARSE |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7326
diff
changeset
|
1133 %! [c,r] = qr (us, xs); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1134 %! r = matrix_type (r, "Singular"); ## Force Matrix Type |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
1135 %! assert (us\xs, r\c, 100*eps); |
5630 | 1136 %!test |
1137 %! pus = us(:,[1:8,10,9]); | |
29261
f36ca61488e0
tests: Make tests that depend on CXSparse conditional.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
1138 %!testif HAVE_UMFPACK, HAVE_CXSPARSE |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7326
diff
changeset
|
1139 %! [c,r] = qr (pus, xf); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1140 %! r = matrix_type (r, "Singular"); ## Force Matrix Type |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
1141 %! assert (pus\xf, r\c, 100*eps); |
29261
f36ca61488e0
tests: Make tests that depend on CXSparse conditional.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
1142 %!testif HAVE_UMFPACK, HAVE_CXSPARSE |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7326
diff
changeset
|
1143 %! [c,r] = qr (pus, xs); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1144 %! r = matrix_type (r, "Singular"); ## Force Matrix Type |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
1145 %! assert (pus\xs, r\c, 100*eps); |
5630 | 1146 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1147 %! ls = alpha*[speye(9,11);[1, sparse(1,8),1,0]]; |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1148 %! xf = beta * ones (10,2); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1149 %! xs = speye (10,10); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1150 %!assert (ls*(ls\xf), xf, 100*eps) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1151 %!assert (ls*(ls\xs), xs, 100*eps) |
5630 | 1152 %!test |
1153 %! pls = ls([1:8,10,9],:); | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1154 %!assert (pls*(pls\xf), xf, 100*eps) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1155 %!assert (pls*(pls\xs), xs, 100*eps) |
5630 | 1156 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1157 %! ls = alpha*[speye(10,10), sparse(10,1);[1;1], sparse(2,9),[1;1]]; |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1158 %! xf = beta * ones (12,2); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1159 %! xs = speye (12,12); |
29261
f36ca61488e0
tests: Make tests that depend on CXSparse conditional.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
1160 %!testif HAVE_UMFPACK, HAVE_CXSPARSE |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7326
diff
changeset
|
1161 %! [c,r] = qr (ls, xf); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
1162 %! assert (ls\xf, r\c, 100*eps); |
29261
f36ca61488e0
tests: Make tests that depend on CXSparse conditional.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
1163 %!testif HAVE_UMFPACK, HAVE_CXSPARSE |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7326
diff
changeset
|
1164 %! [c,r] = qr (ls, xs); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1165 %! r = matrix_type (r, "Singular"); ## Force Matrix Type |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
1166 %! assert (ls\xs, r\c, 100*eps); |
29261
f36ca61488e0
tests: Make tests that depend on CXSparse conditional.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
1167 %!test |
5630 | 1168 %! pls = ls(:,[1:8,10,9]); |
29261
f36ca61488e0
tests: Make tests that depend on CXSparse conditional.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
1169 %!testif HAVE_UMFPACK, HAVE_CXSPARSE |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7326
diff
changeset
|
1170 %! [c,r] = qr (pls, xf); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1171 %! r = matrix_type (r, "Singular"); ## Force Matrix Type |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
1172 %! assert (pls\xf, r\c, 100*eps); |
29261
f36ca61488e0
tests: Make tests that depend on CXSparse conditional.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27923
diff
changeset
|
1173 %!testif HAVE_UMFPACK, HAVE_CXSPARSE |
7505
f5005d9510f4
Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents:
7326
diff
changeset
|
1174 %! [c,r] = qr (pls, xs); |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1175 %! r = matrix_type (r, "Singular"); ## Force Matrix Type |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21317
diff
changeset
|
1176 %! assert (pls\xs, r\c, 100*eps); |
5630 | 1177 |
5610 | 1178 EOF |
5590 | 1179 } |
1180 | |
1181 | |
1182 # ============================================================= | |
1183 # Putting it all together: defining the combined tests | |
1184 | |
1185 | |
1186 # initial function | |
1187 gen_function | |
1188 gen_section | |
1189 | |
1190 # specific tests | |
16215
6fe6ac8bbfdb
test: Remove trailing spaces from ends of lines in test/ directory.
Rik <rik@octave.org>
parents:
16213
diff
changeset
|
1191 if $preset; then |
5590 | 1192 gen_specific_tests |
1193 gen_section | |
1194 fi | |
1195 | |
1196 # scalar operations | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1197 echo '%!shared as,af,bs,bf' |
5590 | 1198 if $preset; then |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1199 echo '%!test af=[1+1i,2-1i,0,0;0,0,0,3+2i;0,0,0,4];' |
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1200 echo '%!test bf=3;' |
5590 | 1201 else |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1202 cat <<EOF |
5590 | 1203 %!test |
1204 %! % generate m,n from 1 to <5000 | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1205 %! m = floor (lognrnd (8,2)+1); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1206 %! n = floor (lognrnd (8,2)+1); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1207 %! as = sprandn (m,n,0.3); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1208 %! af = full (as + 1i*sprandn (as)); |
5590 | 1209 %! bf = randn; |
1210 EOF | |
1211 fi | |
1212 | |
1213 gen_scalar_tests | |
1214 gen_section | |
1215 | |
1216 # rectangular operations | |
1217 if $preset; then | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1218 echo '%!test af=[1+1i,2-1i,0,0;0,0,0,3+2i;0,0,0,4];' |
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1219 echo '%!test bf=[0,1-1i,0,0;2+1i,0,0,0;3-1i,2+3i,0,0];' |
5590 | 1220 else |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1221 cat <<EOF |
5590 | 1222 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1223 %! m = floor (lognrnd (8,2)+1); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1224 %! n = floor (lognrnd (8,2)+1); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1225 %! as = sprandn (m,n,0.3); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1226 %! af = full (as + 1i*sprandn (as)); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1227 %! bs = sprandn (m,n,0.3); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1228 %! bf = full (bs + 1i*sprandn (bs)); |
5590 | 1229 EOF |
1230 fi | |
1231 | |
1232 gen_rectangular_tests | |
1233 gen_section | |
1234 gen_save_tests | |
1235 gen_section | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1236 echo '%!test bf = real (bf);' |
5590 | 1237 gen_rectangular_tests |
1238 gen_section | |
1239 gen_sparsesparse_ordering_tests | |
1240 gen_section | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1241 echo '%!test af = real (af);' |
5590 | 1242 gen_rectangular_tests |
1243 gen_section | |
1244 gen_save_tests | |
1245 gen_section | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1246 echo '%!test bf = bf+1i*(bf!=0);' |
5590 | 1247 gen_rectangular_tests |
1248 gen_section | |
1249 | |
1250 # square operations | |
1251 if $preset; then | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1252 echo '%!test af = [1+1i,2-1i,0,0;0,0,0,3+2i;0,0,0,4];' |
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1253 echo '%! as = sparse (af);' |
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1254 echo '%!test bf = [0,1-1i,0,0;2+1i,0,0,0;3-1i,2+3i,0,0];' |
5590 | 1255 else |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1256 cat <<EOF |
5590 | 1257 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1258 %! m = floor (lognrnd (8,2)+1); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1259 %! n = floor (lognrnd (8,2)+1); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1260 %! as = sprandn (m,n,0.3); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1261 %! af = full (as + 1i*sprandn (as)); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1262 %! bs = sprandn (m,n,0.3); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1263 %! bf = full (bs + 1i*sprandn (bs)); |
5590 | 1264 EOF |
1265 fi | |
1266 | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1267 cat <<EOF |
5590 | 1268 %!test ;# invertible matrix |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1269 %! bf = af'*bf+max (abs ([af(:);bf(:)]))*sparse (eye (columns (as))); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1270 %! bs = sparse (bf); |
5590 | 1271 |
1272 EOF | |
1273 | |
1274 gen_square_tests | |
1275 gen_section | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1276 echo '%!test bf = real (bf);' |
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1277 echo '%! bs = sparse (bf);' |
5590 | 1278 gen_square_tests |
1279 gen_section | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1280 echo '%!test af = real (af);' |
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1281 echo '%! as = sparse (af);' |
5590 | 1282 gen_square_tests |
1283 gen_section | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1284 echo '%!test bf = bf+1i*(bf!=0);' |
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1285 echo '%! bs = sparse (bf);' |
5590 | 1286 gen_square_tests |
1287 gen_section | |
1288 | |
1289 # cholesky tests | |
1290 if $preset; then | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1291 echo '%!test bf = [5,0,1+1i,0;0,5,0,1-2i;1-1i,0,5,0;0,1+2i,0,5];' |
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1292 echo '%! bs = sparse (bf);' |
5590 | 1293 else |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1294 echo '# This has a small chance of failing to create a positive definite matrix' |
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1295 echo '%!test n = floor (lognrnd (8,2)+1)' |
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1296 echo '%! bs = n*speye (n,n) + sprandn (n,n,0.3);' |
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1297 echo '%! bf = full (bs);' |
5590 | 1298 fi |
1299 | |
1300 gen_cholesky_tests | |
1301 gen_section | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1302 echo '%!test bf = real (bf);' |
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1303 echo '%! bs = sparse (bf);' |
5590 | 1304 gen_cholesky_tests |
1305 gen_section | |
1306 | |
1307 # assembly tests | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1308 echo '%!shared r,c,m,n,fsum,funiq' |
5590 | 1309 if $use_preset; then |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1310 cat <<EOF |
5590 | 1311 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1312 %! r = [1,1,2,1,2,3]; |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1313 %! c = [2,1,1,1,2,1]; |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1314 %! m = n = 0; |
5590 | 1315 EOF |
1316 else | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1317 cat <<EOF |
5590 | 1318 %!test |
1319 %! % generate m,n from 1 to <5000 | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1320 %! m = floor (lognrnd (8,2)+1); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1321 %! n = floor (lognrnd (8,2)+1); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1322 %! nz = ceil ((m+n)/2); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1323 %! r = floor (rand (5,nz)*n)+1; |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1324 %! c = floor (rand (5,nn)*m)+1; |
5590 | 1325 EOF |
1326 fi | |
1327 gen_assembly_tests #includes real and complex tests | |
1328 gen_section | |
1329 | |
1330 # slicing tests | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1331 echo '%!shared ridx,cidx,idx,as,af' |
5590 | 1332 if $use_preset; then |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1333 cat <<EOF |
5590 | 1334 %!test |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1335 %! af = [1+1i,2-1i,0,0;0,0,0,3+2i;0,0,0,4]; |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1336 %! ridx = [1,3]; |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1337 %! cidx = [2,3]; |
5590 | 1338 EOF |
1339 else | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1340 cat <<EOF |
5590 | 1341 %!test |
1342 %! % generate m,n from 1 to <5000 | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1343 %! m = floor (lognrnd (8,2)+1); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1344 %! n = floor (lognrnd (8,2)+1); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1345 %! as = sprandn (m,n,0.3); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1346 %! af = full (as + 1i*sprandn (as)); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1347 %! ridx = ceil (m*rand (1,ceil (rand*m)); |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
12757
diff
changeset
|
1348 %! cidx = ceil (n*rand (1,ceil (rand*n)); |
5590 | 1349 EOF |
1350 fi | |
7326 | 1351 gen_scalar_select_tests |
5590 | 1352 gen_select_tests |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1353 echo '%!test af = real (af);' |
5590 | 1354 gen_select_tests |
1355 gen_section | |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1356 echo '%!shared alpha,beta,df,pdf,lf,plf,uf,puf,bf,cf,bcf,tf,tcf,xf,ds,pds,ls,pls,us,pus,bs,cs,bcs,ts,tcs,xs' |
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1357 echo '%!test alpha=1; beta=1;' |
5590 | 1358 gen_solver_tests |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1359 echo '%!test alpha=1; beta=1i;' |
5590 | 1360 gen_solver_tests |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1361 echo '%!test alpha=1i; beta=1;' |
5590 | 1362 gen_solver_tests |
20304
dadfb0be8a42
write sparse tests to stdout
John W. Eaton <jwe@octave.org>
parents:
20303
diff
changeset
|
1363 echo '%!test alpha=1i; beta=1i;' |
5590 | 1364 gen_solver_tests |
1365 gen_section |