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