📄 wmg_cycle.m
字号:
%WMG_CYCLE W-Cycle algorithm.
%
% U_OUT = WMG_CYCLE(LEVEL, B, U_IN) uses the W-cycle to recursively
% solve the linear system AX=B at the given level. If the optional
% starting value U_IN is not passed then U_IN is set to 0's.
%
% James Bordner and Faisal Saied
% Department of Computer Science
% University of Illinois at Urbana-Champaign
% 10 April 1995
% Modified for Matlab Version 6 Compatability
% Ryan McKenzie
% University of Kentucky Center for Computational Sciences
% May 2004
%
% Minor changes made in determining if we are on the coursest level currently.
function u_out = wmg_cycle(level, b, u_in)
% Use the zero vector for u_in as the default
if nargin == 2,
u_in = zeros(size(b));
end
C_level=coarsest;
if level==C_level
u_out = coarse_grid_solve(level, b);
else
u = smooth(level, b, u_in, 'pre');
r = residual(level, b, u);
b_c = restrict(level, r);
u_c = wmg_cycle(level+1, b_c);
if (level < coarsest(level)),
u_c = wmg_cycle(level+1, b_c, u_c);
end
correct = interpolate(level, u_c);
u = u + correct;
u_out = smooth(level, b, u, 'post');
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -