mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-01-30 17:40:05 +08:00
use references intead of pointers for njev/nfev
This commit is contained in:
parent
054652b789
commit
9294d33a11
@ -65,7 +65,7 @@ int ei_hybrd(
|
||||
diag.data(), mode,
|
||||
factor,
|
||||
nprint,
|
||||
&nfev,
|
||||
nfev,
|
||||
fjac.data(), ldfjac,
|
||||
R.data(), lr,
|
||||
qtf.data(),
|
||||
@ -108,8 +108,8 @@ int ei_hybrj(
|
||||
diag.data(), mode,
|
||||
factor,
|
||||
nprint,
|
||||
&nfev,
|
||||
&njev,
|
||||
nfev,
|
||||
njev,
|
||||
R.data(), lr,
|
||||
qtf.data(),
|
||||
wa1.data(), wa2.data(), wa3.data(), wa4.data()
|
||||
@ -152,7 +152,7 @@ int ei_lmstr(
|
||||
diag.data(), mode,
|
||||
factor,
|
||||
nprint,
|
||||
&nfev, &njev,
|
||||
nfev, njev,
|
||||
ipvt.data(),
|
||||
qtf.data(),
|
||||
wa1.data(), wa2.data(), wa3.data(), wa4.data()
|
||||
@ -195,7 +195,7 @@ int ei_lmder(
|
||||
diag.data(), mode,
|
||||
factor,
|
||||
nprint,
|
||||
&nfev, &njev,
|
||||
nfev, njev,
|
||||
ipvt.data(),
|
||||
qtf.data(),
|
||||
wa1.data(), wa2.data(), wa3.data(), wa4.data()
|
||||
@ -239,7 +239,7 @@ int ei_lmdif(
|
||||
diag.data(), mode,
|
||||
factor,
|
||||
nprint,
|
||||
&nfev,
|
||||
nfev,
|
||||
fjac.data() , ldfjac,
|
||||
ipvt.data(),
|
||||
qtf.data(),
|
||||
|
@ -2,7 +2,7 @@
|
||||
template<typename Scalar>
|
||||
int hybrd_template(minpack_func_nn fcn, void *p, int n, Scalar *x, Scalar *
|
||||
fvec, Scalar xtol, int maxfev, int ml, int mu,
|
||||
Scalar epsfcn, Scalar *diag, int mode, Scalar factor, int nprint, int *nfev, Scalar *
|
||||
Scalar epsfcn, Scalar *diag, int mode, Scalar factor, int nprint, int &nfev, Scalar *
|
||||
fjac, int ldfjac, Scalar *r__, int lr, Scalar *qtf,
|
||||
Scalar *wa1, Scalar *wa2, Scalar *wa3, Scalar *wa4)
|
||||
{
|
||||
@ -46,7 +46,7 @@ int hybrd_template(minpack_func_nn fcn, void *p, int n, Scalar *x, Scalar *
|
||||
|
||||
info = 0;
|
||||
iflag = 0;
|
||||
*nfev = 0;
|
||||
nfev = 0;
|
||||
|
||||
/* check the input parameters for errors. */
|
||||
|
||||
@ -69,7 +69,7 @@ L20:
|
||||
/* and calculate its norm. */
|
||||
|
||||
iflag = (*fcn)(p, n, &x[1], &fvec[1], 1);
|
||||
*nfev = 1;
|
||||
nfev = 1;
|
||||
if (iflag < 0) {
|
||||
goto L300;
|
||||
}
|
||||
@ -98,7 +98,7 @@ L30:
|
||||
|
||||
iflag = fdjac1(fcn, p, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac,
|
||||
ml, mu, epsfcn, &wa1[1], &wa2[1]);
|
||||
*nfev += msum;
|
||||
nfev += msum;
|
||||
if (iflag < 0) {
|
||||
goto L300;
|
||||
}
|
||||
@ -243,7 +243,7 @@ L190:
|
||||
/* evaluate the function at x + p and calculate its norm. */
|
||||
|
||||
iflag = (*fcn)(p, n, &wa2[1], &wa4[1], 1);
|
||||
++(*nfev);
|
||||
++(nfev);
|
||||
if (iflag < 0) {
|
||||
goto L300;
|
||||
}
|
||||
@ -343,7 +343,7 @@ L260:
|
||||
|
||||
/* tests for termination and stringent tolerances. */
|
||||
|
||||
if (*nfev >= maxfev) {
|
||||
if (nfev >= maxfev) {
|
||||
info = 2;
|
||||
}
|
||||
/* Computing MAX */
|
||||
|
@ -7,7 +7,7 @@ int ei_hybrd1(
|
||||
)
|
||||
{
|
||||
const int n = x.size();
|
||||
int info, nfev;
|
||||
int info, nfev=0;
|
||||
Matrix< Scalar, Dynamic, Dynamic > fjac;
|
||||
Matrix< Scalar, Dynamic, 1> R, qtf, diag;
|
||||
|
||||
|
@ -3,7 +3,7 @@ template<typename Scalar>
|
||||
int hybrj_template(minpack_funcder_nn fcn, void *p, int n, Scalar *x, Scalar *
|
||||
fvec, Scalar *fjac, int ldfjac, Scalar xtol, int
|
||||
maxfev, Scalar *diag, int mode, Scalar factor, int
|
||||
nprint, int *nfev, int *njev, Scalar *r__,
|
||||
nprint, int &nfev, int &njev, Scalar *r__,
|
||||
int lr, Scalar *qtf, Scalar *wa1, Scalar *wa2,
|
||||
Scalar *wa3, Scalar *wa4)
|
||||
{
|
||||
@ -47,8 +47,8 @@ int hybrj_template(minpack_funcder_nn fcn, void *p, int n, Scalar *x, Scalar *
|
||||
|
||||
info = 0;
|
||||
iflag = 0;
|
||||
*nfev = 0;
|
||||
*njev = 0;
|
||||
nfev = 0;
|
||||
njev = 0;
|
||||
|
||||
/* check the input parameters for errors. */
|
||||
|
||||
@ -71,7 +71,7 @@ L20:
|
||||
/* and calculate its norm. */
|
||||
|
||||
iflag = (*fcn)(p, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, 1);
|
||||
*nfev = 1;
|
||||
nfev = 1;
|
||||
if (iflag < 0) {
|
||||
goto L300;
|
||||
}
|
||||
@ -93,7 +93,7 @@ L30:
|
||||
/* calculate the jacobian matrix. */
|
||||
|
||||
iflag = (*fcn)(p, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, 2);
|
||||
++(*njev);
|
||||
++njev;
|
||||
if (iflag < 0) {
|
||||
goto L300;
|
||||
}
|
||||
@ -237,7 +237,7 @@ L190:
|
||||
/* evaluate the function at x + p and calculate its norm. */
|
||||
|
||||
iflag = (*fcn)(p, n, &wa2[1], &wa4[1], &fjac[fjac_offset], ldfjac, 1);
|
||||
++(*nfev);
|
||||
++nfev;
|
||||
if (iflag < 0) {
|
||||
goto L300;
|
||||
}
|
||||
@ -337,7 +337,7 @@ L260:
|
||||
|
||||
/* tests for termination and stringent tolerances. */
|
||||
|
||||
if (*nfev >= maxfev) {
|
||||
if (nfev >= maxfev) {
|
||||
info = 2;
|
||||
}
|
||||
/* Computing MAX */
|
||||
|
@ -8,7 +8,7 @@ int ei_hybrj1(
|
||||
)
|
||||
{
|
||||
const int n = x.size();
|
||||
int info, nfev, njev;
|
||||
int info, nfev=0, njev=0;
|
||||
Matrix< Scalar, Dynamic, 1> R, qtf, diag;
|
||||
|
||||
/* check the input parameters for errors. */
|
||||
|
@ -4,7 +4,7 @@ int lmder_template(minpack_funcder_mn fcn, void *p, int m, int n, Scalar *x,
|
||||
Scalar *fvec, Scalar *fjac, int ldfjac, Scalar ftol,
|
||||
Scalar xtol, Scalar gtol, int maxfev, Scalar *
|
||||
diag, int mode, Scalar factor, int nprint,
|
||||
int *nfev, int *njev, int *ipvt, Scalar *qtf,
|
||||
int &nfev, int &njev, int *ipvt, Scalar *qtf,
|
||||
Scalar *wa1, Scalar *wa2, Scalar *wa3, Scalar *wa4)
|
||||
{
|
||||
/* Initialized data */
|
||||
@ -40,8 +40,8 @@ int lmder_template(minpack_funcder_mn fcn, void *p, int m, int n, Scalar *x,
|
||||
|
||||
info = 0;
|
||||
iflag = 0;
|
||||
*nfev = 0;
|
||||
*njev = 0;
|
||||
nfev = 0;
|
||||
njev = 0;
|
||||
|
||||
/* check the input parameters for errors. */
|
||||
|
||||
@ -64,7 +64,7 @@ L20:
|
||||
/* and calculate its norm. */
|
||||
|
||||
iflag = (*fcn)(p, m, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, 1);
|
||||
*nfev = 1;
|
||||
nfev = 1;
|
||||
if (iflag < 0) {
|
||||
goto L300;
|
||||
}
|
||||
@ -82,7 +82,7 @@ L30:
|
||||
/* calculate the jacobian matrix. */
|
||||
|
||||
iflag = (*fcn)(p, m, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac, 2);
|
||||
++(*njev);
|
||||
++njev;
|
||||
if (iflag < 0) {
|
||||
goto L300;
|
||||
}
|
||||
@ -235,7 +235,7 @@ L200:
|
||||
/* evaluate the function at x + p and calculate its norm. */
|
||||
|
||||
iflag = (*fcn)(p, m, n, &wa2[1], &wa4[1], &fjac[fjac_offset], ldfjac, 1);
|
||||
++(*nfev);
|
||||
++nfev;
|
||||
if (iflag < 0) {
|
||||
goto L300;
|
||||
}
|
||||
@ -341,7 +341,7 @@ L290:
|
||||
|
||||
/* tests for termination and stringent tolerances. */
|
||||
|
||||
if (*nfev >= maxfev) {
|
||||
if (nfev >= maxfev) {
|
||||
info = 5;
|
||||
}
|
||||
if (ei_abs(actred) <= epsilon<Scalar>() && prered <= epsilon<Scalar>() && p5 * ratio <= 1.) {
|
||||
|
@ -8,7 +8,7 @@ int ei_lmder1(
|
||||
)
|
||||
{
|
||||
const int n = x.size(), m=fvec.size();
|
||||
int info, nfev, njev;
|
||||
int info, nfev=0, njev=0;
|
||||
Matrix< Scalar, Dynamic, Dynamic > fjac(m, n);
|
||||
Matrix< Scalar, Dynamic, 1> diag;
|
||||
|
||||
|
@ -3,8 +3,8 @@ template<typename Scalar>
|
||||
int lmdif_template(minpack_func_mn fcn, void *p, int m, int n, Scalar *x,
|
||||
Scalar *fvec, Scalar ftol, Scalar xtol, Scalar gtol,
|
||||
int maxfev, Scalar epsfcn, Scalar *diag, int
|
||||
mode, Scalar factor, int nprint, int *
|
||||
nfev, Scalar *fjac, int ldfjac, int *ipvt, Scalar *
|
||||
mode, Scalar factor, int nprint, int &nfev,
|
||||
Scalar *fjac, int ldfjac, int *ipvt, Scalar *
|
||||
qtf, Scalar *wa1, Scalar *wa2, Scalar *wa3, Scalar *
|
||||
wa4)
|
||||
{
|
||||
@ -42,7 +42,7 @@ int lmdif_template(minpack_func_mn fcn, void *p, int m, int n, Scalar *x,
|
||||
|
||||
info = 0;
|
||||
iflag = 0;
|
||||
*nfev = 0;
|
||||
nfev = 0;
|
||||
|
||||
/* check the input parameters for errors. */
|
||||
|
||||
@ -65,7 +65,7 @@ L20:
|
||||
/* and calculate its norm. */
|
||||
|
||||
iflag = (*fcn)(p, m, n, &x[1], &fvec[1], 1);
|
||||
*nfev = 1;
|
||||
nfev = 1;
|
||||
if (iflag < 0) {
|
||||
goto L300;
|
||||
}
|
||||
@ -84,7 +84,7 @@ L30:
|
||||
|
||||
iflag = fdjac2(fcn, p, m, n, &x[1], &fvec[1], &fjac[fjac_offset], ldfjac,
|
||||
epsfcn, &wa4[1]);
|
||||
*nfev += n;
|
||||
nfev += n;
|
||||
if (iflag < 0) {
|
||||
goto L300;
|
||||
}
|
||||
@ -237,7 +237,7 @@ L200:
|
||||
/* evaluate the function at x + p and calculate its norm. */
|
||||
|
||||
iflag = (*fcn)(p, m, n, &wa2[1], &wa4[1], 1);
|
||||
++(*nfev);
|
||||
++nfev;
|
||||
if (iflag < 0) {
|
||||
goto L300;
|
||||
}
|
||||
@ -343,7 +343,7 @@ L290:
|
||||
|
||||
/* tests for termination and stringent tolerances. */
|
||||
|
||||
if (*nfev >= maxfev) {
|
||||
if (nfev >= maxfev) {
|
||||
info = 5;
|
||||
}
|
||||
if (ei_abs(actred) <= epsilon<Scalar>() && prered <= epsilon<Scalar>() && p5 * ratio <= 1.) {
|
||||
|
@ -7,7 +7,7 @@ int ei_lmdif1(
|
||||
)
|
||||
{
|
||||
const int n = x.size(), m=fvec.size();
|
||||
int info, nfev;
|
||||
int info, nfev=0;
|
||||
Matrix< Scalar, Dynamic, Dynamic > fjac(m, n);
|
||||
Matrix< Scalar, Dynamic, 1> diag, qtf;
|
||||
VectorXi ipvt;
|
||||
|
@ -4,7 +4,7 @@ int lmstr_template(minpack_funcderstr_mn fcn, void *p, int m, int n, Scalar *x,
|
||||
Scalar *fvec, Scalar *fjac, int ldfjac, Scalar ftol,
|
||||
Scalar xtol, Scalar gtol, int maxfev, Scalar *
|
||||
diag, int mode, Scalar factor, int nprint,
|
||||
int *nfev, int *njev, int *ipvt, Scalar *qtf,
|
||||
int &nfev, int &njev, int *ipvt, Scalar *qtf,
|
||||
Scalar *wa1, Scalar *wa2, Scalar *wa3, Scalar *wa4)
|
||||
{
|
||||
/* Initialized data */
|
||||
@ -41,8 +41,8 @@ int lmstr_template(minpack_funcderstr_mn fcn, void *p, int m, int n, Scalar *x,
|
||||
|
||||
info = 0;
|
||||
iflag = 0;
|
||||
*nfev = 0;
|
||||
*njev = 0;
|
||||
nfev = 0;
|
||||
njev = 0;
|
||||
|
||||
/* check the input parameters for errors. */
|
||||
|
||||
@ -65,7 +65,7 @@ L20:
|
||||
/* and calculate its norm. */
|
||||
|
||||
iflag = (*fcn)(p, m, n, &x[1], &fvec[1], &wa3[1], 1);
|
||||
*nfev = 1;
|
||||
nfev = 1;
|
||||
if (iflag < 0) {
|
||||
goto L340;
|
||||
}
|
||||
@ -118,7 +118,7 @@ L40:
|
||||
++iflag;
|
||||
/* L70: */
|
||||
}
|
||||
++(*njev);
|
||||
++njev;
|
||||
|
||||
/* if the jacobian is rank deficient, call qrfac to */
|
||||
/* reorder its columns and update the components of qtf. */
|
||||
@ -259,7 +259,7 @@ L240:
|
||||
/* evaluate the function at x + p and calculate its norm. */
|
||||
|
||||
iflag = (*fcn)(p, m, n, &wa2[1], &wa4[1], &wa3[1], 1);
|
||||
++(*nfev);
|
||||
++nfev;
|
||||
if (iflag < 0) {
|
||||
goto L340;
|
||||
}
|
||||
@ -366,7 +366,7 @@ L330:
|
||||
|
||||
/* tests for termination and stringent tolerances. */
|
||||
|
||||
if (*nfev >= maxfev) {
|
||||
if (nfev >= maxfev) {
|
||||
info = 5;
|
||||
}
|
||||
if (ei_abs(actred) <= epsilon<Scalar>() && prered <= epsilon<Scalar>() && p5 * ratio <= 1.) {
|
||||
|
@ -8,7 +8,7 @@ int ei_lmstr1(
|
||||
)
|
||||
{
|
||||
const int n = x.size(), m=fvec.size();
|
||||
int info, nfev, njev;
|
||||
int info, nfev=0, njev=0;
|
||||
Matrix< Scalar, Dynamic, Dynamic > fjac(m, n);
|
||||
Matrix< Scalar, Dynamic, 1> diag;
|
||||
|
||||
|
@ -216,7 +216,7 @@ struct lmder_functor {
|
||||
void testLmder()
|
||||
{
|
||||
const int m=15, n=3;
|
||||
int info, nfev, njev;
|
||||
int info, nfev=0, njev=0;
|
||||
double fnorm, covfac, covar_ftol;
|
||||
VectorXd x(n), fvec(m), diag(n);
|
||||
MatrixXd fjac;
|
||||
@ -379,7 +379,7 @@ struct hybrj_functor {
|
||||
void testHybrj()
|
||||
{
|
||||
const int n=9;
|
||||
int info, nfev, njev, mode;
|
||||
int info, nfev=0, njev=0, mode;
|
||||
VectorXd x(n), fvec, diag(n), R, qtf;
|
||||
MatrixXd fjac;
|
||||
|
||||
@ -485,7 +485,7 @@ struct hybrd_functor {
|
||||
void testHybrd()
|
||||
{
|
||||
const int n=9;
|
||||
int info, nfev, ml, mu, mode;
|
||||
int info, nfev=0, ml, mu, mode;
|
||||
VectorXd x(n), fvec, diag(n), R, qtf;
|
||||
MatrixXd fjac;
|
||||
|
||||
@ -624,7 +624,7 @@ struct lmstr_functor {
|
||||
void testLmstr()
|
||||
{
|
||||
const int m=15, n=3;
|
||||
int info, nfev, njev;
|
||||
int info, nfev=0, njev=0;
|
||||
double fnorm;
|
||||
VectorXd x(n), fvec(m), diag(n);
|
||||
MatrixXd fjac;
|
||||
@ -732,7 +732,7 @@ struct lmdif_functor {
|
||||
void testLmdif()
|
||||
{
|
||||
const int m=15, n=3;
|
||||
int info, nfev;
|
||||
int info, nfev=0;
|
||||
double fnorm, covfac, covar_ftol;
|
||||
VectorXd x(n), fvec(m), diag(n), qtf;
|
||||
MatrixXd fjac;
|
||||
@ -812,7 +812,7 @@ struct chwirut2_functor {
|
||||
void testNistChwirut2(void)
|
||||
{
|
||||
const int m=54, n=3;
|
||||
int info, nfev, njev;
|
||||
int info, nfev=0, njev=0;
|
||||
|
||||
VectorXd x(n), fvec(m), diag;
|
||||
MatrixXd fjac;
|
||||
@ -886,7 +886,7 @@ struct misra1a_functor {
|
||||
void testNistMisra1a(void)
|
||||
{
|
||||
const int m=14, n=2;
|
||||
int info, nfev, njev;
|
||||
int info, nfev=0, njev=0;
|
||||
|
||||
VectorXd x(n), fvec(m), diag;
|
||||
MatrixXd fjac;
|
||||
@ -966,7 +966,7 @@ struct hahn1_functor {
|
||||
void testNistHahn1(void)
|
||||
{
|
||||
const int m=236, n=7;
|
||||
int info, nfev, njev;
|
||||
int info, nfev=0, njev=0;
|
||||
|
||||
VectorXd x(n), fvec(m), diag;
|
||||
MatrixXd fjac;
|
||||
@ -1048,7 +1048,7 @@ struct misra1d_functor {
|
||||
void testNistMisra1d(void)
|
||||
{
|
||||
const int m=14, n=2;
|
||||
int info, nfev, njev;
|
||||
int info, nfev=0, njev=0;
|
||||
|
||||
VectorXd x(n), fvec(m), diag;
|
||||
MatrixXd fjac;
|
||||
@ -1123,7 +1123,7 @@ struct lanczos1_functor {
|
||||
void testNistLanczos1(void)
|
||||
{
|
||||
const int m=24, n=6;
|
||||
int info, nfev, njev;
|
||||
int info, nfev=0, njev=0;
|
||||
|
||||
VectorXd x(n), fvec(m), diag;
|
||||
MatrixXd fjac;
|
||||
@ -1204,7 +1204,7 @@ struct rat42_functor {
|
||||
void testNistRat42(void)
|
||||
{
|
||||
const int m=9, n=3;
|
||||
int info, nfev, njev;
|
||||
int info, nfev=0, njev=0;
|
||||
|
||||
VectorXd x(n), fvec(m), diag;
|
||||
MatrixXd fjac;
|
||||
@ -1279,7 +1279,7 @@ struct MGH10_functor {
|
||||
void testNistMGH10(void)
|
||||
{
|
||||
const int m=16, n=3;
|
||||
int info, nfev, njev;
|
||||
int info, nfev=0, njev=0;
|
||||
|
||||
VectorXd x(n), fvec(m), diag;
|
||||
MatrixXd fjac;
|
||||
@ -1353,7 +1353,7 @@ struct BoxBOD_functor {
|
||||
void testNistBoxBOD(void)
|
||||
{
|
||||
const int m=6, n=2;
|
||||
int info, nfev, njev;
|
||||
int info, nfev=0, njev=0;
|
||||
|
||||
VectorXd x(n), fvec(m), diag;
|
||||
MatrixXd fjac;
|
||||
@ -1428,7 +1428,7 @@ struct MGH17_functor {
|
||||
void testNistMGH17(void)
|
||||
{
|
||||
const int m=33, n=5;
|
||||
int info, nfev, njev;
|
||||
int info, nfev=0, njev=0;
|
||||
|
||||
VectorXd x(n), fvec(m), diag;
|
||||
MatrixXd fjac;
|
||||
@ -1513,7 +1513,7 @@ struct MGH09_functor {
|
||||
void testNistMGH09(void)
|
||||
{
|
||||
const int m=11, n=4;
|
||||
int info, nfev, njev;
|
||||
int info, nfev=0, njev=0;
|
||||
|
||||
VectorXd x(n), fvec(m), diag;
|
||||
MatrixXd fjac;
|
||||
@ -1594,7 +1594,7 @@ struct Bennett5_functor {
|
||||
void testNistBennett5(void)
|
||||
{
|
||||
const int m=154, n=3;
|
||||
int info, nfev, njev;
|
||||
int info, nfev=0, njev=0;
|
||||
|
||||
VectorXd x(n), fvec(m), diag;
|
||||
MatrixXd fjac;
|
||||
@ -1676,7 +1676,7 @@ struct thurber_functor {
|
||||
void testNistThurber(void)
|
||||
{
|
||||
const int m=37, n=7;
|
||||
int info, nfev, njev;
|
||||
int info, nfev=0, njev=0;
|
||||
|
||||
VectorXd x(n), fvec(m), diag;
|
||||
MatrixXd fjac;
|
||||
@ -1762,7 +1762,7 @@ struct rat43_functor {
|
||||
void testNistRat43(void)
|
||||
{
|
||||
const int m=15, n=4;
|
||||
int info, nfev, njev;
|
||||
int info, nfev=0, njev=0;
|
||||
|
||||
VectorXd x(n), fvec(m), diag;
|
||||
MatrixXd fjac;
|
||||
@ -1844,7 +1844,7 @@ struct eckerle4_functor {
|
||||
void testNistEckerle4(void)
|
||||
{
|
||||
const int m=35, n=3;
|
||||
int info, nfev, njev;
|
||||
int info, nfev=0, njev=0;
|
||||
|
||||
VectorXd x(n), fvec(m), diag;
|
||||
MatrixXd fjac;
|
||||
|
Loading…
Reference in New Issue
Block a user