gee_its_simple.m

来自「The "GEE! It s Simple" package illustrat」· M 代码 · 共 40 行

M
40
字号
function [x, rcnd] = gee_its_simple (A, b)%GEE_ITS_SIMPLE solves A*x=b using a Gaussian Elimination Example (it's simple!)% For details on the algorithm used (Gaussian elimination with partial% pivoting), see gee_its_simple_factorize, gee_its_simple_forwardsolve,% and gee_its_simple_backsolve.%% Example:%%   x = gee_its_simple (A,b) ;%   [x,rcnd] = gee_its_simple (A,b) ;%%   % which is the same as:%   x = A\b ;%%   % or using LU:%   [L U p] = lu (A) ;%   x = U \ (L \ (b (p,:))) ;%   rcnd = min (abs (diag (U))) / max (abs (diag (U))) ;%% See also: lu, mldivide, rcond, gee_its_short% Copyright 2007, Timothy A. Davis.% http://www.cise.ufl.edu/research/sparse% check inputsif (nargin ~= 2 | nargout > 2)                                              %#ok    error ('Usage: [x,rcnd] = gee_its_simple (A,b)') ;end% ensure A is square, and that A and b have the same number of rowsgee_its_simple_check (A, 'A', b) ;% LU factorization, using Gaussian Elimination with partial pivoting, same as% [L,U,p] = lu (A) ; rcnd = rcond (A) ; except return L and U in one matrix LU.[LU p rcnd] = gee_its_simple_factorize (A) ;% forward/backsolve, same as x = U \ (L \ b (p,:))x = gee_its_simple_backsolve (LU, gee_its_simple_forwardsolve (LU, b (p,:))) ;

⌨️ 快捷键说明

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