📄 tridiag_lu_sl.m
字号:
function [b, iflag] = tridiag_lu_sl( c, d, e, b);%% TRIDIAG_LU_SL solves a tridiagonal linear system A x = b,% using the LU decomposition of A computed by TRIDIAG_LU.%% Usage% [b, iflag] = tridiag_lu_sl( c, d, e, b)%% input:% d, e contain the LU factors in compact form% of A as computed by tridiag_lu%% b right hand side vector% output:
%% b overwritten with the solution of the system if iflag = 0.%%% iflag: error flag% iflag = 0 solution could be computed and is% stored in b% iflag = 1 dimension of b, and A are not compatible% iflag > 1 zero diagonal element detected in step iflag+1%%%% Matthias Heinkenschloss% Feb 6, 2001iflag = 0;% get size of A and check dimensionsn = size(d(:),1);if ( n ~= size(b(:),1) ) iflag = 1; returnend% solve L y = b (overwrite b with the solution)for i = 2:n b(i) = b(i) - c(i-1)*b(i-1);end% solve U x = y (overwrite b with the solution)b(n) = b(n) / d(n);for i = n-1:-1:1 b(i) = (b(i) - e(i)*b(i+1)) / d(i);end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -