1function test21 2%TEST21 test cholmod2 on diagonal or ill-conditioned matrices 3% Example: 4% test21 5% See also cholmod_test 6 7% Copyright 2007, Timothy A. Davis, http://www.suitesparse.com 8 9fprintf ('=================================================================\n'); 10fprintf ('test21: test cholmod2 on diagonal or ill-conditioned matrices\n') ; 11 12f = [ 13 72 % HB/bcsstm22 14 315 % Bai/mhdb416 15 64 % HB/bcsstm09 16 71 % HB/bcsstm21 17 1207 % Oberwolfach/t2dal_e 18 354 % Boeing/crystm02 19 1211 % Oberwolfach/t3dl_e 20 ]' ; 21 22for i = f 23 24 Prob = ssget (i) %#ok 25 A = Prob.A ; 26 n = size (A,1) ; 27 x = ones (n,2) ; 28 b = A*x ; 29 fprintf ('nnz: %d\n', nnz (A)) ; 30 31 x1 = A\b ; 32 x2 = cholmod2 (A,b) ; 33 34 s = norm (A,1) * norm (x,1) + norm (b,1) ; 35 resid1 = norm (A*x1-b,1) / s ; 36 resid2 = norm (A*x2-b,1) / s ; 37 38 err1 = norm (x-x1,1) ; 39 err2 = norm (x-x2,1) ; 40 41 fprintf ('MATLAB resid %6.1e err %6.1e\n', resid1, err1) ; 42 fprintf ('CHOLMOD resid %6.1e err %6.1e\n', resid2, err2) ; 43 fprintf ('condest %6.1e\n', condest (A)) ; 44 45end 46