Functions for nonlinear minimization.
Constructor | Description |
Full Usage:
NLFit()
|
|
Static member | Description |
Full Usage:
NLFit.ComputeCovariances(fcn, x, n, m, covar, sumchisq, sigmasq)
Parameters:
LMFunction
-
The function that was to minimize.
x : float[]
-
Parameter vector.
n : int
-
First dimension of the parameter vector.
m : int
-
Second dimension of the parameter vector.
covar : float[]
-
Array to hold the covariance matrix. Must be of dimension m*n.
sumchisq : byref<float>
-
Outputs the sum of chi squared.
sigmasq : byref<float>
-
Sigma squared.
Returns: int
|
This will compute the covariances at a given parameter set xvec.
|
Full Usage:
NLFit.LevenbergMarquardtFit(fcn, xvec, fvec, tol, info)
Parameters:
LMFunction
-
The user supplied function which provides the values to minimize.
xvec : float[]
-
Array of length n containing the parameter vector. On input x must contain
an initial estimate of the solution vector. On output x
contains the final estimate of the solution vector.
fvec : float[]
-
Output array of length m which contains the functions evaluated at the output x.
tol : float
-
Nonnegative input variable. Termination occurs
when the algorithm estimates either that the relative
error in the sum of squares is at most tol or that
the relative error between x and the solution is at
most tol.
info : byref<int>
-
Info is an integer output variable. If the user has
terminated execution, info is set to the (negative)
value of iflag. See description of fcn. Otherwise,
info is set as follows:
info = 0 improper input parameters.
info = 1 algorithm estimates that the relative error
in the sum of squares is at most tol.
info = 2 algorithm estimates that the relative error
between x and the solution is at most tol.
info = 3 conditions for info = 1 and info = 2 both hold.
info = 4 fvec is orthogonal to the columns of the
Jacobian to machine precision.
info = 5 number of calls to fcn has reached or
exceeded 200*(n+1).
info = 6 tol is too small. No further reduction in
the sum of squares is possible.
info = 7 tol is too small. No further improvement in
the approximate solution x is possible.
|
The purpose of LevenbergMarquardtFit is to minimize the sum of the squares of m nonlinear functions in n variables by a modification of the Levenberg-Marquardt algorithm. This is done by using the more general least-squares solver below. The user must provide a subroutine which calculates the functions. The Jacobian is then calculated by a forward-difference approximation. This is the most easy-to-use interface with the smallest number of arguments. If you need more control over the minimization process and auxilliary storage allocation you should use one of the interfaces described below.
|
Full Usage:
NLFit.LevenbergMarquardtFit(fcn, xvec, fvec, tol, info, iwa, diag, fjac, ipvt, qtf, wa1, wa2, wa3, wa4)
Parameters:
LMFunction
-
The user supplied function which provides the values to minimize.
xvec : float[]
-
Array of length n containing the parameter vector. On input x must contain
an initial estimate of the solution vector. On output x
contains the final estimate of the solution vector.
fvec : float[]
-
Output array of length m which contains the functions evaluated at the output x.
tol : float
-
Nonnegative input variable. Termination occurs
when the algorithm estimates either that the relative
error in the sum of squares is at most tol or that
the relative error between x and the solution is at
most tol.
info : byref<int>
-
Info is an integer output variable. If the user has
terminated execution, info is set to the (negative)
value of iflag. See description of fcn. Otherwise,
info is set as follows:
info = 0 improper input parameters.
info = 1 algorithm estimates that the relative error
in the sum of squares is at most tol.
info = 2 algorithm estimates that the relative error
between x and the solution is at most tol.
info = 3 conditions for info = 1 and info = 2 both hold.
info = 4 fvec is orthogonal to the columns of the
Jacobian to machine precision.
info = 5 number of calls to fcn has reached or
exceeded 200*(n+1).
info = 6 tol is too small. No further reduction in
the sum of squares is possible.
info = 7 tol is too small. No further improvement in
the approximate solution x is possible.
iwa : int[]
-
Integer working array of length n.
diag : float[]
-
fjac : float[]
-
ipvt : int[]
-
qtf : float[]
-
wa1 : float[]
-
wa2 : float[]
-
wa3 : float[]
-
wa4 : float[]
-
|
The purpose of LevenbergMarquardtFit is to minimize the sum of the squares of m nonlinear functions in n variables by a modification of the Levenberg-Marquardt algorithm. This is done by using the more general least-squares solver below. The user must provide a subroutine which calculates the functions. The Jacobian is then calculated by a forward-difference approximation. This is the most easy-to-use interface with the smallest number of arguments. If you need more control over the minimization process and auxilliary storage allocation you should use one of the interfaces described below.
|
Full Usage:
NLFit.LevenbergMarquardtFit(fcn, xvec, fvec, ftol, xtol, gtol, maxfev, epsfcn, diag, mode, factor, nprint, info, nfev, fjac, ldfjac, ipvt, qtf, wa1, wa2, wa3, wa4)
Parameters:
LMFunction
xvec : float[]
fvec : float[]
ftol : float
xtol : float
gtol : float
maxfev : int
epsfcn : float
diag : float[]
mode : int
factor : float
nprint : int
info : byref<int>
nfev : byref<int>
fjac : float[]
ldfjac : int
ipvt : int[]
qtf : float[]
wa1 : float[]
wa2 : float[]
wa3 : float[]
wa4 : float[]
|
|
Full Usage:
NLFit.enorm (n, x)
Parameters:
int
-
n is a positive integer input variable.
x : float[]
-
x is an input array of length n.
Returns: float
Euclidean norm of x.
|
given an n-vector x, this function calculates the euclidean norm of x. the euclidean norm is computed by accumulating the sum of squares in three different sums. the sums of squares for the small and large components are scaled so that no overflows occur. non-destructive underflows are permitted. underflows and overflows do not occur in the computation of the unscaled sum of squares for the intermediate components. the definitions of small, intermediate and large components depend on two constants, rdwarf and rgiant. the main restrictions on these constants are that rdwarf**2 not underflow and rgiant**2 not overflow. the constants given here are suitable for every known computer. burton s. garbow, kenneth e. hillstrom, jorge j. more
|
Full Usage:
NLFit.enorm (n, x, startindex)
Parameters:
int
-
A positive integer input variable of the number of elements to process.
x : float[]
-
An input array of length n.
startindex : int
-
The index of the first element in x to process.
Returns: float
The euclidian norm of the vector of length n, i.e. the square root of the sum of squares of the elements.
|
Given an n-vector x, this function calculates the euclidean norm of x. the euclidean norm is computed by accumulating the sum of squares in three different sums. the sums of squares for the small and large components are scaled so that no overflows occur. non-destructive underflows are permitted. underflows and overflows do not occur in the computation of the unscaled sum of squares for the intermediate components. the definitions of small, intermediate and large components depend on two constants, rdwarf and rgiant. the main restrictions on these constants are that rdwarf**2 not underflow and rgiant**2 not overflow. the constants given here are suitable for every known computer. burton s. garbow, kenneth e. hillstrom, jorge j. more
|
Full Usage:
NLFit.fdjac2 (fcn, m, n, x, fvec, fjac, ldfjac, iflag, epsfcn, wa)
Parameters:
LMFunction
-
User-supplied subroutine which calculates the functions
m : int
-
m is a positive integer input variable set to the number of functions.
n : int
-
n is a positive integer input variable set to the number of variables. n must not exceed m.
x : float[]
-
x is an input array of length n containing the parameters.
fvec : float[]
-
fvec is an input array of length m which must contain the functions evaluated at x.
fjac : float[]
-
fjac is an output m by n array which contains the approximation to the Jacobian matrix evaluated at x.
ldfjac : int
-
ldfjac is a positive integer input variable not less than m which specifies the leading dimension of the array fjac.
iflag : byref<int>
-
iflag is an integer variable which can be used to terminate the execution of fdjac2. see description of fcn.
epsfcn : float
-
epsfcn is an input variable used in determining a suitable
step length for the forward-difference approximation. this
approximation assumes that the relative errors in the
functions are of the order of epsfcn. if epsfcn is less
than the machine precision, it is assumed that the relative
errors in the functions are of the order of the machine
precision.
wa : float[]
-
wa is a work array of length m.
|
This subroutine computes a forward-difference approximation to the m by n Jacobian matrix associated with a specified problem of m functions in n variables.
|
Full Usage:
NLFit.lmpar (n, r, ldr, ipvt, diag, qtb, delta, par, x, sdiag, wa1, wa2)
Parameters:
int
r : float[]
ldr : int
ipvt : int[]
diag : float[]
qtb : float[]
delta : float
par : byref<float>
x : float[]
sdiag : float[]
wa1 : float[]
wa2 : float[]
|
|
Full Usage:
NLFit.qrsolve (n, r, ldr, ipvt, diag, qtb, x, sdiag, wa)
Parameters:
int
r : float[]
ldr : int
ipvt : int[]
diag : float[]
qtb : float[]
x : float[]
sdiag : float[]
wa : float[]
|
|
Full Usage:
NLFit.sqr x
Parameters:
float
Returns: float
|
|