共轭梯度法。一种求解数学特定线性方程组Ax=b的数值解的迭代方法。
要求矩阵A对称(symmetric)且正定(positive definite)。
Ax=b是数值求解常见的偏微分方程,可以用Cholesky分解。
当等式左边是稀疏矩阵线性方程组时,Conjugate gradient method更加适用。
另外,该方法也可以用于求解无约束的最优化问题。
对于非对称矩阵,有双共轭梯度法,Biconjugate gradient method。
方法细节:
conjugate gradient method as a direction method
Direct method
when n is too large, using conjugate gradient method as a iterative method
Iterative method
以上这个算法的推论过程还在理解中...(我觉得好难...)
let's look at the example code:
function[x] = conjgrad(A,b,x)
r = b - A*x
p = r
rsold = r' * r
for i = 1:length(b) //size of A
Ap = A * p
alpha = rsold / (p' * Ap) //alpha_k
x = x + alpha * p //x_(k+1) = x_k + alpha_k * p_k
r = r - alpha * Ap //r_(k+1) = r_k - alpha_k * A * p_k
rsnew = r' * r
if sqrt(rsnew) < 1e-10
break;
end
p = r + (rsnew / rsold) * p; //p_(k+1) = r_(k+1) + \beta_k * p_k
rsold = rsnew;
end
end
网友评论