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