>> load hwk10 >> % is A symmetric? >> norm(A-A') ??? Error using ==> norm Use norm(full(S)) or norm(S,1) or norm(S,inf). >> norm(A-A',inf) ans = 0 >> p = symmmd(A); >> R = chol(A(p,p)); >> x = R\(R'\b(p)); >> x(p) = x; >> norm(A*x-b) ans = 7.5578e-14 >> >> % type out pcg.m if you want to see an implementation of cg in MATLAB >> x = pcg(A,b,1e-4,1000); pcg converged at iteration 36 to a solution with relative residual 7.4e-05 >> norm(A*x-b) ans = 0.0019 >> x = pcg(A,b,1e-8,1000); pcg converged at iteration 68 to a solution with relative residual 6.8e-09 >> norm(A*x-b) ans = 1.7696e-07 >> >> % should use flops, cputime, but I forgot!! >> >> diary off