文件名称:共轭梯度法matlab程序
文件大小:304B
文件格式:NONE
更新时间:2012-05-03 18:29:50
共轭梯度法
共轭梯度法matlab程序 function x = cg(A,b) tol=1e-10; r = b + A*b; w = -r; z = A*w; s = w'*z; t = (r'*w)/s; x = -b + t*w; for k = 1:numel(b); r = r - t*z; if( norm(r) < tol ) return; end B = (r'*z)/s; w = -r + B*w; z = A*w; s = w'*z; t = (r'*w)/s; x = x + t*w; end