1function lxtest 2%LXTEST test the lsubsolve mexFunction 3% Example: 4% lxtest 5% See also cholmod_test, ltest, ltest2 6 7% Copyright 2013, Timothy A. Davis, http://www.suitesparse.com 8 9rng ('default') 10index = ssget ; 11 12%{ 13f = find (index.posdef & index.amd_lnz > 0) ; 14f = setdiff (f, 1425) ; % not really posdef 15[ignore i] = sort (index.amd_lnz (f)) ; 16f = f (i) ; 17%} 18 19f = [ 1440 1438 57 2203 72 2204 60 436 872 873 874 25 61 70 23 220 44 217 ... 20 69 63 64 315 2 66 76 ] ; 21 22nmat = length (f) ; 23 24for k = 1:nmat 25 id = f (k) ; 26 Prob = ssget (id, index) 27 A = Prob.A ; 28 n = size (A,1) ; 29 [LD gunk p] = ldlchol (A) ; 30 C = A (p,p) ; 31 [count h parent post Lpattern] = symbfact (C, 'sym', 'lower') ; 32 if (~isequal (Lpattern, GB_spones_mex (LD))) 33 error ('!') ; 34 end 35 36 P = sparse (1:n, p, 1) ; 37 38 L = speye (n) + tril (LD,-1) ; 39 D = triu (LD) ; 40 err = norm (L*D*L' - C, 1) / norm (C, 1) ; 41 fprintf ('err %g in LDL''-C\n', err) ; 42 if (err > 1e-12) 43 error ('!') ; 44 end 45 46 D2 = chol (D) ; 47 L2 = L*D2 + 1e-50 * GB_spones_mex (L) ; 48 if (~isequal (GB_spones_mex (L), GB_spones_mex (L2))) 49 error ('oops') ; 50 end 51 err = norm (L2*L2' - C, 1) / norm (C, 1) ; 52 fprintf ('err %g in LL''-C\n', err) ; 53 if (err > 1e-12) 54 error ('!') ; 55 end 56 57 % test lsubsolve 58 for i = 1:n 59 b = sparse (i, 1, rand(1), n, 1) ; 60 [err x1 x2 xset] = ltest2 (LD, L, D, L2, P, p, b, err) ; 61 if (err > 1e-12) 62 error ('!') ; 63 end 64 end 65 66 for trial = 1:100 67 b = sprand (n, 1, trial/100) ; 68 [err x1 x2 xset] = ltest2 (LD, L, D, L2, P, p, b, err) ; 69 if (err > 1e-12) 70 error ('!') ; 71 end 72 end 73 74 b = sparse (rand (n,1)) ; 75 [err x1 x2 xset] = ltest2 (LD, L, D, L2, P, p, b, err) ; 76 fprintf ('err %g in solves\n', err) ; 77 if (err > 1e-12) 78 error ('!') ; 79 end 80end 81 82fprintf ('lxtest: all tests passed\n') ; 83