资源简介
共轭梯度法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
代码片段和文件信息
function x = cg(Ab)
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;
i
评论
共有 条评论