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
|
function lxtest
%LXTEST test the lsubsolve mexFunction
% Example:
% lxtest
% See also cholmod_test, ltest, ltest2
% Copyright 2013, Timothy A. Davis, http://www.suitesparse.com
rng ('default')
index = ssget ;
%{
f = find (index.posdef & index.amd_lnz > 0) ;
f = setdiff (f, 1425) ; % not really posdef
[ignore i] = sort (index.amd_lnz (f)) ;
f = f (i) ;
%}
f = [ 1440 1438 57 2203 72 2204 60 436 872 873 874 25 61 70 23 220 44 217 ...
69 63 64 315 2 66 76 ] ;
nmat = length (f) ;
for k = 1:nmat
id = f (k) ;
Prob = ssget (id, index)
A = Prob.A ;
n = size (A,1) ;
[LD gunk p] = ldlchol (A) ;
C = A (p,p) ;
[count h parent post Lpattern] = symbfact (C, 'sym', 'lower') ;
if (~isequal (Lpattern, GB_spones_mex (LD)))
error ('!') ;
end
P = sparse (1:n, p, 1) ;
L = speye (n) + tril (LD,-1) ;
D = triu (LD) ;
err = norm (L*D*L' - C, 1) / norm (C, 1) ;
fprintf ('err %g in LDL''-C\n', err) ;
if (err > 1e-12)
error ('!') ;
end
D2 = chol (D) ;
L2 = L*D2 + 1e-50 * GB_spones_mex (L) ;
if (~isequal (GB_spones_mex (L), GB_spones_mex (L2)))
error ('oops') ;
end
err = norm (L2*L2' - C, 1) / norm (C, 1) ;
fprintf ('err %g in LL''-C\n', err) ;
if (err > 1e-12)
error ('!') ;
end
% test lsubsolve
for i = 1:n
b = sparse (i, 1, rand(1), n, 1) ;
[err x1 x2 xset] = ltest2 (LD, L, D, L2, P, p, b, err) ;
if (err > 1e-12)
error ('!') ;
end
end
for trial = 1:100
b = sprand (n, 1, trial/100) ;
[err x1 x2 xset] = ltest2 (LD, L, D, L2, P, p, b, err) ;
if (err > 1e-12)
error ('!') ;
end
end
b = sparse (rand (n,1)) ;
[err x1 x2 xset] = ltest2 (LD, L, D, L2, P, p, b, err) ;
fprintf ('err %g in solves\n', err) ;
if (err > 1e-12)
error ('!') ;
end
end
fprintf ('lxtest: all tests passed\n') ;
|