| [Invertf,sigmaP,bP,RelTotalError,AbsTotalError,AbsTruncateError,AbsRoundoffError,LaguerreCoef] =... |
function [Invertf,sigmaP,bP,RelTotalError,AbsTotalError,AbsTruncateError,AbsRoundoffError,LaguerreCoef] =...
wfnWeeksCore(varargin)
%WFNWEEKSCORE The core function for the Weeks' method computations for a single time.
% The outer script selects the appropriate parameters and sends them to this core function.
%
% Use:
% [Invertf,sigmaP,bP,RelTotalError,AbsTotalError,AbsTruncateError,AbsRoundoffError,LaguerreCoef] =...
% wfnweekscore(varargin)
%
% Input:
% (variable inputs)
% 1) FLaplace = a symbolic expression for the Laplace transform space function F(s)
% 2) TimeInput = a single time where f(t) is to be computed
% 3) NLag = the number of terms in the Laguerre expansion
% if 5 inputs
% 4) sigmaP = user defined free parameter sigma in the Weeks method
% 5) bP = user defined free parameter b in the Weeks method
% if 9 inputs
% 4) sigmin = the minimum sigma value for the (sigma,b) search
% 5) sigmax = the maximum sigma value for the (sigma,b) search
% 6) bmax = the maximum b value for the (sigma,b) search
% 7) SearchSwitch = 0-CPU local fminbnd, 1-CPU global, 2-GPU/JACKET global
% 8) tols = the resolution of the s-parameter
% 9) tolb = the resolution of the b-parameter
%
% Output:
% Invertf = numerically computed f(t)
% sigmaP = automatically determined sigma or user defined if an input
% bP = automatically determined b or user defined if an input
% RelTotalError = the estimate relative total error
% AbsTotalError = the estimated absolute total error
% AbsTruncationError = the estimated absolute trunction error
% AbsRoundoffError = the estimated absolute round-off error
% LaguerreCoef = Laguerre polynomial expansion coefficients
%
% Author:
% Patrick Kano, Moysey Brio - 2011
%
% Modification Date [M/D/Y]:
% 03/31/2011 - Initial work
switch nargin
case 5 %input sigma and b parameters input by the user
FLaplace = varargin{1};
TimeInput = varargin{2};
NLag = varargin{3};
sigmaP = varargin{4};
bP = varargin{5};
case 9 %determine the optimal sigma and b parmeters internally
FLaplace = varargin{1};
TimeInput = varargin{2};
NLag = varargin{3};
sigmin = varargin{4};
sigmax = varargin{5};
bmax = varargin{6};
SearchSwitch = varargin{7};
tols = varargin{8};
tolb = varargin{9};
[sigmaP, bP] = wfnParamEst(FLaplace,TimeInput,NLag,sigmin,sigmax,bmax,SearchSwitch,tols,tolb);
otherwise
error('wfnWeeksCore','Incorrect number of inputs, 5 or 9 are required.');
end
%Laguerre polynomial coefficients calculation
LaguerreCoef = wfncpuFFTLagCoef(FLaplace,NLag,sigmaP,bP);
%Clenshaw algorithm to sum the polynomials
Invertf = wfnClenshaw(NLag,TimeInput,sigmaP,bP,LaguerreCoef);
%Estimate the absolute and relative error of the inverted function
[AbsTotalError, AbsTruncateError, AbsRoundoffError] = wfncpuErrorEst(bP,sigmaP,FLaplace,TimeInput,NLag,0);
%Convert from the log base 10 value
AbsTotalError = 10^(AbsTotalError);
AbsTruncateError = 10^(AbsTruncateError);
AbsRoundoffError = 10^(AbsRoundoffError);
RelTotalError = abs(AbsTotalError)/abs(Invertf);
end %function definition
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|