sor.m
来自「Mathematical Methods by Moor n Stiling.」· M 代码 · 共 23 行
M
23 行
function x = sor(A,x,b,omega)
%
% Produce an updated solution x to Ax = b successive over-relaxation
% A must be Hermitian positive definite
%
% function x = sor(A,x,b)
%
% A = input matrix
% x = initial solution
% b = right-hand side
% omega = relaxation parameter
%
% Output x= updated solution
% Copyright 1999 by Todd K. Moon
[m,n] = size(A); if(n ~= m) error('Error: matrix needs to be square'); end;
D = diag(diag(A)); Cl = tril(A,-1); Cu = triu(A,1);
% the following should be set up and stored if this is used iteratively
omegaQ = D + omega*Cl; % omega * Q
omegaQmA = (1-omega)*D - omega*Cu; % omega * (Q-A)
% The update step:
x = backsub(omegaQ, omegaQmA*x + omega*b);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?