mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-09-23 06:43:13 +08:00
make diag be an internal variable too
This commit is contained in:
parent
e465ea82e1
commit
fa0183e7c7
@ -34,7 +34,6 @@ public:
|
|||||||
Status solve(
|
Status solve(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
int &nfev, int &njev,
|
int &nfev, int &njev,
|
||||||
Matrix< Scalar, Dynamic, 1 > &diag,
|
|
||||||
const Parameters ¶meters,
|
const Parameters ¶meters,
|
||||||
const int mode=1
|
const int mode=1
|
||||||
);
|
);
|
||||||
@ -46,7 +45,6 @@ public:
|
|||||||
Status solveNumericalDiff(
|
Status solveNumericalDiff(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
int &nfev,
|
int &nfev,
|
||||||
Matrix< Scalar, Dynamic, 1 > &diag,
|
|
||||||
const Parameters ¶meters,
|
const Parameters ¶meters,
|
||||||
const int mode=1,
|
const int mode=1,
|
||||||
int nb_of_subdiagonals = -1,
|
int nb_of_subdiagonals = -1,
|
||||||
@ -58,6 +56,7 @@ public:
|
|||||||
Matrix< Scalar, Dynamic, Dynamic > fjac;
|
Matrix< Scalar, Dynamic, Dynamic > fjac;
|
||||||
Matrix< Scalar, Dynamic, 1 > R;
|
Matrix< Scalar, Dynamic, 1 > R;
|
||||||
Matrix< Scalar, Dynamic, 1 > qtf;
|
Matrix< Scalar, Dynamic, 1 > qtf;
|
||||||
|
Matrix< Scalar, Dynamic, 1 > diag;
|
||||||
private:
|
private:
|
||||||
const FunctorType &functor;
|
const FunctorType &functor;
|
||||||
};
|
};
|
||||||
@ -73,7 +72,6 @@ HybridNonLinearSolver<FunctorType,Scalar>::solve(
|
|||||||
{
|
{
|
||||||
const int n = x.size();
|
const int n = x.size();
|
||||||
int nfev=0, njev=0;
|
int nfev=0, njev=0;
|
||||||
Matrix< Scalar, Dynamic, 1> diag;
|
|
||||||
Parameters parameters;
|
Parameters parameters;
|
||||||
|
|
||||||
/* check the input parameters for errors. */
|
/* check the input parameters for errors. */
|
||||||
@ -88,7 +86,6 @@ HybridNonLinearSolver<FunctorType,Scalar>::solve(
|
|||||||
return solve(
|
return solve(
|
||||||
x,
|
x,
|
||||||
nfev, njev,
|
nfev, njev,
|
||||||
diag,
|
|
||||||
parameters,
|
parameters,
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
@ -102,7 +99,6 @@ HybridNonLinearSolver<FunctorType,Scalar>::solve(
|
|||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
int &nfev,
|
int &nfev,
|
||||||
int &njev,
|
int &njev,
|
||||||
Matrix< Scalar, Dynamic, 1 > &diag,
|
|
||||||
const Parameters ¶meters,
|
const Parameters ¶meters,
|
||||||
const int mode
|
const int mode
|
||||||
)
|
)
|
||||||
@ -115,6 +111,8 @@ HybridNonLinearSolver<FunctorType,Scalar>::solve(
|
|||||||
R.resize( (n*(n+1))/2);
|
R.resize( (n*(n+1))/2);
|
||||||
fjac.resize(n, n);
|
fjac.resize(n, n);
|
||||||
fvec.resize(n);
|
fvec.resize(n);
|
||||||
|
if (mode != 2)
|
||||||
|
diag.resize(n);
|
||||||
|
|
||||||
/* Local variables */
|
/* Local variables */
|
||||||
int i, j, l, iwa[1];
|
int i, j, l, iwa[1];
|
||||||
@ -388,7 +386,6 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiff(
|
|||||||
{
|
{
|
||||||
const int n = x.size();
|
const int n = x.size();
|
||||||
int nfev=0;
|
int nfev=0;
|
||||||
Matrix< Scalar, Dynamic, 1> diag;
|
|
||||||
Parameters parameters;
|
Parameters parameters;
|
||||||
|
|
||||||
/* check the input parameters for errors. */
|
/* check the input parameters for errors. */
|
||||||
@ -404,7 +401,6 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiff(
|
|||||||
return solveNumericalDiff(
|
return solveNumericalDiff(
|
||||||
x,
|
x,
|
||||||
nfev,
|
nfev,
|
||||||
diag,
|
|
||||||
parameters,
|
parameters,
|
||||||
2,
|
2,
|
||||||
-1, -1,
|
-1, -1,
|
||||||
@ -418,7 +414,6 @@ typename HybridNonLinearSolver<FunctorType,Scalar>::Status
|
|||||||
HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiff(
|
HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiff(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
int &nfev,
|
int &nfev,
|
||||||
Matrix< Scalar, Dynamic, 1 > &diag,
|
|
||||||
const Parameters ¶meters,
|
const Parameters ¶meters,
|
||||||
const int mode,
|
const int mode,
|
||||||
int nb_of_subdiagonals,
|
int nb_of_subdiagonals,
|
||||||
@ -436,6 +431,8 @@ HybridNonLinearSolver<FunctorType,Scalar>::solveNumericalDiff(
|
|||||||
R.resize( (n*(n+1))/2);
|
R.resize( (n*(n+1))/2);
|
||||||
fjac.resize(n, n);
|
fjac.resize(n, n);
|
||||||
fvec.resize(n);
|
fvec.resize(n);
|
||||||
|
if (mode != 2)
|
||||||
|
diag.resize(n);
|
||||||
|
|
||||||
/* Local variables */
|
/* Local variables */
|
||||||
int i, j, l, iwa[1];
|
int i, j, l, iwa[1];
|
||||||
|
@ -43,7 +43,6 @@ public:
|
|||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
int &nfev,
|
int &nfev,
|
||||||
int &njev,
|
int &njev,
|
||||||
Matrix< Scalar, Dynamic, 1 > &diag,
|
|
||||||
const Parameters ¶meters,
|
const Parameters ¶meters,
|
||||||
const int mode=1
|
const int mode=1
|
||||||
);
|
);
|
||||||
@ -56,7 +55,6 @@ public:
|
|||||||
Status minimizeNumericalDiff(
|
Status minimizeNumericalDiff(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
int &nfev,
|
int &nfev,
|
||||||
Matrix< Scalar, Dynamic, 1 > &diag,
|
|
||||||
const Parameters ¶meters,
|
const Parameters ¶meters,
|
||||||
const int mode=1,
|
const int mode=1,
|
||||||
const Scalar epsfcn = Scalar(0.)
|
const Scalar epsfcn = Scalar(0.)
|
||||||
@ -71,7 +69,6 @@ public:
|
|||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
int &nfev,
|
int &nfev,
|
||||||
int &njev,
|
int &njev,
|
||||||
Matrix< Scalar, Dynamic, 1 > &diag,
|
|
||||||
const Parameters ¶meters,
|
const Parameters ¶meters,
|
||||||
const int mode=1
|
const int mode=1
|
||||||
);
|
);
|
||||||
@ -80,6 +77,7 @@ public:
|
|||||||
Matrix< Scalar, Dynamic, Dynamic > fjac;
|
Matrix< Scalar, Dynamic, Dynamic > fjac;
|
||||||
VectorXi ipvt;
|
VectorXi ipvt;
|
||||||
Matrix< Scalar, Dynamic, 1 > qtf;
|
Matrix< Scalar, Dynamic, 1 > qtf;
|
||||||
|
Matrix< Scalar, Dynamic, 1 > diag;
|
||||||
private:
|
private:
|
||||||
const FunctorType &functor;
|
const FunctorType &functor;
|
||||||
};
|
};
|
||||||
@ -94,9 +92,6 @@ LevenbergMarquardt<FunctorType,Scalar>::minimize(
|
|||||||
const int n = x.size();
|
const int n = x.size();
|
||||||
const int m = functor.nbOfFunctions();
|
const int m = functor.nbOfFunctions();
|
||||||
int nfev=0, njev=0;
|
int nfev=0, njev=0;
|
||||||
Matrix< Scalar, Dynamic, Dynamic > fjac(m, n);
|
|
||||||
Matrix< Scalar, Dynamic, 1> diag, qtf;
|
|
||||||
VectorXi ipvt;
|
|
||||||
Parameters parameters;
|
Parameters parameters;
|
||||||
|
|
||||||
/* check the input parameters for errors. */
|
/* check the input parameters for errors. */
|
||||||
@ -112,7 +107,6 @@ LevenbergMarquardt<FunctorType,Scalar>::minimize(
|
|||||||
return minimize(
|
return minimize(
|
||||||
x,
|
x,
|
||||||
nfev, njev,
|
nfev, njev,
|
||||||
diag,
|
|
||||||
parameters,
|
parameters,
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
@ -125,7 +119,6 @@ LevenbergMarquardt<FunctorType,Scalar>::minimize(
|
|||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
int &nfev,
|
int &nfev,
|
||||||
int &njev,
|
int &njev,
|
||||||
Matrix< Scalar, Dynamic, 1 > &diag,
|
|
||||||
const Parameters ¶meters,
|
const Parameters ¶meters,
|
||||||
const int mode
|
const int mode
|
||||||
)
|
)
|
||||||
@ -137,7 +130,8 @@ LevenbergMarquardt<FunctorType,Scalar>::minimize(
|
|||||||
fvec.resize(m);
|
fvec.resize(m);
|
||||||
ipvt.resize(n);
|
ipvt.resize(n);
|
||||||
fjac.resize(m, n);
|
fjac.resize(m, n);
|
||||||
diag.resize(n);
|
if (mode != 2)
|
||||||
|
diag.resize(n);
|
||||||
qtf.resize(n);
|
qtf.resize(n);
|
||||||
|
|
||||||
/* Local variables */
|
/* Local variables */
|
||||||
@ -376,9 +370,6 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeNumericalDiff(
|
|||||||
const int n = x.size();
|
const int n = x.size();
|
||||||
const int m = functor.nbOfFunctions();
|
const int m = functor.nbOfFunctions();
|
||||||
int nfev=0;
|
int nfev=0;
|
||||||
Matrix< Scalar, Dynamic, Dynamic > fjac(m, n);
|
|
||||||
Matrix< Scalar, Dynamic, 1> diag, qtf;
|
|
||||||
VectorXi ipvt;
|
|
||||||
Parameters parameters;
|
Parameters parameters;
|
||||||
|
|
||||||
/* check the input parameters for errors. */
|
/* check the input parameters for errors. */
|
||||||
@ -394,7 +385,6 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeNumericalDiff(
|
|||||||
return minimizeNumericalDiff(
|
return minimizeNumericalDiff(
|
||||||
x,
|
x,
|
||||||
nfev,
|
nfev,
|
||||||
diag,
|
|
||||||
parameters,
|
parameters,
|
||||||
1,
|
1,
|
||||||
Scalar(0.)
|
Scalar(0.)
|
||||||
@ -406,7 +396,6 @@ typename LevenbergMarquardt<FunctorType,Scalar>::Status
|
|||||||
LevenbergMarquardt<FunctorType,Scalar>::minimizeNumericalDiff(
|
LevenbergMarquardt<FunctorType,Scalar>::minimizeNumericalDiff(
|
||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
int &nfev,
|
int &nfev,
|
||||||
Matrix< Scalar, Dynamic, 1 > &diag,
|
|
||||||
const Parameters ¶meters,
|
const Parameters ¶meters,
|
||||||
const int mode,
|
const int mode,
|
||||||
const Scalar epsfcn
|
const Scalar epsfcn
|
||||||
@ -419,7 +408,8 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeNumericalDiff(
|
|||||||
fvec.resize(m);
|
fvec.resize(m);
|
||||||
ipvt.resize(n);
|
ipvt.resize(n);
|
||||||
fjac.resize(m, n);
|
fjac.resize(m, n);
|
||||||
diag.resize(n);
|
if (mode != 2 )
|
||||||
|
diag.resize(n);
|
||||||
qtf.resize(n);
|
qtf.resize(n);
|
||||||
|
|
||||||
/* Local variables */
|
/* Local variables */
|
||||||
@ -658,7 +648,6 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorage(
|
|||||||
const int m = functor.nbOfFunctions();
|
const int m = functor.nbOfFunctions();
|
||||||
int nfev=0, njev=0;
|
int nfev=0, njev=0;
|
||||||
Matrix< Scalar, Dynamic, Dynamic > fjac(m, n);
|
Matrix< Scalar, Dynamic, Dynamic > fjac(m, n);
|
||||||
Matrix< Scalar, Dynamic, 1> diag, qtf;
|
|
||||||
VectorXi ipvt;
|
VectorXi ipvt;
|
||||||
Parameters parameters;
|
Parameters parameters;
|
||||||
|
|
||||||
@ -675,7 +664,6 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorage(
|
|||||||
return minimizeOptimumStorage(
|
return minimizeOptimumStorage(
|
||||||
x,
|
x,
|
||||||
nfev, njev,
|
nfev, njev,
|
||||||
diag,
|
|
||||||
parameters,
|
parameters,
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
@ -687,7 +675,6 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorage(
|
|||||||
Matrix< Scalar, Dynamic, 1 > &x,
|
Matrix< Scalar, Dynamic, 1 > &x,
|
||||||
int &nfev,
|
int &nfev,
|
||||||
int &njev,
|
int &njev,
|
||||||
Matrix< Scalar, Dynamic, 1 > &diag,
|
|
||||||
const Parameters ¶meters,
|
const Parameters ¶meters,
|
||||||
const int mode
|
const int mode
|
||||||
)
|
)
|
||||||
@ -699,7 +686,8 @@ LevenbergMarquardt<FunctorType,Scalar>::minimizeOptimumStorage(
|
|||||||
fvec.resize(m);
|
fvec.resize(m);
|
||||||
ipvt.resize(n);
|
ipvt.resize(n);
|
||||||
fjac.resize(m, n);
|
fjac.resize(m, n);
|
||||||
diag.resize(n);
|
if (mode != 2)
|
||||||
|
diag.resize(n);
|
||||||
qtf.resize(n);
|
qtf.resize(n);
|
||||||
|
|
||||||
/* Local variables */
|
/* Local variables */
|
||||||
|
@ -173,7 +173,7 @@ void testLmder()
|
|||||||
const int m=15, n=3;
|
const int m=15, n=3;
|
||||||
int info, nfev=0, njev=0;
|
int info, nfev=0, njev=0;
|
||||||
double fnorm, covfac;
|
double fnorm, covfac;
|
||||||
VectorXd x, diag;
|
VectorXd x;
|
||||||
|
|
||||||
/* the following starting values provide a rough fit. */
|
/* the following starting values provide a rough fit. */
|
||||||
x.setConstant(n, 1.);
|
x.setConstant(n, 1.);
|
||||||
@ -182,7 +182,7 @@ void testLmder()
|
|||||||
lmder_functor functor;
|
lmder_functor functor;
|
||||||
LevenbergMarquardt<lmder_functor> lm(functor);
|
LevenbergMarquardt<lmder_functor> lm(functor);
|
||||||
LevenbergMarquardt<lmder_functor>::Parameters parameters;
|
LevenbergMarquardt<lmder_functor>::Parameters parameters;
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return values
|
// check return values
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -292,18 +292,18 @@ void testHybrj()
|
|||||||
{
|
{
|
||||||
const int n=9;
|
const int n=9;
|
||||||
int info, nfev=0, njev=0;
|
int info, nfev=0, njev=0;
|
||||||
VectorXd x(n), diag(n);
|
VectorXd x(n);
|
||||||
|
|
||||||
/* the following starting values provide a rough fit. */
|
/* the following starting values provide a rough fit. */
|
||||||
x.setConstant(n, -1.);
|
x.setConstant(n, -1.);
|
||||||
|
|
||||||
diag.setConstant(n, 1.);
|
|
||||||
|
|
||||||
// do the computation
|
// do the computation
|
||||||
hybrj_functor functor;
|
hybrj_functor functor;
|
||||||
HybridNonLinearSolver<hybrj_functor> solver(functor);
|
HybridNonLinearSolver<hybrj_functor> solver(functor);
|
||||||
|
solver.diag.setConstant(n, 1.);
|
||||||
HybridNonLinearSolver<hybrj_functor>::Parameters parameters;
|
HybridNonLinearSolver<hybrj_functor>::Parameters parameters;
|
||||||
info = solver.solve(x, nfev, njev, diag, parameters, 2);
|
info = solver.solve(x, nfev, njev, parameters, 2);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -374,20 +374,20 @@ void testHybrd()
|
|||||||
{
|
{
|
||||||
const int n=9;
|
const int n=9;
|
||||||
int info, nfev=0, ml, mu;
|
int info, nfev=0, ml, mu;
|
||||||
VectorXd x, diag(n);
|
VectorXd x;
|
||||||
|
|
||||||
/* the following starting values provide a rough fit. */
|
/* the following starting values provide a rough fit. */
|
||||||
x.setConstant(n, -1.);
|
x.setConstant(n, -1.);
|
||||||
|
|
||||||
ml = 1;
|
ml = 1;
|
||||||
mu = 1;
|
mu = 1;
|
||||||
diag.setConstant(n, 1.);
|
|
||||||
|
|
||||||
// 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;
|
HybridNonLinearSolver<hybrd_functor>::Parameters parameters;
|
||||||
info = solver.solveNumericalDiff(x, nfev, diag, parameters, 2, ml, mu);
|
solver.diag.setConstant(n, 1.);
|
||||||
|
info = solver.solveNumericalDiff(x, nfev, parameters, 2, ml, mu);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -477,7 +477,7 @@ void testLmstr()
|
|||||||
const int n=3;
|
const int n=3;
|
||||||
int info, nfev=0, njev=0;
|
int info, nfev=0, njev=0;
|
||||||
double fnorm;
|
double fnorm;
|
||||||
VectorXd x(n), diag;
|
VectorXd x(n);
|
||||||
|
|
||||||
/* the following starting values provide a rough fit. */
|
/* the following starting values provide a rough fit. */
|
||||||
x.setConstant(n, 1.);
|
x.setConstant(n, 1.);
|
||||||
@ -486,7 +486,7 @@ void testLmstr()
|
|||||||
lmstr_functor functor;
|
lmstr_functor functor;
|
||||||
LevenbergMarquardt<lmstr_functor> lm(functor);
|
LevenbergMarquardt<lmstr_functor> lm(functor);
|
||||||
LevenbergMarquardt<lmstr_functor>::Parameters parameters;
|
LevenbergMarquardt<lmstr_functor>::Parameters parameters;
|
||||||
info = lm.minimizeOptimumStorage(x, nfev, njev, diag, parameters);
|
info = lm.minimizeOptimumStorage(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return values
|
// check return values
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -564,7 +564,7 @@ void testLmdif()
|
|||||||
const int m=15, n=3;
|
const int m=15, n=3;
|
||||||
int info, nfev=0;
|
int info, nfev=0;
|
||||||
double fnorm, covfac;
|
double fnorm, covfac;
|
||||||
VectorXd x(n), diag;
|
VectorXd x(n);
|
||||||
|
|
||||||
/* the following starting values provide a rough fit. */
|
/* the following starting values provide a rough fit. */
|
||||||
x.setConstant(n, 1.);
|
x.setConstant(n, 1.);
|
||||||
@ -573,7 +573,7 @@ void testLmdif()
|
|||||||
lmdif_functor functor;
|
lmdif_functor functor;
|
||||||
LevenbergMarquardt<lmdif_functor> lm(functor);
|
LevenbergMarquardt<lmdif_functor> lm(functor);
|
||||||
LevenbergMarquardt<lmdif_functor>::Parameters parameters;
|
LevenbergMarquardt<lmdif_functor>::Parameters parameters;
|
||||||
info = lm.minimizeNumericalDiff(x, nfev, diag, parameters);
|
info = lm.minimizeNumericalDiff(x, nfev, parameters);
|
||||||
|
|
||||||
// check return values
|
// check return values
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -649,7 +649,7 @@ void testNistChwirut2(void)
|
|||||||
const int n=3;
|
const int n=3;
|
||||||
int info, nfev=0, njev=0;
|
int info, nfev=0, njev=0;
|
||||||
|
|
||||||
VectorXd x(n), diag;
|
VectorXd x(n);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First try
|
* First try
|
||||||
@ -659,7 +659,7 @@ void testNistChwirut2(void)
|
|||||||
chwirut2_functor functor;
|
chwirut2_functor functor;
|
||||||
LevenbergMarquardt<chwirut2_functor> lm(functor);
|
LevenbergMarquardt<chwirut2_functor> lm(functor);
|
||||||
LevenbergMarquardt<chwirut2_functor>::Parameters parameters;
|
LevenbergMarquardt<chwirut2_functor>::Parameters parameters;
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -680,7 +680,7 @@ void testNistChwirut2(void)
|
|||||||
parameters = LevenbergMarquardt<chwirut2_functor>::Parameters(); // get default back
|
parameters = LevenbergMarquardt<chwirut2_functor>::Parameters(); // get default back
|
||||||
parameters.ftol = 1.E6*epsilon<double>();
|
parameters.ftol = 1.E6*epsilon<double>();
|
||||||
parameters.xtol = 1.E6*epsilon<double>();
|
parameters.xtol = 1.E6*epsilon<double>();
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -730,7 +730,7 @@ void testNistMisra1a(void)
|
|||||||
const int n=2;
|
const int n=2;
|
||||||
int info, nfev=0, njev=0;
|
int info, nfev=0, njev=0;
|
||||||
|
|
||||||
VectorXd x(n), diag;
|
VectorXd x(n);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First try
|
* First try
|
||||||
@ -740,7 +740,7 @@ void testNistMisra1a(void)
|
|||||||
misra1a_functor functor;
|
misra1a_functor functor;
|
||||||
LevenbergMarquardt<misra1a_functor> lm(functor);
|
LevenbergMarquardt<misra1a_functor> lm(functor);
|
||||||
LevenbergMarquardt<misra1a_functor>::Parameters parameters;
|
LevenbergMarquardt<misra1a_functor>::Parameters parameters;
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -757,7 +757,7 @@ void testNistMisra1a(void)
|
|||||||
*/
|
*/
|
||||||
x<< 250., 0.0005;
|
x<< 250., 0.0005;
|
||||||
// do the computation
|
// do the computation
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -817,7 +817,7 @@ void testNistHahn1(void)
|
|||||||
const int n=7;
|
const int n=7;
|
||||||
int info, nfev=0, njev=0;
|
int info, nfev=0, njev=0;
|
||||||
|
|
||||||
VectorXd x(n), diag;
|
VectorXd x(n);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First try
|
* First try
|
||||||
@ -827,7 +827,7 @@ void testNistHahn1(void)
|
|||||||
hahn1_functor functor;
|
hahn1_functor functor;
|
||||||
LevenbergMarquardt<hahn1_functor> lm(functor);
|
LevenbergMarquardt<hahn1_functor> lm(functor);
|
||||||
LevenbergMarquardt<hahn1_functor>::Parameters parameters;
|
LevenbergMarquardt<hahn1_functor>::Parameters parameters;
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -849,7 +849,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, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -904,7 +904,7 @@ void testNistMisra1d(void)
|
|||||||
const int n=2;
|
const int n=2;
|
||||||
int info, nfev=0, njev=0;
|
int info, nfev=0, njev=0;
|
||||||
|
|
||||||
VectorXd x(n), diag;
|
VectorXd x(n);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First try
|
* First try
|
||||||
@ -914,7 +914,7 @@ void testNistMisra1d(void)
|
|||||||
misra1d_functor functor;
|
misra1d_functor functor;
|
||||||
LevenbergMarquardt<misra1d_functor> lm(functor);
|
LevenbergMarquardt<misra1d_functor> lm(functor);
|
||||||
LevenbergMarquardt<misra1d_functor>::Parameters parameters;
|
LevenbergMarquardt<misra1d_functor>::Parameters parameters;
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 3 == info);
|
VERIFY( 3 == info);
|
||||||
@ -931,7 +931,7 @@ void testNistMisra1d(void)
|
|||||||
*/
|
*/
|
||||||
x<< 450., 0.0003;
|
x<< 450., 0.0003;
|
||||||
// do the computation
|
// do the computation
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -983,7 +983,7 @@ void testNistLanczos1(void)
|
|||||||
const int n=6;
|
const int n=6;
|
||||||
int info, nfev=0, njev=0;
|
int info, nfev=0, njev=0;
|
||||||
|
|
||||||
VectorXd x(n), diag;
|
VectorXd x(n);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First try
|
* First try
|
||||||
@ -993,7 +993,7 @@ void testNistLanczos1(void)
|
|||||||
lanczos1_functor functor;
|
lanczos1_functor functor;
|
||||||
LevenbergMarquardt<lanczos1_functor> lm(functor);
|
LevenbergMarquardt<lanczos1_functor> lm(functor);
|
||||||
LevenbergMarquardt<lanczos1_functor>::Parameters parameters;
|
LevenbergMarquardt<lanczos1_functor>::Parameters parameters;
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 2 == info);
|
VERIFY( 2 == info);
|
||||||
@ -1014,7 +1014,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, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 2 == info);
|
VERIFY( 2 == info);
|
||||||
@ -1070,7 +1070,7 @@ void testNistRat42(void)
|
|||||||
const int n=3;
|
const int n=3;
|
||||||
int info, nfev=0, njev=0;
|
int info, nfev=0, njev=0;
|
||||||
|
|
||||||
VectorXd x(n), diag;
|
VectorXd x(n);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First try
|
* First try
|
||||||
@ -1080,7 +1080,7 @@ void testNistRat42(void)
|
|||||||
rat42_functor functor;
|
rat42_functor functor;
|
||||||
LevenbergMarquardt<rat42_functor> lm(functor);
|
LevenbergMarquardt<rat42_functor> lm(functor);
|
||||||
LevenbergMarquardt<rat42_functor>::Parameters parameters;
|
LevenbergMarquardt<rat42_functor>::Parameters parameters;
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1098,7 +1098,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, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1149,7 +1149,7 @@ void testNistMGH10(void)
|
|||||||
const int n=3;
|
const int n=3;
|
||||||
int info, nfev=0, njev=0;
|
int info, nfev=0, njev=0;
|
||||||
|
|
||||||
VectorXd x(n), diag;
|
VectorXd x(n);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First try
|
* First try
|
||||||
@ -1159,7 +1159,7 @@ void testNistMGH10(void)
|
|||||||
MGH10_functor functor;
|
MGH10_functor functor;
|
||||||
LevenbergMarquardt<MGH10_functor> lm(functor);
|
LevenbergMarquardt<MGH10_functor> lm(functor);
|
||||||
LevenbergMarquardt<MGH10_functor>::Parameters parameters;
|
LevenbergMarquardt<MGH10_functor>::Parameters parameters;
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 2 == info);
|
VERIFY( 2 == info);
|
||||||
@ -1177,7 +1177,7 @@ void testNistMGH10(void)
|
|||||||
*/
|
*/
|
||||||
x<< 0.02, 4000., 250.;
|
x<< 0.02, 4000., 250.;
|
||||||
// do the computation
|
// do the computation
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 2 == info);
|
VERIFY( 2 == info);
|
||||||
@ -1226,7 +1226,7 @@ void testNistBoxBOD(void)
|
|||||||
const int n=2;
|
const int n=2;
|
||||||
int info, nfev=0, njev=0;
|
int info, nfev=0, njev=0;
|
||||||
|
|
||||||
VectorXd x(n), diag;
|
VectorXd x(n);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First try
|
* First try
|
||||||
@ -1239,7 +1239,7 @@ void testNistBoxBOD(void)
|
|||||||
parameters.ftol = 1.E6*epsilon<double>();
|
parameters.ftol = 1.E6*epsilon<double>();
|
||||||
parameters.xtol = 1.E6*epsilon<double>();
|
parameters.xtol = 1.E6*epsilon<double>();
|
||||||
parameters.factor = 10.;
|
parameters.factor = 10.;
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1259,7 +1259,7 @@ void testNistBoxBOD(void)
|
|||||||
parameters = LevenbergMarquardt<BoxBOD_functor>::Parameters(); // get default back
|
parameters = LevenbergMarquardt<BoxBOD_functor>::Parameters(); // get default back
|
||||||
parameters.ftol = epsilon<double>();
|
parameters.ftol = epsilon<double>();
|
||||||
parameters.xtol = epsilon<double>();
|
parameters.xtol = epsilon<double>();
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1309,7 +1309,7 @@ void testNistMGH17(void)
|
|||||||
const int n=5;
|
const int n=5;
|
||||||
int info, nfev=0, njev=0;
|
int info, nfev=0, njev=0;
|
||||||
|
|
||||||
VectorXd x(n), diag;
|
VectorXd x(n);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First try
|
* First try
|
||||||
@ -1322,7 +1322,7 @@ void testNistMGH17(void)
|
|||||||
parameters.ftol = epsilon<double>();
|
parameters.ftol = epsilon<double>();
|
||||||
parameters.xtol = epsilon<double>();
|
parameters.xtol = epsilon<double>();
|
||||||
parameters.maxfev = 1000;
|
parameters.maxfev = 1000;
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1343,7 +1343,7 @@ 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
|
parameters = LevenbergMarquardt<MGH17_functor>::Parameters(); // get default back
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1399,7 +1399,7 @@ void testNistMGH09(void)
|
|||||||
const int n=4;
|
const int n=4;
|
||||||
int info, nfev=0, njev=0;
|
int info, nfev=0, njev=0;
|
||||||
|
|
||||||
VectorXd x(n), diag;
|
VectorXd x(n);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First try
|
* First try
|
||||||
@ -1410,7 +1410,7 @@ void testNistMGH09(void)
|
|||||||
LevenbergMarquardt<MGH09_functor> lm(functor);
|
LevenbergMarquardt<MGH09_functor> lm(functor);
|
||||||
LevenbergMarquardt<MGH09_functor>::Parameters parameters;
|
LevenbergMarquardt<MGH09_functor>::Parameters parameters;
|
||||||
parameters.maxfev = 1000;
|
parameters.maxfev = 1000;
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1430,7 +1430,7 @@ 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();
|
parameters = LevenbergMarquardt<MGH09_functor>::Parameters();
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1483,7 +1483,7 @@ void testNistBennett5(void)
|
|||||||
const int n=3;
|
const int n=3;
|
||||||
int info, nfev=0, njev=0;
|
int info, nfev=0, njev=0;
|
||||||
|
|
||||||
VectorXd x(n), diag;
|
VectorXd x(n);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First try
|
* First try
|
||||||
@ -1494,7 +1494,7 @@ void testNistBennett5(void)
|
|||||||
LevenbergMarquardt<Bennett5_functor> lm(functor);
|
LevenbergMarquardt<Bennett5_functor> lm(functor);
|
||||||
LevenbergMarquardt<Bennett5_functor>::Parameters parameters;
|
LevenbergMarquardt<Bennett5_functor>::Parameters parameters;
|
||||||
parameters.maxfev = 1000;
|
parameters.maxfev = 1000;
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1512,7 +1512,7 @@ void testNistBennett5(void)
|
|||||||
x<< -1500., 45., 0.85;
|
x<< -1500., 45., 0.85;
|
||||||
// do the computation
|
// do the computation
|
||||||
parameters = LevenbergMarquardt<Bennett5_functor>::Parameters();
|
parameters = LevenbergMarquardt<Bennett5_functor>::Parameters();
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1571,7 +1571,7 @@ void testNistThurber(void)
|
|||||||
const int n=7;
|
const int n=7;
|
||||||
int info, nfev=0, njev=0;
|
int info, nfev=0, njev=0;
|
||||||
|
|
||||||
VectorXd x(n), diag;
|
VectorXd x(n);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First try
|
* First try
|
||||||
@ -1583,7 +1583,7 @@ void testNistThurber(void)
|
|||||||
LevenbergMarquardt<thurber_functor>::Parameters parameters;
|
LevenbergMarquardt<thurber_functor>::Parameters parameters;
|
||||||
parameters.ftol = 1.E4*epsilon<double>();
|
parameters.ftol = 1.E4*epsilon<double>();
|
||||||
parameters.xtol = 1.E4*epsilon<double>();
|
parameters.xtol = 1.E4*epsilon<double>();
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1608,7 +1608,7 @@ void testNistThurber(void)
|
|||||||
parameters = LevenbergMarquardt<thurber_functor>::Parameters();
|
parameters = LevenbergMarquardt<thurber_functor>::Parameters();
|
||||||
parameters.ftol = 1.E4*epsilon<double>();
|
parameters.ftol = 1.E4*epsilon<double>();
|
||||||
parameters.xtol = 1.E4*epsilon<double>();
|
parameters.xtol = 1.E4*epsilon<double>();
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1664,7 +1664,7 @@ void testNistRat43(void)
|
|||||||
const int n=4;
|
const int n=4;
|
||||||
int info, nfev=0, njev=0;
|
int info, nfev=0, njev=0;
|
||||||
|
|
||||||
VectorXd x(n), diag;
|
VectorXd x(n);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First try
|
* First try
|
||||||
@ -1676,7 +1676,7 @@ void testNistRat43(void)
|
|||||||
LevenbergMarquardt<rat43_functor>::Parameters parameters;
|
LevenbergMarquardt<rat43_functor>::Parameters parameters;
|
||||||
parameters.ftol = 1.E6*epsilon<double>();
|
parameters.ftol = 1.E6*epsilon<double>();
|
||||||
parameters.xtol = 1.E6*epsilon<double>();
|
parameters.xtol = 1.E6*epsilon<double>();
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1698,7 +1698,7 @@ void testNistRat43(void)
|
|||||||
parameters = LevenbergMarquardt<rat43_functor>::Parameters(); // get default back
|
parameters = LevenbergMarquardt<rat43_functor>::Parameters(); // get default back
|
||||||
parameters.ftol = 1.E5*epsilon<double>();
|
parameters.ftol = 1.E5*epsilon<double>();
|
||||||
parameters.xtol = 1.E5*epsilon<double>();
|
parameters.xtol = 1.E5*epsilon<double>();
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1752,7 +1752,7 @@ void testNistEckerle4(void)
|
|||||||
const int n=3;
|
const int n=3;
|
||||||
int info, nfev=0, njev=0;
|
int info, nfev=0, njev=0;
|
||||||
|
|
||||||
VectorXd x(n), diag;
|
VectorXd x(n);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First try
|
* First try
|
||||||
@ -1762,7 +1762,7 @@ void testNistEckerle4(void)
|
|||||||
eckerle4_functor functor;
|
eckerle4_functor functor;
|
||||||
LevenbergMarquardt<eckerle4_functor> lm(functor);
|
LevenbergMarquardt<eckerle4_functor> lm(functor);
|
||||||
LevenbergMarquardt<eckerle4_functor>::Parameters parameters;
|
LevenbergMarquardt<eckerle4_functor>::Parameters parameters;
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
@ -1780,7 +1780,7 @@ void testNistEckerle4(void)
|
|||||||
*/
|
*/
|
||||||
x<< 1.5, 5., 450.;
|
x<< 1.5, 5., 450.;
|
||||||
// do the computation
|
// do the computation
|
||||||
info = lm.minimize(x, nfev, njev, diag, parameters);
|
info = lm.minimize(x, nfev, njev, parameters);
|
||||||
|
|
||||||
// check return value
|
// check return value
|
||||||
VERIFY( 1 == info);
|
VERIFY( 1 == info);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user