Matlab diary from CS 290H, Wednesday, May 07, 2014 This is /Users/gilbert/Documents/CS290hSpring2014/Matlab/startup.m Starting diary file diary-07-May-2014.txt > A = grid5(10); > whos Name Size Bytes Class Attributes A 100x100 8168 double sparse > spy(A) > A A = (1,1) 4 (2,1) -1 (11,1) -1 (1,2) -1 (2,2) 4 (3,2) -1 (12,2) -1 (2,3) -1 (3,3) 4 (4,3) -1 ... (100,100) 4 > condest(A) ans = 69.8634 > e = eigs(A,5,'SM') e = 0.7713 0.6350 0.3985 0.3985 0.1620 > f = eigs(A,5,'LM') f = 7.8380 7.6015 7.6015 7.3650 7.2287 > n = length(A) n = 100 > b = rand(n,1); > x = A \ b; > norm(A*x-b) ans = 2.0146e-14 help pcg PCG Preconditioned Conjugate Gradients Method. X = PCG(A,B) attempts to solve the system of linear equations A*X=B for X. The N-by-N coefficient matrix A must be symmetric and positive definite and the right hand side column vector B must have length N. ... X = PCG(A,B,TOL) specifies the tolerance of the method. If TOL is [] then PCG uses the default, 1e-6. X = PCG(A,B,TOL,MAXIT) specifies the maximum number of iterations. If MAXIT is [] then PCG uses the default, min(N,20). X = PCG(A,B,TOL,MAXIT,M) and X = PCG(A,B,TOL,MAXIT,M1,M2) use symmetric positive definite preconditioner M or M=M1*M2 and effectively solve the system inv(M)*A*X = inv(M)*B for X. If M is [] then a preconditioner is not applied. M may be a function handle MFUN returning M\X. ... [X,FLAG,RELRES,ITER,RESVEC] = PCG(A,B,...) also returns a vector of the estimated residual norms at each iteration including NORM(B-A*X0). ... > [x, flag, relres, iter, resvec] = pcg(A,b,1e-8,n); > iter iter = 32 > norm(A*x-b) ans = 3.5636e-08 > semilogy(resvec / resvec(1)),hold on, shg > what M-files in the current directory /Users/gilbert/Documents/CS290hSpring2014/Matlab/graphs bfslevels eigsvdgui plotccd btermatch gploth plotdegs ccoeff matstats rmat clustereg misluby rmatstats dhist misseq MAT-files in the current directory /Users/gilbert/Documents/CS290hSpring2014/Matlab/graphs G3_circuit fourvtx PGPgiantcompo graphs bcsstk08 matlab circuit_3 meshes clusters samplegraphs coAuthorsDBLP dodec > clear > load bcsstk08 > whos Name Size Bytes Class Attributes BCSSTK08 1074x1074 215976 double sparse M 1x1 216670 struct > A = BCSSTK08; > n = length(A) n = 1074 > b = rand(n,1); > [x, flag, relres, iter, resvec] = pcg(A,b,1e-8,n); > semilogy(resvec / resvec(1)),shg > [x, flag, relres, iter, resvec] = pcg(A,b,1e-8,10*n); > semilogy(resvec / resvec(1)),shg > condest(A) ans = 4.7262e+07 > clear > load PGPgiantcompo > whos Name Size Bytes Class Attributes Problem 1x1 1037746 struct > A = Problem.A; > whos Name Size Bytes Class Attributes A 10680x10680 863560 double sparse Problem 1x1 1037746 struct > A = laplacian(A); > max(sum(A)) ans = All zero sparse: 1-by-1 > nnz(A-A') ans = 0 > max(components(A)) ans = 1 > n = length(A) n = 10680 > b = rand(n,1); > b = b - mean(b); > sum(b) ans = -6.9657e-12 > [x, flag, relres, iter, resvec] = pcg(A,b,1e-8,n); > iter iter = 832 > semilogy(resvec / resvec(1)),shg > norm(A*x-b) ans = 2.9539e-07 > sum(x) ans = -5.3072e-09 > sum(b) ans = -6.9657e-12 > clear > load bcsstk08 > A = BCSSTK08; > n = length(A) n = 1074 > b = rand(n,1); > [x, flag, relres, iter, resvec] = pcg(A,b,1e-8,n); > semilogy(resvec / resvec(1)),hold on, shg > R = cholinc(A,'0'); > [x, flag, relres, iter, resvec] = pcg(A,b,1e-8,n,R',R); > semilogy(resvec / resvec(1),'r');shg > diary off