From 9294d33a116913c24f50c87c2529981b2898d03a Mon Sep 17 00:00:00 2001 From: Thomas Capricelli Date: Fri, 21 Aug 2009 00:23:26 +0200 Subject: [PATCH] use references intead of pointers for njev/nfev --- .../Eigen/src/NonLinear/MathFunctions.h | 12 +++--- unsupported/Eigen/src/NonLinear/hybrd.h | 12 +++--- unsupported/Eigen/src/NonLinear/hybrd1.h | 2 +- unsupported/Eigen/src/NonLinear/hybrj.h | 14 +++---- unsupported/Eigen/src/NonLinear/hybrj1.h | 2 +- unsupported/Eigen/src/NonLinear/lmder.h | 14 +++---- unsupported/Eigen/src/NonLinear/lmder1.h | 2 +- unsupported/Eigen/src/NonLinear/lmdif.h | 14 +++---- unsupported/Eigen/src/NonLinear/lmdif1.h | 2 +- unsupported/Eigen/src/NonLinear/lmstr.h | 14 +++---- unsupported/Eigen/src/NonLinear/lmstr1.h | 2 +- unsupported/test/NonLinear.cpp | 38 +++++++++---------- 12 files changed, 64 insertions(+), 64 deletions(-) diff --git a/unsupported/Eigen/src/NonLinear/MathFunctions.h b/unsupported/Eigen/src/NonLinear/MathFunctions.h index 7d9337fc4..79e495a7e 100644 --- a/unsupported/Eigen/src/NonLinear/MathFunctions.h +++ b/unsupported/Eigen/src/NonLinear/MathFunctions.h @@ -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(), diff --git a/unsupported/Eigen/src/NonLinear/hybrd.h b/unsupported/Eigen/src/NonLinear/hybrd.h index 3995e4299..e8179a25d 100644 --- a/unsupported/Eigen/src/NonLinear/hybrd.h +++ b/unsupported/Eigen/src/NonLinear/hybrd.h @@ -2,7 +2,7 @@ template 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 */ diff --git a/unsupported/Eigen/src/NonLinear/hybrd1.h b/unsupported/Eigen/src/NonLinear/hybrd1.h index b8ab8d13b..47b64d8e8 100644 --- a/unsupported/Eigen/src/NonLinear/hybrd1.h +++ b/unsupported/Eigen/src/NonLinear/hybrd1.h @@ -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; diff --git a/unsupported/Eigen/src/NonLinear/hybrj.h b/unsupported/Eigen/src/NonLinear/hybrj.h index a9a4fbf4e..dcac33dba 100644 --- a/unsupported/Eigen/src/NonLinear/hybrj.h +++ b/unsupported/Eigen/src/NonLinear/hybrj.h @@ -3,7 +3,7 @@ template 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 */ diff --git a/unsupported/Eigen/src/NonLinear/hybrj1.h b/unsupported/Eigen/src/NonLinear/hybrj1.h index 52953330a..c32b0cf95 100644 --- a/unsupported/Eigen/src/NonLinear/hybrj1.h +++ b/unsupported/Eigen/src/NonLinear/hybrj1.h @@ -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. */ diff --git a/unsupported/Eigen/src/NonLinear/lmder.h b/unsupported/Eigen/src/NonLinear/lmder.h index 2d11445b2..a0807dc4e 100644 --- a/unsupported/Eigen/src/NonLinear/lmder.h +++ b/unsupported/Eigen/src/NonLinear/lmder.h @@ -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() && prered <= epsilon() && p5 * ratio <= 1.) { diff --git a/unsupported/Eigen/src/NonLinear/lmder1.h b/unsupported/Eigen/src/NonLinear/lmder1.h index b12f7595a..f9fb01ce5 100644 --- a/unsupported/Eigen/src/NonLinear/lmder1.h +++ b/unsupported/Eigen/src/NonLinear/lmder1.h @@ -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; diff --git a/unsupported/Eigen/src/NonLinear/lmdif.h b/unsupported/Eigen/src/NonLinear/lmdif.h index f13f6c974..0d44dbf6a 100644 --- a/unsupported/Eigen/src/NonLinear/lmdif.h +++ b/unsupported/Eigen/src/NonLinear/lmdif.h @@ -3,8 +3,8 @@ template 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() && prered <= epsilon() && p5 * ratio <= 1.) { diff --git a/unsupported/Eigen/src/NonLinear/lmdif1.h b/unsupported/Eigen/src/NonLinear/lmdif1.h index 7a82c551f..6b795b010 100644 --- a/unsupported/Eigen/src/NonLinear/lmdif1.h +++ b/unsupported/Eigen/src/NonLinear/lmdif1.h @@ -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; diff --git a/unsupported/Eigen/src/NonLinear/lmstr.h b/unsupported/Eigen/src/NonLinear/lmstr.h index bb544e451..2f4549063 100644 --- a/unsupported/Eigen/src/NonLinear/lmstr.h +++ b/unsupported/Eigen/src/NonLinear/lmstr.h @@ -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() && prered <= epsilon() && p5 * ratio <= 1.) { diff --git a/unsupported/Eigen/src/NonLinear/lmstr1.h b/unsupported/Eigen/src/NonLinear/lmstr1.h index b1e1827b3..896bba394 100644 --- a/unsupported/Eigen/src/NonLinear/lmstr1.h +++ b/unsupported/Eigen/src/NonLinear/lmstr1.h @@ -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; diff --git a/unsupported/test/NonLinear.cpp b/unsupported/test/NonLinear.cpp index 26d1bdf6b..5610785d8 100644 --- a/unsupported/test/NonLinear.cpp +++ b/unsupported/test/NonLinear.cpp @@ -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;