| [abd,lda,n,ml,mu,ipvt,det]=sgbdi(abd,lda,n,ml,mu,ipvt,det); |
function [abd,lda,n,ml,mu,ipvt,det]=sgbdi(abd,lda,n,ml,mu,ipvt,det);
%***BEGIN PROLOGUE SGBDI
%***PURPOSE Compute the determinant of a band matrix using the factors
% computed by SGBCO or SGBFA.
%***LIBRARY SLATEC (LINPACK)
%***CATEGORY D3A2
%***TYPE SINGLE PRECISION (SGBDI-S, DGBDI-D, CGBDI-C)
%***KEYWORDS BANDED, DETERMINANT, INVERSE, LINEAR ALGEBRA, LINPACK,
% MATRIX
%***AUTHOR Moler, C. B., (U. of New Mexico)
%***DESCRIPTION
%
% SGBDI computes the determinant of a band matrix
% using the factors computed by SBGCO or SGBFA.
% If the inverse is needed, use SGBSL N times.
%
% On Entry
%
% ABD REAL(LDA, N)
% the output from SBGCO or SGBFA.
%
% LDA INTEGER
% the leading dimension of the array ABD .
%
% N INTEGER
% the order of the original matrix.
%
% ML INTEGER
% number of diagonals below the main diagonal.
%
% MU INTEGER
% number of diagonals above the main diagonal.
%
% IPVT INTEGER(N)
% the pivot vector from SBGCO or SGBFA.
%
% On Return
%
% DET REAL(2)
% determinant of original matrix.
% Determinant = DET(1) * 10.0**DET(2)
% with 1.0 .LE. ABS(DET(1)) .LT. 10.0
% or DET(1) = 0.0 .
%
%***REFERENCES J. J. Dongarra, J. R. Bunch, C. B. Moler, and G. W.
% Stewart, LINPACK Users' Guide, SIAM, 1979.
%***ROUTINES CALLED (NONE)
%***REVISION HISTORY (YYMMDD)
% 780814 DATE WRITTEN
% 890831 Modified array declarations. (WRB)
% 890831 REVISION DATE from Version 3.2
% 891214 Prologue converted to Version 4.0 format. (BAB)
% 900326 Removed duplicate information from DESCRIPTION section.
% (WRB)
% 920501 Reformatted the REFERENCES section. (WRB)
%***end PROLOGUE SGBDI
persistent i m ten ;
ipvt_shape=size(ipvt);ipvt=reshape(ipvt,1,[]);
abd_shape=size(abd);abd=reshape([abd(:).',zeros(1,ceil(numel(abd)./prod([lda])).*prod([lda])-numel(abd))],lda,[]);
%
if isempty(ten), ten=0; end;
if isempty(i), i=0; end;
if isempty(m), m=0; end;
%***FIRST EXECUTABLE STATEMENT SGBDI
m = fix(ml + mu + 1);
det(1) = 1.0e0;
det(2) = 0.0e0;
ten = 10.0e0;
for i = 1 : n;
if( ipvt(i)~=i )
det(1) = -det(1);
end;
det(1) = abd(m,i).*det(1);
if( det(1)==0.0e0 )
break;
end;
if( abs(det(1))>=1.0e0 )
if( abs(det(1))>=ten )
det(1) = det(1)./ten;
det(2) = det(2) + 1.0e0;
goto 60;
end;
else;
det(1) = ten.*det(1);
det(2) = det(2) - 1.0e0;
goto 50;
end;
end;
ipvt_shape=zeros(ipvt_shape);ipvt_shape(:)=ipvt(1:numel(ipvt_shape));ipvt=ipvt_shape;
abd_shape=zeros(abd_shape);abd_shape(:)=abd(1:numel(abd_shape));abd=abd_shape;
end
%DECK SGBFA
|
|