如何在Cholesky方法的解决方案阶段中推断替换算法前后?
如何比较函数choleskiSol
?
这是choleskisol
function x = choleskiSol(L,b)
% Solves [L][L’]{x} = {b}
% USAGE: x = choleskiSol(L,b)
n = length(b);
if size(b,2) > 1
b = b’;
end % {b} must be column vector
for k = 1:n % Solution of [L]{y} = {b}
b(k) = (b(k) - dot(L(k,1:k-1),b(1:k-1)’))/L(k,k);
end
for k = n:-1:1 % Solution of {L}’{x} = {y}
b(k) = (b(k) - dot(L(k+1:n,k),b(k+1:n)))/L(k,k);
end
x = b;
答案 0 :(得分:2)
matlab中的标准Cholesky分解(chol(A))将对称(正定)矩阵A分解为上三角形。要求求线性方程组,必须简单地采用上三角形,并通过后向替换来求解。这将产生系统的变量值。
在matlab中用参数矩阵A和输出向量B完成解决方案:
L = chol(A); % A must be sym and det(A) > 0
x = (L \ (L' \ b)); % L' is lower-triangular