1function test10 (nmat) 2%TEST10 test cholmod2's backslash on real and complex matrices 3% Example: 4% test10(nmat) 5% See also cholmod_test 6 7% Copyright 2007, Timothy A. Davis, http://www.suitesparse.com 8 9fprintf ('=================================================================\n'); 10fprintf ('test10: test cholmod2''s backslash\n') ; 11 12rand ('state',0) ; 13randn ('state',0) ; 14 15index = ssget ; 16f = find (index.posdef) ; 17[ignore i] = sort (index.nrows (f)) ; 18f = f (i) ; 19 20% start after nd6k 21% f = f ((find (f == 937) + 1):end) ; 22 23skip = [937:939 1202:1211] ; 24if (nargin > 0) 25 nmat = max (0,nmat) ; 26 nmat = min (nmat, length (f)) ; 27 f = f (1:nmat) ; 28end 29 30fprintf ('test matrices sorted by dimension:\n') ; 31for i = f 32 if (any (i == skip)) 33 continue 34 end 35 fprintf ('%4d: %-20s %-20s %12d %d\n', i, ... 36 index.Group {i}, index.Name {i}, index.nrows (i), index.posdef (i)) ; 37end 38 39 40for nn = f 41 % for nn = 23 42 43 if (any (nn == skip)) 44 continue 45 end 46 47 % try 48 49 for complexity = 0:1 50 51 if nn < 0 52 n = -nn ; 53 A = rand (n) + (complexity * rand(n) * 1i) ; 54 A=A*A' ; 55 full (A) 56 A = sparse (A) ; 57 58 elseif (nn == 0) 59 60 i = 1i ; 61 A = [ 11 4-i 1+i 2+2*i 62 4+i 22 0 0 63 1-i 0 33 0 64 2-2*i 0 0 44 ] ; 65 A = sparse (A) ; 66 p = [4 3 2 1] ; %#ok 67 full (A) 68 A = sparse (A) ; 69 70 else 71 72 if (~complexity) 73 nn %#ok 74 Prob = ssget (nn) %#ok 75 end 76 A = Prob.A ; 77 if (complexity) 78 A = A / norm(A,1) ; 79 Z = .1 * sprandn (A) * 1i ; 80 Z = Z+Z' ; 81 A = A + Z ; 82 A = A + norm(A,1) * speye (size(A,1)) ; 83 end 84 n = size (A,1) ; 85 end 86 87 for sparsity = 0:1 88 89 if (sparsity) 90 b = sprandn (n,4,0.1) ; 91 else 92 b = rand (n,4) ; 93 end 94 95 b1 = b (:,1) ; 96 97 [x1,x2,e1,e2] = testsolve (A,b1) ; %#ok 98 [x1,x2,e1,e2] = testsolve (A,b) ; %#ok 99 100 if (sparsity) 101 b = sprandn (n,9,0.1) ; 102 else 103 b = rand (n,9) ; 104 end 105 106 [x1,x2,e1,e2] = testsolve (A,b) ; %#ok 107 108 if (sparsity) 109 b = sprandn (n,9,0.1) + sprandn (n,9,0.1)*1i ; 110 else 111 b = rand (n,9) + rand(n,9)*1i ; 112 end 113 114 b1 = b (:,1) ; 115 116 [x1,x2,e1,e2] = testsolve (A,b1) ; %#ok 117 [x1,x2,e1,e2] = testsolve (A,b) ; %#ok 118 119 end 120 end 121 % catch 122 % fprintf (' failed\n') ; 123 % end 124end 125