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

📄 ludec.m

📁 matlab算法集 matlab算法集
💻 M
字号:
function [x,Delta] = ludec (A,b,eq)
%----------------------------------------------------------------
% Usage:      [x,Delta] = ludec (A,b,eq)
%
% Descripton: Solve the linear algebraic system Ax = b using the
%             LU decomposition method.
%
% Inputs:     A  = n by n coefficeint matrix
%             b  = n by 1 right-hand side vector
%             eq = an optional scaling mode.  If eq is present
%                  the equations are first scaled using 
%                  equilibration.
%
% Outputs:    x     = n by 1 solution vector
%             Delta = determinant of A.  If Delta ~= 0, then
%                     x is a valid solution.
%----------------------------------------------------------------

% Initialize 

   chkvec (b,2,'ludec');
   [n,n] = size(A);
   if (n == 1)
      if (abs(A(1,1)) > eps)
         Delta = A(1,1);
         x = b(1)/A(1,1);
      else
         Delta = 0;
         return
      end
   end

% Prescale using equlibration 

   if (nargin > 1) 
      for i = 1 : n
         a = max(abs(A(i,:)));
         A(i,:) = A(i,:)/a;
         b(i) = b(i)/a;
      end
   end
   
% Solve system by factoring A 

   [L,U,P,Delta] = lufac (A);
   [x,d] = lusub (L,U,P,b);
%----------------------------------------------------------------

⌨️ 快捷键说明

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