| [initdsresult,os,nos,eta]=initds(os,nos,eta); |
function [initdsresult,os,nos,eta]=initds(os,nos,eta);
initdsresult=[];
persistent err i ii initds ;
if isempty(err), err=0; end;
if isempty(i), i=0; end;
if isempty(ii), ii=0; end;
if isempty(initdsresult), initdsresult=0; end;
%***BEGIN PROLOGUE INITDS
%***PURPOSE Determine the number of terms needed in an orthogonal
% polynomial series so that it meets a specified accuracy.
%***LIBRARY SLATEC (FNLIB)
%***CATEGORY C3A2
%***TYPE doubleprecision (INITS-S, INITDS-D)
%***KEYWORDS CHEBYSHEV, FNLIB, INITIALIZE, ORTHOGONAL POLYNOMIAL,
% ORTHOGONAL SERIES, SPECIAL FUNCTIONS
%***AUTHOR Fullerton, W., (LANL)
%***DESCRIPTION
%
% Initialize the orthogonal series, represented by the array OS, so
% that INITDS is the number of terms needed to insure the error is no
% larger than ETA. Ordinarily, ETA will be chosen to be one-tenth
% machine precision.
%
% Input Arguments --
% OS doubleprecision array of NOS coefficients in an orthogonal
% series.
% NOS number of coefficients in OS.
% ETA single precision scalar containing requested accuracy of
% series.
%
%***REFERENCES (NONE)
%***ROUTINES CALLED XERMSG
%***REVISION HISTORY (YYMMDD)
% 770601 DATE WRITTEN
% 890531 Changed all specific intrinsics to generic. (WRB)
% 890831 Modified array declarations. (WRB)
% 891115 Modified error message. (WRB)
% 891115 REVISION DATE from Version 3.2
% 891214 Prologue converted to Version 4.0 format. (BAB)
% 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
%***end PROLOGUE INITDS
os_shape=size(os);os=reshape(os,1,[]);
%***FIRST EXECUTABLE STATEMENT INITDS
if( nos<1 )
xermsg('SLATEC','INITDS','Number of coefficients is less than 1',2,1);
end;
%
err = 0.;
for ii = 1 : nos;
i = fix(nos + 1 - ii);
err = err + abs(real(os(i)));
if( err>eta )
break;
end;
end;
%
if( i==nos )
xermsg('SLATEC','INITDS','Chebyshev series too short for specified accuracy',1,1);
end;
initdsresult = fix(i);
%
os_shape=zeros(os_shape);os_shape(:)=os(1:numel(os_shape));os=os_shape;
csnil=dbstack(1); csnil=csnil(1).name(1)~='@';
if csnil&&~isempty(inputname(1)), assignin('caller','FUntemp',os); evalin('caller',[inputname(1),'=FUntemp;']); end
if csnil&&~isempty(inputname(2)), assignin('caller','FUntemp',nos); evalin('caller',[inputname(2),'=FUntemp;']); end
if csnil&&~isempty(inputname(3)), assignin('caller','FUntemp',eta); evalin('caller',[inputname(3),'=FUntemp;']); end
end
%DECK INITS
|
|