⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tridiag_lu.m

📁 LU decomposition routines in matlab
💻 M
字号:
function [c, d, e, iflag] = tridiag_lu( c, d, e);%% TRIDIAG_LU computes the Lu-decomposition of a tridiagonal%    matrix. No pivoting is applied.%% Usage%       [c, d, e, iflag] = tridiag_lu( c, d, e)%% input:%        c:     real(n-1)%               the subdiagonal entries of A %%        d:     real(n)%               the diagonal entries of A %%        e:     real(n-1)%               the superdiagonal entries of A %%%        The matrix is stored as%%               d(1) e(1)%               c(1) d(2) e(2)%                    c(2) d(3) e(3)%                       .    .    .% output:
   %%        c, d, e are overwritten with the LU factors in compact form%               of A%%%        iflag: error flag%               iflag = 0  LU decomposition could be computed and is%                          stored in c, d, e%               iflag = 1  dimension of c, d, e are not correct%               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(c(:),1)+1 | n > size(e(:),1)+1 )   iflag = 1;   returnendfor i = 1:n-1   if( d(i) == 0 )       iflag = i+1;       return   end    c(i)   = c(i) / d(i);   d(i+1) = d(i+1) - c(i)*e(i);end

⌨️ 快捷键说明

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