run.m

来自「五点差分型多重网格方法:各种插值算子的比较)」· M 代码 · 共 50 行

M
50
字号
%RUN    Apply a solver to a linear system.
%
%       [X1,RESIDS1,ITS1] = RUN applies a solver to a discretized PDE problem
%       and returns the solution X1, history of residuals RESIDS1, and
%       iteration vector ITS1.

% 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
% April 2004
%
% For some reason, locally generated variables cannot be seen outside the scope of a
% particular function in version 6 unless they have a global reference. This seems to 
% only occur when the newly generated variable is passed as a parameter. I have taken
% locally generated variables throughout MGLab and "bridged" them to their destination
% routines using global references. It's an ugly fix, so maybe someone should come up
% with a more centralized solution.

function [x1,resids1,its1] = run

include_globals
include_bridge_globals
include_flags

show_params; drawnow;

if (generate_matrix)
   [A1,N1] = get_matrix(nx1,ny1);
   generate_matrix = 0;
   multigrid_setup;
end

if (generate_rhs)
   b1 = get_rhs(nx1,ny1);   
   generate_rhs = 0;
end

x0 = zeros(N1,1);

% "bridging" variables to the solve routine
b_in_solve = b1;
A_in_solve = A1;
x0_in_solve = x0;

[x1,resids1,its1] = solve (A1,b1,x0);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?