annotate test/build-sparse-tests.sh @ 16029:b8157404614f

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