1function test20 2%TEST20 test symbfact2, cholmod2, and lu on a few large matrices 3% Example: 4% test20 5% See also cholmod_test 6 7% Copyright 2007, Timothy A. Davis, http://www.suitesparse.com 8 9fprintf ('=================================================================\n'); 10fprintf ('test20: test symbfact2, cholmod2, and lu on a few large matrices\n') ; 11 12unsym = [409 899 901 291 827] ; %#ok 13spd = [813 817] ; 14% f = [ unsym spd ] ; 15f = spd ; 16spparms ('spumoni',0) ; 17 18for i = f 19 Prob = ssget (i) %#ok 20 A = Prob.A ; 21 clear Prob ; 22 n = size (A,1) ; 23 b = A*ones (n,1) ; 24 if (any (i == spd)) 25 p = amd2 (A) ; 26 count = symbfact2 (A (p,p)) ; 27 count2 = symbfact (A (p,p)) ; 28 if (any (count ~= count2)) 29 error ('!') ; 30 end 31 fl = sum (count.^2) ; 32 lnz = sum (count) ; 33 unz = lnz ; 34 tic 35 x = cholmod2 (A,b) ; 36 t = toc ; 37 else 38 % spparms ('spumoni',2) ; 39 [L, U, P, Q] = lu (A) ; %#ok 40 % fl = luflop (L,U) ; 41 Lnz = full (sum (spones (L))) - 1 ; 42 Unz = full (sum (spones (U')))' - 1 ; 43 fl = 2*Lnz*Unz + sum (Lnz) ; 44 lnz = nnz(L) ; 45 unz = nnz(U) ; 46 tic 47 x=A\b ; 48 t = toc ; 49 end 50 err = norm (A*x-b,1) ; 51 clear L U P Q A x b 52 fprintf ('lnz %d unz %d nnz(L+U) %d fl %g gflop %g\n t %g err %e\n', ... 53 lnz, unz, lnz+unz-n, fl, 1e-9*fl/t, t, err) ; 54 % pause 55end 56 57