mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-12 11:49:02 +08:00
move Parameters as a class member, simplify calling sequence. Convenience
methods from minpack ( "*1()" ) get their original name back : they are only useful when porting, anyway. Still, i prefer to keep them.
This commit is contained in:
parent
c1be96967e
commit
458947af5e
@ -33,48 +33,44 @@ public:
|
|||||||
Scalar epsfcn;
|
Scalar epsfcn;
|
||||||
};
|
};
|
||||||
|
|
||||||
Status solve(
|
Status hybrj1(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Scalar tol = ei_sqrt(epsilon<Scalar>())
|
const Scalar tol = ei_sqrt(epsilon<Scalar>())
|
||||||
);
|
);
|
||||||
|
|
||||||
Status solveInit(
|
Status solveInit(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode=1
|
const int mode=1
|
||||||
);
|
);
|
||||||
Status solveOneStep(
|
Status solveOneStep(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode=1
|
const int mode=1
|
||||||
);
|
);
|
||||||
Status solve(
|
Status solve(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode=1
|
const int mode=1
|
||||||
);
|
);
|
||||||
|
|
||||||
Status solveNumericalDiff(
|
Status hybrd1(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Scalar tol = ei_sqrt(epsilon<Scalar>())
|
const Scalar tol = ei_sqrt(epsilon<Scalar>())
|
||||||
);
|
);
|
||||||
|
|
||||||
Status solveNumericalDiffInit(
|
Status solveNumericalDiffInit(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode=1
|
const int mode=1
|
||||||
);
|
);
|
||||||
Status solveNumericalDiffOneStep(
|
Status solveNumericalDiffOneStep(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode=1
|
const int mode=1
|
||||||
);
|
);
|
||||||
Status solveNumericalDiff(
|
Status solveNumericalDiff(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode=1
|
const int mode=1
|
||||||
);
|
);
|
||||||
|
|
||||||
|
void resetParameters(void) { parameters = Parameters(); }
|
||||||
|
Parameters parameters;
|
||||||
Matrix< Scalar, Dynamic, 1 > fvec;
|
Matrix< Scalar, Dynamic, 1 > fvec;
|
||||||
Matrix< Scalar, Dynamic, Dynamic > fjac;
|
Matrix< Scalar, Dynamic, Dynamic > fjac;
|
||||||
Matrix< Scalar, Dynamic, 1 > R;
|
Matrix< Scalar, Dynamic, 1 > R;
|
||||||
@ -105,24 +101,23 @@ private:
|
|||||||
|
|
||||||
template<typename FunctorType, typename Scalar>
|
template<typename FunctorType, typename Scalar>
|
||||||
typename HybridNonLinearSolver<FunctorType,Scalar>::Status
|
typename HybridNonLinearSolver<FunctorType,Scalar>::Status
|
||||||
HybridNonLinearSolver<FunctorType,Scalar>::solve(
|
HybridNonLinearSolver<FunctorType,Scalar>::hybrj1(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Scalar tol
|
const Scalar tol
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
n = x.size();
|
n = x.size();
|
||||||
Parameters parameters;
|
|
||||||
|
|
||||||
/* check the input parameters for errors. */
|
/* check the input parameters for errors. */
|
||||||
if (n <= 0 || tol < 0.)
|
if (n <= 0 || tol < 0.)
|
||||||
return ImproperInputParameters;
|
return ImproperInputParameters;
|
||||||
|
|
||||||
|
resetParameters();
|
||||||
parameters.maxfev = 100*(n+1);
|
parameters.maxfev = 100*(n+1);
|
||||||
parameters.xtol = tol;
|
parameters.xtol = tol;
|
||||||
diag.setConstant(n, 1.);
|
diag.setConstant(n, 1.);
|
||||||
return solve(
|
return solve(
|
||||||
x,
|
x,
|
||||||
parameters,
|
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -131,7 +126,6 @@ template<typename FunctorType, typename Scalar>
|
|||||||
typename HybridNonLinearSolver<FunctorType,Scalar>::Status
|
typename HybridNonLinearSolver<FunctorType,Scalar>::Status
|
||||||
HybridNonLinearSolver<FunctorType,Scalar>::solveInit(
|
HybridNonLinearSolver<FunctorType,Scalar>::solveInit(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode
|
const int mode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -182,7 +176,6 @@ template<typename FunctorType, typename Scalar>
|
|||||||
typename HybridNonLinearSolver<FunctorType,Scalar>::Status
|
typename HybridNonLinearSolver<FunctorType,Scalar>::Status
|
||||||
HybridNonLinearSolver<FunctorType,Scalar>::solveOneStep(
|
HybridNonLinearSolver<FunctorType,Scalar>::solveOneStep(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode
|
const int mode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -404,13 +397,12 @@ template<typename FunctorType, typename Scalar>
|
|||||||
typename HybridNonLinearSolver<FunctorType,Scalar>::Status
|
typename HybridNonLinearSolver<FunctorType,Scalar>::Status
|
||||||
HybridNonLinearSolver<FunctorType,Scalar>::solve(
|
HybridNonLinearSolver<FunctorType,Scalar>::solve(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode
|
const int mode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Status status = solveInit(x, parameters, mode);
|
Status status = solveInit(x, mode);
|
||||||
while (status==Running)
|
while (status==Running)
|
||||||
status = solveOneStep(x, parameters, mode);
|
status = solveOneStep(x, mode);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,25 +410,24 @@ HybridNonLinearSolver<FunctorType,Scalar>::solve(
|
|||||||
|
|
||||||
template<typename FunctorType, typename Scalar>
|
template<typename FunctorType, typename Scalar>
|
||||||
typename HybridNonLinearSolver<FunctorType,Scalar>::Status
|
typename HybridNonLinearSolver<FunctorType,Scalar>::Status
|
||||||
HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiff(
|
HybridNonLinearSolver<FunctorType,Scalar>::hybrd1(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Scalar tol
|
const Scalar tol
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
n = x.size();
|
n = x.size();
|
||||||
Parameters parameters;
|
|
||||||
|
|
||||||
/* check the input parameters for errors. */
|
/* check the input parameters for errors. */
|
||||||
if (n <= 0 || tol < 0.)
|
if (n <= 0 || tol < 0.)
|
||||||
return ImproperInputParameters;
|
return ImproperInputParameters;
|
||||||
|
|
||||||
|
resetParameters();
|
||||||
parameters.maxfev = 200*(n+1);
|
parameters.maxfev = 200*(n+1);
|
||||||
parameters.xtol = tol;
|
parameters.xtol = tol;
|
||||||
|
|
||||||
diag.setConstant(n, 1.);
|
diag.setConstant(n, 1.);
|
||||||
return solveNumericalDiff(
|
return solveNumericalDiff(
|
||||||
x,
|
x,
|
||||||
parameters,
|
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -445,16 +436,13 @@ template<typename FunctorType, typename Scalar>
|
|||||||
typename HybridNonLinearSolver<FunctorType,Scalar>::Status
|
typename HybridNonLinearSolver<FunctorType,Scalar>::Status
|
||||||
HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiffInit(
|
HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiffInit(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode
|
const int mode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
n = x.size();
|
n = x.size();
|
||||||
|
|
||||||
int nsub = parameters.nb_of_subdiagonals;
|
if (parameters.nb_of_subdiagonals<0) parameters.nb_of_subdiagonals= n-1;
|
||||||
int nsup = parameters.nb_of_superdiagonals;
|
if (parameters.nb_of_superdiagonals<0) parameters.nb_of_superdiagonals= n-1;
|
||||||
if (nsub<0) nsub= n-1;
|
|
||||||
if (nsup<0) nsup= n-1;
|
|
||||||
|
|
||||||
wa1.resize(n); wa2.resize(n); wa3.resize(n); wa4.resize(n);
|
wa1.resize(n); wa2.resize(n); wa3.resize(n); wa4.resize(n);
|
||||||
qtf.resize(n);
|
qtf.resize(n);
|
||||||
@ -472,7 +460,7 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiffInit(
|
|||||||
|
|
||||||
/* check the input parameters for errors. */
|
/* check the input parameters for errors. */
|
||||||
|
|
||||||
if (n <= 0 || parameters.xtol < 0. || parameters.maxfev <= 0 || nsub< 0 || nsup< 0 || parameters.factor <= 0. )
|
if (n <= 0 || parameters.xtol < 0. || parameters.maxfev <= 0 || parameters.nb_of_subdiagonals< 0 || parameters.nb_of_superdiagonals< 0 || parameters.factor <= 0. )
|
||||||
return ImproperInputParameters;
|
return ImproperInputParameters;
|
||||||
if (mode == 2)
|
if (mode == 2)
|
||||||
for (int j = 0; j < n; ++j)
|
for (int j = 0; j < n; ++j)
|
||||||
@ -502,22 +490,19 @@ template<typename FunctorType, typename Scalar>
|
|||||||
typename HybridNonLinearSolver<FunctorType,Scalar>::Status
|
typename HybridNonLinearSolver<FunctorType,Scalar>::Status
|
||||||
HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiffOneStep(
|
HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiffOneStep(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode
|
const int mode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int i, j, l, iwa[1];
|
int i, j, l, iwa[1];
|
||||||
jeval = true;
|
jeval = true;
|
||||||
int nsub = parameters.nb_of_subdiagonals;
|
if (parameters.nb_of_subdiagonals<0) parameters.nb_of_subdiagonals= n-1;
|
||||||
int nsup = parameters.nb_of_superdiagonals;
|
if (parameters.nb_of_superdiagonals<0) parameters.nb_of_superdiagonals= n-1;
|
||||||
if (nsub<0) nsub= n-1;
|
|
||||||
if (nsup<0) nsup= n-1;
|
|
||||||
|
|
||||||
/* calculate the jacobian matrix. */
|
/* calculate the jacobian matrix. */
|
||||||
|
|
||||||
if (ei_fdjac1(functor, x, fvec, fjac, nsub, nsup, parameters.epsfcn) <0)
|
if (ei_fdjac1(functor, x, fvec, fjac, parameters.nb_of_subdiagonals, parameters.nb_of_superdiagonals, parameters.epsfcn) <0)
|
||||||
return UserAksed;
|
return UserAksed;
|
||||||
nfev += std::min(nsub+ nsup+ 1, n);
|
nfev += std::min(parameters.nb_of_subdiagonals+parameters.nb_of_superdiagonals+ 1, n);
|
||||||
|
|
||||||
/* compute the qr factorization of the jacobian. */
|
/* compute the qr factorization of the jacobian. */
|
||||||
|
|
||||||
@ -728,13 +713,12 @@ template<typename FunctorType, typename Scalar>
|
|||||||
typename HybridNonLinearSolver<FunctorType,Scalar>::Status
|
typename HybridNonLinearSolver<FunctorType,Scalar>::Status
|
||||||
HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiff(
|
HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiff(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode
|
const int mode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Status status = solveNumericalDiffInit(x, parameters, mode);
|
Status status = solveNumericalDiffInit(x, mode);
|
||||||
while (status==Running)
|
while (status==Running)
|
||||||
status = solveNumericalDiffOneStep(x, parameters, mode);
|
status = solveNumericalDiffOneStep(x, mode);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,69 +36,62 @@ public:
|
|||||||
Scalar epsfcn;
|
Scalar epsfcn;
|
||||||
};
|
};
|
||||||
|
|
||||||
Status minimize(
|
Status lmder1(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Scalar tol = ei_sqrt(epsilon<Scalar>())
|
const Scalar tol = ei_sqrt(epsilon<Scalar>())
|
||||||
);
|
);
|
||||||
|
|
||||||
Status minimize(
|
Status minimize(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode=1
|
const int mode=1
|
||||||
);
|
);
|
||||||
Status minimizeInit(
|
Status minimizeInit(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode=1
|
const int mode=1
|
||||||
);
|
);
|
||||||
Status minimizeOneStep(
|
Status minimizeOneStep(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode=1
|
const int mode=1
|
||||||
);
|
);
|
||||||
|
|
||||||
Status minimizeNumericalDiff(
|
Status lmdif1(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Scalar tol = ei_sqrt(epsilon<Scalar>())
|
const Scalar tol = ei_sqrt(epsilon<Scalar>())
|
||||||
);
|
);
|
||||||
|
|
||||||
Status minimizeNumericalDiff(
|
Status minimizeNumericalDiff(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode=1
|
const int mode=1
|
||||||
);
|
);
|
||||||
Status minimizeNumericalDiffInit(
|
Status minimizeNumericalDiffInit(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode=1
|
const int mode=1
|
||||||
);
|
);
|
||||||
Status minimizeNumericalDiffOneStep(
|
Status minimizeNumericalDiffOneStep(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode=1
|
const int mode=1
|
||||||
);
|
);
|
||||||
|
|
||||||
Status minimizeOptimumStorage(
|
Status lmstr1(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Scalar tol = ei_sqrt(epsilon<Scalar>())
|
const Scalar tol = ei_sqrt(epsilon<Scalar>())
|
||||||
);
|
);
|
||||||
|
|
||||||
Status minimizeOptimumStorage(
|
Status minimizeOptimumStorage(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode=1
|
const int mode=1
|
||||||
);
|
);
|
||||||
Status minimizeOptimumStorageInit(
|
Status minimizeOptimumStorageInit(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode=1
|
const int mode=1
|
||||||
);
|
);
|
||||||
Status minimizeOptimumStorageOneStep(
|
Status minimizeOptimumStorageOneStep(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode=1
|
const int mode=1
|
||||||
);
|
);
|
||||||
|
|
||||||
|
void resetParameters(void) { parameters = Parameters(); }
|
||||||
|
Parameters parameters;
|
||||||
Matrix< Scalar, Dynamic, 1 > fvec;
|
Matrix< Scalar, Dynamic, 1 > fvec;
|
||||||
Matrix< Scalar, Dynamic, Dynamic > fjac;
|
Matrix< Scalar, Dynamic, Dynamic > fjac;
|
||||||
VectorXi ipvt;
|
VectorXi ipvt;
|
||||||
@ -123,27 +116,24 @@ private:
|
|||||||
|
|
||||||
template<typename FunctorType, typename Scalar>
|
template<typename FunctorType, typename Scalar>
|
||||||
typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
||||||
LevenbergMarquardt<FunctorType,Scalar>::minimize(
|
LevenbergMarquardt<FunctorType,Scalar>::lmder1(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Scalar tol
|
const Scalar tol
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
n = x.size();
|
n = x.size();
|
||||||
m = functor.nbOfFunctions();
|
m = functor.nbOfFunctions();
|
||||||
Parameters parameters;
|
|
||||||
|
|
||||||
/* check the input parameters for errors. */
|
/* check the input parameters for errors. */
|
||||||
if (n <= 0 || m < n || tol < 0.)
|
if (n <= 0 || m < n || tol < 0.)
|
||||||
return ImproperInputParameters;
|
return ImproperInputParameters;
|
||||||
|
|
||||||
|
resetParameters();
|
||||||
parameters.ftol = tol;
|
parameters.ftol = tol;
|
||||||
parameters.xtol = tol;
|
parameters.xtol = tol;
|
||||||
parameters.maxfev = 100*(n+1);
|
parameters.maxfev = 100*(n+1);
|
||||||
|
|
||||||
return minimize(
|
return minimize(x);
|
||||||
x,
|
|
||||||
parameters
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -151,13 +141,12 @@ template<typename FunctorType, typename Scalar>
|
|||||||
typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
||||||
LevenbergMarquardt<FunctorType,Scalar>::minimize(
|
LevenbergMarquardt<FunctorType,Scalar>::minimize(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode
|
const int mode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Status status = minimizeInit(x, parameters, mode);
|
Status status = minimizeInit(x, mode);
|
||||||
while (status==Running)
|
while (status==Running)
|
||||||
status = minimizeOneStep(x, parameters, mode);
|
status = minimizeOneStep(x, mode);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +154,6 @@ template<typename FunctorType, typename Scalar>
|
|||||||
typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
||||||
LevenbergMarquardt<FunctorType,Scalar>::minimizeInit(
|
LevenbergMarquardt<FunctorType,Scalar>::minimizeInit(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode
|
const int mode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -216,7 +204,6 @@ template<typename FunctorType, typename Scalar>
|
|||||||
typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
||||||
LevenbergMarquardt<FunctorType,Scalar>::minimizeOneStep(
|
LevenbergMarquardt<FunctorType,Scalar>::minimizeOneStep(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode
|
const int mode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -408,34 +395,30 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOneStep(
|
|||||||
|
|
||||||
template<typename FunctorType, typename Scalar>
|
template<typename FunctorType, typename Scalar>
|
||||||
typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
||||||
LevenbergMarquardt<FunctorType,Scalar>::minimizeNumericalDiff(
|
LevenbergMarquardt<FunctorType,Scalar>::lmdif1(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Scalar tol
|
const Scalar tol
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
n = x.size();
|
n = x.size();
|
||||||
m = functor.nbOfFunctions();
|
m = functor.nbOfFunctions();
|
||||||
Parameters parameters;
|
|
||||||
|
|
||||||
/* check the input parameters for errors. */
|
/* check the input parameters for errors. */
|
||||||
if (n <= 0 || m < n || tol < 0.)
|
if (n <= 0 || m < n || tol < 0.)
|
||||||
return ImproperInputParameters;
|
return ImproperInputParameters;
|
||||||
|
|
||||||
|
resetParameters();
|
||||||
parameters.ftol = tol;
|
parameters.ftol = tol;
|
||||||
parameters.xtol = tol;
|
parameters.xtol = tol;
|
||||||
parameters.maxfev = 200*(n+1);
|
parameters.maxfev = 200*(n+1);
|
||||||
|
|
||||||
return minimizeNumericalDiff(
|
return minimizeNumericalDiff(x);
|
||||||
x,
|
|
||||||
parameters
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename FunctorType, typename Scalar>
|
template<typename FunctorType, typename Scalar>
|
||||||
typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
||||||
LevenbergMarquardt<FunctorType,Scalar>::minimizeNumericalDiffInit(
|
LevenbergMarquardt<FunctorType,Scalar>::minimizeNumericalDiffInit(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode
|
const int mode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -484,7 +467,6 @@ template<typename FunctorType, typename Scalar>
|
|||||||
typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
||||||
LevenbergMarquardt<FunctorType,Scalar>::minimizeNumericalDiffOneStep(
|
LevenbergMarquardt<FunctorType,Scalar>::minimizeNumericalDiffOneStep(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode
|
const int mode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -679,20 +661,19 @@ template<typename FunctorType, typename Scalar>
|
|||||||
typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
||||||
LevenbergMarquardt<FunctorType,Scalar>::minimizeNumericalDiff(
|
LevenbergMarquardt<FunctorType,Scalar>::minimizeNumericalDiff(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode
|
const int mode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Status status = minimizeNumericalDiffInit(x, parameters, mode);
|
Status status = minimizeNumericalDiffInit(x, mode);
|
||||||
while (status==Running)
|
while (status==Running)
|
||||||
status = minimizeNumericalDiffOneStep(x, parameters, mode);
|
status = minimizeNumericalDiffOneStep(x, mode);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename FunctorType, typename Scalar>
|
template<typename FunctorType, typename Scalar>
|
||||||
typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
||||||
LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorage(
|
LevenbergMarquardt<FunctorType,Scalar>::lmstr1(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Scalar tol
|
const Scalar tol
|
||||||
)
|
)
|
||||||
@ -701,27 +682,23 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorage(
|
|||||||
m = functor.nbOfFunctions();
|
m = functor.nbOfFunctions();
|
||||||
Matrix< Scalar, Dynamic, Dynamic > fjac(m, n);
|
Matrix< Scalar, Dynamic, Dynamic > fjac(m, n);
|
||||||
VectorXi ipvt;
|
VectorXi ipvt;
|
||||||
Parameters parameters;
|
|
||||||
|
|
||||||
/* check the input parameters for errors. */
|
/* check the input parameters for errors. */
|
||||||
if (n <= 0 || m < n || tol < 0.)
|
if (n <= 0 || m < n || tol < 0.)
|
||||||
return ImproperInputParameters;
|
return ImproperInputParameters;
|
||||||
|
|
||||||
|
resetParameters();
|
||||||
parameters.ftol = tol;
|
parameters.ftol = tol;
|
||||||
parameters.xtol = tol;
|
parameters.xtol = tol;
|
||||||
parameters.maxfev = 100*(n+1);
|
parameters.maxfev = 100*(n+1);
|
||||||
|
|
||||||
return minimizeOptimumStorage(
|
return minimizeOptimumStorage(x);
|
||||||
x,
|
|
||||||
parameters
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename FunctorType, typename Scalar>
|
template<typename FunctorType, typename Scalar>
|
||||||
typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
||||||
LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorageInit(
|
LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorageInit(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode
|
const int mode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -773,7 +750,6 @@ template<typename FunctorType, typename Scalar>
|
|||||||
typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
||||||
LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorageOneStep(
|
LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorageOneStep(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode
|
const int mode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -986,13 +962,12 @@ template<typename FunctorType, typename Scalar>
|
|||||||
typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
||||||
LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorage(
|
LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorage(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
const Parameters ¶meters,
|
|
||||||
const int mode
|
const int mode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Status status = minimizeOptimumStorageInit(x, parameters, mode);
|
Status status = minimizeOptimumStorageInit(x, mode);
|
||||||
while (status==Running)
|
while (status==Running)
|
||||||
status = minimizeOptimumStorageOneStep(x, parameters, mode);
|
status = minimizeOptimumStorageOneStep(x, mode);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ void testLmder1()
|
|||||||
// do the computation
|
// do the computation
|
||||||
lmder_functor functor;
|
lmder_functor functor;
|
||||||
LevenbergMarquardt<lmder_functor> lm(functor);
|
LevenbergMarquardt<lmder_functor> lm(functor);
|
||||||
info = lm.minimize(x);
|
info = lm.lmder1(x);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -181,8 +181,7 @@ void testLmder()
|
|||||||
// do the computation
|
// do the computation
|
||||||
lmder_functor functor;
|
lmder_functor functor;
|
||||||
LevenbergMarquardt<lmder_functor> lm(functor);
|
LevenbergMarquardt<lmder_functor> lm(functor);
|
||||||
LevenbergMarquardt<lmder_functor>::Parameters parameters;
|
info = lm.minimize(x);
|
||||||
info = lm.minimize(x, parameters);
|
|
||||||
|
|
||||||
// check return values
|
// check return values
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -270,7 +269,7 @@ void testHybrj1()
|
|||||||
// do the computation
|
// do the computation
|
||||||
hybrj_functor functor;
|
hybrj_functor functor;
|
||||||
HybridNonLinearSolver<hybrj_functor> solver(functor);
|
HybridNonLinearSolver<hybrj_functor> solver(functor);
|
||||||
info = solver.solve(x);
|
info = solver.hybrj1(x);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -302,8 +301,7 @@ void testHybrj()
|
|||||||
hybrj_functor functor;
|
hybrj_functor functor;
|
||||||
HybridNonLinearSolver<hybrj_functor> solver(functor);
|
HybridNonLinearSolver<hybrj_functor> solver(functor);
|
||||||
solver.diag.setConstant(n, 1.);
|
solver.diag.setConstant(n, 1.);
|
||||||
HybridNonLinearSolver<hybrj_functor>::Parameters parameters;
|
info = solver.solve(x, 2);
|
||||||
info = solver.solve(x, parameters, 2);
|
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -356,7 +354,7 @@ void testHybrd1()
|
|||||||
// do the computation
|
// do the computation
|
||||||
hybrd_functor functor;
|
hybrd_functor functor;
|
||||||
HybridNonLinearSolver<hybrd_functor> solver(functor);
|
HybridNonLinearSolver<hybrd_functor> solver(functor);
|
||||||
info = solver.solveNumericalDiff(x);
|
info = solver.hybrd1(x);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -382,11 +380,10 @@ void testHybrd()
|
|||||||
// do the computation
|
// do the computation
|
||||||
hybrd_functor functor;
|
hybrd_functor functor;
|
||||||
HybridNonLinearSolver<hybrd_functor> solver(functor);
|
HybridNonLinearSolver<hybrd_functor> solver(functor);
|
||||||
HybridNonLinearSolver<hybrd_functor>::Parameters parameters;
|
solver.parameters.nb_of_subdiagonals = 1;
|
||||||
parameters.nb_of_subdiagonals = 1;
|
solver.parameters.nb_of_superdiagonals = 1;
|
||||||
parameters.nb_of_superdiagonals = 1;
|
|
||||||
solver.diag.setConstant(n, 1.);
|
solver.diag.setConstant(n, 1.);
|
||||||
info = solver.solveNumericalDiff(x, parameters, 2);
|
info = solver.solveNumericalDiff(x, 2);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -457,7 +454,7 @@ void testLmstr1()
|
|||||||
// do the computation
|
// do the computation
|
||||||
lmstr_functor functor;
|
lmstr_functor functor;
|
||||||
LevenbergMarquardt<lmstr_functor> lm(functor);
|
LevenbergMarquardt<lmstr_functor> lm(functor);
|
||||||
info = lm.minimizeOptimumStorage(x);
|
info = lm.lmstr1(x);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -484,8 +481,7 @@ void testLmstr()
|
|||||||
// do the computation
|
// do the computation
|
||||||
lmstr_functor functor;
|
lmstr_functor functor;
|
||||||
LevenbergMarquardt<lmstr_functor> lm(functor);
|
LevenbergMarquardt<lmstr_functor> lm(functor);
|
||||||
LevenbergMarquardt<lmstr_functor>::Parameters parameters;
|
info = lm.minimizeOptimumStorage(x);
|
||||||
info = lm.minimizeOptimumStorage(x, parameters);
|
|
||||||
|
|
||||||
// check return values
|
// check return values
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -543,7 +539,7 @@ void testLmdif1()
|
|||||||
// do the computation
|
// do the computation
|
||||||
lmdif_functor functor;
|
lmdif_functor functor;
|
||||||
LevenbergMarquardt<lmdif_functor> lm(functor);
|
LevenbergMarquardt<lmdif_functor> lm(functor);
|
||||||
info = lm.minimizeNumericalDiff(x);
|
info = lm.lmdif1(x);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -571,8 +567,7 @@ void testLmdif()
|
|||||||
// do the computation
|
// do the computation
|
||||||
lmdif_functor functor;
|
lmdif_functor functor;
|
||||||
LevenbergMarquardt<lmdif_functor> lm(functor);
|
LevenbergMarquardt<lmdif_functor> lm(functor);
|
||||||
LevenbergMarquardt<lmdif_functor>::Parameters parameters;
|
info = lm.minimizeNumericalDiff(x);
|
||||||
info = lm.minimizeNumericalDiff(x, parameters);
|
|
||||||
|
|
||||||
// check return values
|
// check return values
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -657,8 +652,7 @@ void testNistChwirut2(void)
|
|||||||
// do the computation
|
// do the computation
|
||||||
chwirut2_functor functor;
|
chwirut2_functor functor;
|
||||||
LevenbergMarquardt<chwirut2_functor> lm(functor);
|
LevenbergMarquardt<chwirut2_functor> lm(functor);
|
||||||
LevenbergMarquardt<chwirut2_functor>::Parameters parameters;
|
info = lm.minimize(x);
|
||||||
info = lm.minimize(x, parameters);
|
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -676,10 +670,10 @@ void testNistChwirut2(void)
|
|||||||
*/
|
*/
|
||||||
x<< 0.15, 0.008, 0.010;
|
x<< 0.15, 0.008, 0.010;
|
||||||
// do the computation
|
// do the computation
|
||||||
parameters = LevenbergMarquardt<chwirut2_functor>::Parameters(); // get default back
|
lm.resetParameters();
|
||||||
parameters.ftol = 1.E6*epsilon<double>();
|
lm.parameters.ftol = 1.E6*epsilon<double>();
|
||||||
parameters.xtol = 1.E6*epsilon<double>();
|
lm.parameters.xtol = 1.E6*epsilon<double>();
|
||||||
info = lm.minimize(x, parameters);
|
info = lm.minimize(x);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -738,8 +732,7 @@ void testNistMisra1a(void)
|
|||||||
// do the computation
|
// do the computation
|
||||||
misra1a_functor functor;
|
misra1a_functor functor;
|
||||||
LevenbergMarquardt<misra1a_functor> lm(functor);
|
LevenbergMarquardt<misra1a_functor> lm(functor);
|
||||||
LevenbergMarquardt<misra1a_functor>::Parameters parameters;
|
info = lm.minimize(x);
|
||||||
info = lm.minimize(x, parameters);
|
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -756,7 +749,7 @@ void testNistMisra1a(void)
|
|||||||
*/
|
*/
|
||||||
x<< 250., 0.0005;
|
x<< 250., 0.0005;
|
||||||
// do the computation
|
// do the computation
|
||||||
info = lm.minimize(x, parameters);
|
info = lm.minimize(x);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -825,8 +818,7 @@ void testNistHahn1(void)
|
|||||||
// do the computation
|
// do the computation
|
||||||
hahn1_functor functor;
|
hahn1_functor functor;
|
||||||
LevenbergMarquardt<hahn1_functor> lm(functor);
|
LevenbergMarquardt<hahn1_functor> lm(functor);
|
||||||
LevenbergMarquardt<hahn1_functor>::Parameters parameters;
|
info = lm.minimize(x);
|
||||||
info = lm.minimize(x, parameters);
|
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -848,7 +840,7 @@ void testNistHahn1(void)
|
|||||||
*/
|
*/
|
||||||
x<< .1, -.1, .005, -.000001, -.005, .0001, -.0000001;
|
x<< .1, -.1, .005, -.000001, -.005, .0001, -.0000001;
|
||||||
// do the computation
|
// do the computation
|
||||||
info = lm.minimize(x, parameters);
|
info = lm.minimize(x);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -912,8 +904,7 @@ void testNistMisra1d(void)
|
|||||||
// do the computation
|
// do the computation
|
||||||
misra1d_functor functor;
|
misra1d_functor functor;
|
||||||
LevenbergMarquardt<misra1d_functor> lm(functor);
|
LevenbergMarquardt<misra1d_functor> lm(functor);
|
||||||
LevenbergMarquardt<misra1d_functor>::Parameters parameters;
|
info = lm.minimize(x);
|
||||||
info = lm.minimize(x, parameters);
|
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 3 == info);
|
VERIFY( 3 == info);
|
||||||
@ -930,7 +921,7 @@ void testNistMisra1d(void)
|
|||||||
*/
|
*/
|
||||||
x<< 450., 0.0003;
|
x<< 450., 0.0003;
|
||||||
// do the computation
|
// do the computation
|
||||||
info = lm.minimize(x, parameters);
|
info = lm.minimize(x);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -991,8 +982,7 @@ void testNistLanczos1(void)
|
|||||||
// do the computation
|
// do the computation
|
||||||
lanczos1_functor functor;
|
lanczos1_functor functor;
|
||||||
LevenbergMarquardt<lanczos1_functor> lm(functor);
|
LevenbergMarquardt<lanczos1_functor> lm(functor);
|
||||||
LevenbergMarquardt<lanczos1_functor>::Parameters parameters;
|
info = lm.minimize(x);
|
||||||
info = lm.minimize(x, parameters);
|
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 2 == info);
|
VERIFY( 2 == info);
|
||||||
@ -1013,7 +1003,7 @@ void testNistLanczos1(void)
|
|||||||
*/
|
*/
|
||||||
x<< 0.5, 0.7, 3.6, 4.2, 4., 6.3;
|
x<< 0.5, 0.7, 3.6, 4.2, 4., 6.3;
|
||||||
// do the computation
|
// do the computation
|
||||||
info = lm.minimize(x, parameters);
|
info = lm.minimize(x);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 2 == info);
|
VERIFY( 2 == info);
|
||||||
@ -1078,8 +1068,7 @@ void testNistRat42(void)
|
|||||||
// do the computation
|
// do the computation
|
||||||
rat42_functor functor;
|
rat42_functor functor;
|
||||||
LevenbergMarquardt<rat42_functor> lm(functor);
|
LevenbergMarquardt<rat42_functor> lm(functor);
|
||||||
LevenbergMarquardt<rat42_functor>::Parameters parameters;
|
info = lm.minimize(x);
|
||||||
info = lm.minimize(x, parameters);
|
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1097,7 +1086,7 @@ void testNistRat42(void)
|
|||||||
*/
|
*/
|
||||||
x<< 75., 2.5, 0.07;
|
x<< 75., 2.5, 0.07;
|
||||||
// do the computation
|
// do the computation
|
||||||
info = lm.minimize(x, parameters);
|
info = lm.minimize(x);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1157,8 +1146,7 @@ void testNistMGH10(void)
|
|||||||
// do the computation
|
// do the computation
|
||||||
MGH10_functor functor;
|
MGH10_functor functor;
|
||||||
LevenbergMarquardt<MGH10_functor> lm(functor);
|
LevenbergMarquardt<MGH10_functor> lm(functor);
|
||||||
LevenbergMarquardt<MGH10_functor>::Parameters parameters;
|
info = lm.minimize(x);
|
||||||
info = lm.minimize(x, parameters);
|
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 2 == info);
|
VERIFY( 2 == info);
|
||||||
@ -1176,7 +1164,7 @@ void testNistMGH10(void)
|
|||||||
*/
|
*/
|
||||||
x<< 0.02, 4000., 250.;
|
x<< 0.02, 4000., 250.;
|
||||||
// do the computation
|
// do the computation
|
||||||
info = lm.minimize(x, parameters);
|
info = lm.minimize(x);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 2 == info);
|
VERIFY( 2 == info);
|
||||||
@ -1234,11 +1222,10 @@ void testNistBoxBOD(void)
|
|||||||
// do the computation
|
// do the computation
|
||||||
BoxBOD_functor functor;
|
BoxBOD_functor functor;
|
||||||
LevenbergMarquardt<BoxBOD_functor> lm(functor);
|
LevenbergMarquardt<BoxBOD_functor> lm(functor);
|
||||||
LevenbergMarquardt<BoxBOD_functor>::Parameters parameters;
|
lm.parameters.ftol = 1.E6*epsilon<double>();
|
||||||
parameters.ftol = 1.E6*epsilon<double>();
|
lm.parameters.xtol = 1.E6*epsilon<double>();
|
||||||
parameters.xtol = 1.E6*epsilon<double>();
|
lm.parameters.factor = 10.;
|
||||||
parameters.factor = 10.;
|
info = lm.minimize(x);
|
||||||
info = lm.minimize(x, parameters);
|
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1255,10 +1242,10 @@ void testNistBoxBOD(void)
|
|||||||
*/
|
*/
|
||||||
x<< 100., 0.75;
|
x<< 100., 0.75;
|
||||||
// do the computation
|
// do the computation
|
||||||
parameters = LevenbergMarquardt<BoxBOD_functor>::Parameters(); // get default back
|
lm.resetParameters();
|
||||||
parameters.ftol = epsilon<double>();
|
lm.parameters.ftol = epsilon<double>();
|
||||||
parameters.xtol = epsilon<double>();
|
lm.parameters.xtol = epsilon<double>();
|
||||||
info = lm.minimize(x, parameters);
|
info = lm.minimize(x);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1317,11 +1304,10 @@ void testNistMGH17(void)
|
|||||||
// do the computation
|
// do the computation
|
||||||
MGH17_functor functor;
|
MGH17_functor functor;
|
||||||
LevenbergMarquardt<MGH17_functor> lm(functor);
|
LevenbergMarquardt<MGH17_functor> lm(functor);
|
||||||
LevenbergMarquardt<MGH17_functor>::Parameters parameters;
|
lm.parameters.ftol = epsilon<double>();
|
||||||
parameters.ftol = epsilon<double>();
|
lm.parameters.xtol = epsilon<double>();
|
||||||
parameters.xtol = epsilon<double>();
|
lm.parameters.maxfev = 1000;
|
||||||
parameters.maxfev = 1000;
|
info = lm.minimize(x);
|
||||||
info = lm.minimize(x, parameters);
|
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1341,8 +1327,8 @@ void testNistMGH17(void)
|
|||||||
*/
|
*/
|
||||||
x<< 0.5 ,1.5 ,-1 ,0.01 ,0.02;
|
x<< 0.5 ,1.5 ,-1 ,0.01 ,0.02;
|
||||||
// do the computation
|
// do the computation
|
||||||
parameters = LevenbergMarquardt<MGH17_functor>::Parameters(); // get default back
|
lm.resetParameters();
|
||||||
info = lm.minimize(x, parameters);
|
info = lm.minimize(x);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1407,9 +1393,8 @@ void testNistMGH09(void)
|
|||||||
// do the computation
|
// do the computation
|
||||||
MGH09_functor functor;
|
MGH09_functor functor;
|
||||||
LevenbergMarquardt<MGH09_functor> lm(functor);
|
LevenbergMarquardt<MGH09_functor> lm(functor);
|
||||||
LevenbergMarquardt<MGH09_functor>::Parameters parameters;
|
lm.parameters.maxfev = 1000;
|
||||||
parameters.maxfev = 1000;
|
info = lm.minimize(x);
|
||||||
info = lm.minimize(x, parameters);
|
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1428,8 +1413,8 @@ void testNistMGH09(void)
|
|||||||
*/
|
*/
|
||||||
x<< 0.25, 0.39, 0.415, 0.39;
|
x<< 0.25, 0.39, 0.415, 0.39;
|
||||||
// do the computation
|
// do the computation
|
||||||
parameters = LevenbergMarquardt<MGH09_functor>::Parameters();
|
lm.resetParameters();
|
||||||
info = lm.minimize(x, parameters);
|
info = lm.minimize(x);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1491,9 +1476,8 @@ void testNistBennett5(void)
|
|||||||
// do the computation
|
// do the computation
|
||||||
Bennett5_functor functor;
|
Bennett5_functor functor;
|
||||||
LevenbergMarquardt<Bennett5_functor> lm(functor);
|
LevenbergMarquardt<Bennett5_functor> lm(functor);
|
||||||
LevenbergMarquardt<Bennett5_functor>::Parameters parameters;
|
lm.parameters.maxfev = 1000;
|
||||||
parameters.maxfev = 1000;
|
info = lm.minimize(x);
|
||||||
info = lm.minimize(x, parameters);
|
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1510,8 +1494,8 @@ void testNistBennett5(void)
|
|||||||
*/
|
*/
|
||||||
x<< -1500., 45., 0.85;
|
x<< -1500., 45., 0.85;
|
||||||
// do the computation
|
// do the computation
|
||||||
parameters = LevenbergMarquardt<Bennett5_functor>::Parameters();
|
lm.resetParameters();
|
||||||
info = lm.minimize(x, parameters);
|
info = lm.minimize(x);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1579,10 +1563,9 @@ void testNistThurber(void)
|
|||||||
// do the computation
|
// do the computation
|
||||||
thurber_functor functor;
|
thurber_functor functor;
|
||||||
LevenbergMarquardt<thurber_functor> lm(functor);
|
LevenbergMarquardt<thurber_functor> lm(functor);
|
||||||
LevenbergMarquardt<thurber_functor>::Parameters parameters;
|
lm.parameters.ftol = 1.E4*epsilon<double>();
|
||||||
parameters.ftol = 1.E4*epsilon<double>();
|
lm.parameters.xtol = 1.E4*epsilon<double>();
|
||||||
parameters.xtol = 1.E4*epsilon<double>();
|
info = lm.minimize(x);
|
||||||
info = lm.minimize(x, parameters);
|
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1604,10 +1587,10 @@ void testNistThurber(void)
|
|||||||
*/
|
*/
|
||||||
x<< 1300 ,1500 ,500 ,75 ,1 ,0.4 ,0.05 ;
|
x<< 1300 ,1500 ,500 ,75 ,1 ,0.4 ,0.05 ;
|
||||||
// do the computation
|
// do the computation
|
||||||
parameters = LevenbergMarquardt<thurber_functor>::Parameters();
|
lm.resetParameters();
|
||||||
parameters.ftol = 1.E4*epsilon<double>();
|
lm.parameters.ftol = 1.E4*epsilon<double>();
|
||||||
parameters.xtol = 1.E4*epsilon<double>();
|
lm.parameters.xtol = 1.E4*epsilon<double>();
|
||||||
info = lm.minimize(x, parameters);
|
info = lm.minimize(x);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1672,10 +1655,9 @@ void testNistRat43(void)
|
|||||||
// do the computation
|
// do the computation
|
||||||
rat43_functor functor;
|
rat43_functor functor;
|
||||||
LevenbergMarquardt<rat43_functor> lm(functor);
|
LevenbergMarquardt<rat43_functor> lm(functor);
|
||||||
LevenbergMarquardt<rat43_functor>::Parameters parameters;
|
lm.parameters.ftol = 1.E6*epsilon<double>();
|
||||||
parameters.ftol = 1.E6*epsilon<double>();
|
lm.parameters.xtol = 1.E6*epsilon<double>();
|
||||||
parameters.xtol = 1.E6*epsilon<double>();
|
info = lm.minimize(x);
|
||||||
info = lm.minimize(x, parameters);
|
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1694,10 +1676,10 @@ void testNistRat43(void)
|
|||||||
*/
|
*/
|
||||||
x<< 700., 5., 0.75, 1.3;
|
x<< 700., 5., 0.75, 1.3;
|
||||||
// do the computation
|
// do the computation
|
||||||
parameters = LevenbergMarquardt<rat43_functor>::Parameters(); // get default back
|
lm.resetParameters();
|
||||||
parameters.ftol = 1.E5*epsilon<double>();
|
lm.parameters.ftol = 1.E5*epsilon<double>();
|
||||||
parameters.xtol = 1.E5*epsilon<double>();
|
lm.parameters.xtol = 1.E5*epsilon<double>();
|
||||||
info = lm.minimize(x, parameters);
|
info = lm.minimize(x);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1760,8 +1742,7 @@ void testNistEckerle4(void)
|
|||||||
// do the computation
|
// do the computation
|
||||||
eckerle4_functor functor;
|
eckerle4_functor functor;
|
||||||
LevenbergMarquardt<eckerle4_functor> lm(functor);
|
LevenbergMarquardt<eckerle4_functor> lm(functor);
|
||||||
LevenbergMarquardt<eckerle4_functor>::Parameters parameters;
|
info = lm.minimize(x);
|
||||||
info = lm.minimize(x, parameters);
|
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1779,7 +1760,7 @@ void testNistEckerle4(void)
|
|||||||
*/
|
*/
|
||||||
x<< 1.5, 5., 450.;
|
x<< 1.5, 5., 450.;
|
||||||
// do the computation
|
// do the computation
|
||||||
info = lm.minimize(x, parameters);
|
info = lm.minimize(x);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user