diff options
author | Thomas Capricelli <orzel@freehackers.org> | 2009-08-20 21:10:28 +0200 |
---|---|---|
committer | Thomas Capricelli <orzel@freehackers.org> | 2009-08-20 21:10:28 +0200 |
commit | a84dc9a5c1f203b4c48d61a9a398eefd9f442ea0 (patch) | |
tree | 78e3e5a63a18d0654e01fbc6cc241ba20d918420 | |
parent | df98e660195fdfb42f1aec3809dd005eaed69aba (diff) |
coherency for scalar typename : use "Scalar" everywhere
-rw-r--r-- | unsupported/Eigen/src/NonLinear/chkder.h | 18 | ||||
-rw-r--r-- | unsupported/Eigen/src/NonLinear/hybrd.h | 43 | ||||
-rw-r--r-- | unsupported/Eigen/src/NonLinear/hybrd1.h | 12 | ||||
-rw-r--r-- | unsupported/Eigen/src/NonLinear/hybrj.h | 44 | ||||
-rw-r--r-- | unsupported/Eigen/src/NonLinear/hybrj1.h | 12 | ||||
-rw-r--r-- | unsupported/Eigen/src/NonLinear/lmder.h | 44 | ||||
-rw-r--r-- | unsupported/Eigen/src/NonLinear/lmder1.h | 13 | ||||
-rw-r--r-- | unsupported/Eigen/src/NonLinear/lmdif.h | 47 | ||||
-rw-r--r-- | unsupported/Eigen/src/NonLinear/lmdif1.h | 14 | ||||
-rw-r--r-- | unsupported/Eigen/src/NonLinear/lmstr.h | 46 | ||||
-rw-r--r-- | unsupported/Eigen/src/NonLinear/lmstr1.h | 12 |
11 files changed, 151 insertions, 154 deletions
diff --git a/unsupported/Eigen/src/NonLinear/chkder.h b/unsupported/Eigen/src/NonLinear/chkder.h index 89552d530..f7b4693fd 100644 --- a/unsupported/Eigen/src/NonLinear/chkder.h +++ b/unsupported/Eigen/src/NonLinear/chkder.h @@ -4,18 +4,18 @@ /* Table of constant values */ -template<typename T> -void chkder_template(int m, int n, const T *x, - T *fvec, T *fjac, int ldfjac, T *xp, - T *fvecp, int mode, T *err) +template<typename Scalar> +void chkder_template(int m, int n, const Scalar *x, + Scalar *fvec, Scalar *fjac, int ldfjac, Scalar *xp, + Scalar *fvecp, int mode, Scalar *err) { /* System generated locals */ int fjac_dim1, fjac_offset, i__1, i__2; /* Local variables */ int i__, j; - T eps, epsf, temp; - T epslog; + Scalar eps, epsf, temp; + Scalar epslog; /* Parameter adjustments */ --err; @@ -29,7 +29,7 @@ void chkder_template(int m, int n, const T *x, /* Function Body */ - eps = ei_sqrt(epsilon<T>()); + eps = ei_sqrt(epsilon<Scalar>()); if (mode == 2) { goto L20; @@ -52,7 +52,7 @@ L20: /* mode = 2. */ - epsf = chkder_factor * epsilon<T>(); + epsf = chkder_factor * epsilon<Scalar>(); epslog = chkder_log10e * log(eps); i__1 = m; for (i__ = 1; i__ <= i__1; ++i__) { @@ -83,7 +83,7 @@ L20: fabs(fvecp[i__])); } err[i__] = 1.; - if (temp > epsilon<T>() && temp < eps) { + if (temp > epsilon<Scalar>() && temp < eps) { err[i__] = (chkder_log10e * log(temp) - epslog) / epslog; } if (temp >= eps) { diff --git a/unsupported/Eigen/src/NonLinear/hybrd.h b/unsupported/Eigen/src/NonLinear/hybrd.h index 6a28b63e4..d8a41b9ba 100644 --- a/unsupported/Eigen/src/NonLinear/hybrd.h +++ b/unsupported/Eigen/src/NonLinear/hybrd.h @@ -1,34 +1,33 @@ -template<typename T> -int hybrd_template(minpack_func_nn fcn, void *p, int n, T *x, T * - fvec, T xtol, int maxfev, int ml, int mu, - T epsfcn, T *diag, int mode, T - factor, int nprint, int *nfev, T * - fjac, int ldfjac, T *r__, int lr, T *qtf, - T *wa1, T *wa2, T *wa3, T *wa4) +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 * + fjac, int ldfjac, Scalar *r__, int lr, Scalar *qtf, + Scalar *wa1, Scalar *wa2, Scalar *wa3, Scalar *wa4) { /* Initialized data */ /* System generated locals */ int fjac_dim1, fjac_offset, i__1, i__2; - T d__1, d__2; + Scalar d__1, d__2; /* Local variables */ int i__, j, l, jm1, iwa[1]; - T sum; + Scalar sum; int sing; int iter; - T temp; + Scalar temp; int msum, iflag; - T delta; + Scalar delta; int jeval; int ncsuc; - T ratio; - T fnorm; - T pnorm, xnorm, fnorm1; + Scalar ratio; + Scalar fnorm; + Scalar pnorm, xnorm, fnorm1; int nslow1, nslow2; int ncfail; - T actred, prered; + Scalar actred, prered; int info; /* Parameter adjustments */ @@ -77,7 +76,7 @@ L20: if (iflag < 0) { goto L300; } - fnorm = ei_enorm<T>(n, &fvec[1]); + fnorm = ei_enorm<Scalar>(n, &fvec[1]); /* determine the number of calls to fcn needed to compute */ /* the jacobian matrix. */ @@ -140,7 +139,7 @@ L50: wa3[j] = diag[j] * x[j]; /* L60: */ } - xnorm = ei_enorm<T>(n, &wa3[1]); + xnorm = ei_enorm<Scalar>(n, &wa3[1]); delta = factor * xnorm; if (delta == 0.) { delta = factor; @@ -250,7 +249,7 @@ L190: wa3[j] = diag[j] * wa1[j]; /* L200: */ } - pnorm = ei_enorm<T>(n, &wa3[1]); + pnorm = ei_enorm<Scalar>(n, &wa3[1]); /* on the first iteration, adjust the initial step bound. */ @@ -265,7 +264,7 @@ L190: if (iflag < 0) { goto L300; } - fnorm1 = ei_enorm<T>(n, &wa4[1]); + fnorm1 = ei_enorm<Scalar>(n, &wa4[1]); /* compute the scaled actual reduction. */ @@ -291,7 +290,7 @@ L190: wa3[i__] = qtf[i__] + sum; /* L220: */ } - temp = ei_enorm<T>(n, &wa3[1]); + temp = ei_enorm<Scalar>(n, &wa3[1]); prered = 0.; if (temp < fnorm) { /* Computing 2nd power */ @@ -344,7 +343,7 @@ L240: fvec[j] = wa4[j]; /* L250: */ } - xnorm = ei_enorm<T>(n, &wa2[1]); + xnorm = ei_enorm<Scalar>(n, &wa2[1]); fnorm = fnorm1; ++iter; L260: @@ -378,7 +377,7 @@ L260: } /* Computing MAX */ d__1 = p1 * delta; - if (p1 * max(d__1,pnorm) <= epsilon<T>() * xnorm) { + if (p1 * max(d__1,pnorm) <= epsilon<Scalar>() * xnorm) { info = 3; } if (nslow2 == 5) { diff --git a/unsupported/Eigen/src/NonLinear/hybrd1.h b/unsupported/Eigen/src/NonLinear/hybrd1.h index dd9fb86d7..71feb64b1 100644 --- a/unsupported/Eigen/src/NonLinear/hybrd1.h +++ b/unsupported/Eigen/src/NonLinear/hybrd1.h @@ -1,20 +1,20 @@ -template<typename T> -int hybrd1_template(minpack_func_nn fcn, void *p, int n, T *x, T * - fvec, T tol, T *wa, int lwa) +template<typename Scalar> +int hybrd1_template(minpack_func_nn fcn, void *p, int n, Scalar *x, Scalar * + fvec, Scalar tol, Scalar *wa, int lwa) { /* Initialized data */ - const T factor = 100.; + const Scalar factor = 100.; /* System generated locals */ int i__1; /* Local variables */ int j, ml, lr, mu, mode, nfev; - T xtol; + Scalar xtol; int index; - T epsfcn; + Scalar epsfcn; int maxfev, nprint; int info; diff --git a/unsupported/Eigen/src/NonLinear/hybrj.h b/unsupported/Eigen/src/NonLinear/hybrj.h index 013757ae7..4a259f8fe 100644 --- a/unsupported/Eigen/src/NonLinear/hybrj.h +++ b/unsupported/Eigen/src/NonLinear/hybrj.h @@ -1,34 +1,34 @@ -template<typename T> -int hybrj_template(minpack_funcder_nn fcn, void *p, int n, T *x, T * - fvec, T *fjac, int ldfjac, T xtol, int - maxfev, T *diag, int mode, T factor, int - nprint, int *nfev, int *njev, T *r__, - int lr, T *qtf, T *wa1, T *wa2, - T *wa3, T *wa4) +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__, + int lr, Scalar *qtf, Scalar *wa1, Scalar *wa2, + Scalar *wa3, Scalar *wa4) { /* Initialized data */ /* System generated locals */ int fjac_dim1, fjac_offset, i__1, i__2; - T d__1, d__2; + Scalar d__1, d__2; /* Local variables */ int i__, j, l, jm1, iwa[1]; - T sum; + Scalar sum; int sing; int iter; - T temp; + Scalar temp; int iflag; - T delta; + Scalar delta; int jeval; int ncsuc; - T ratio; - T fnorm; - T pnorm, xnorm, fnorm1; + Scalar ratio; + Scalar fnorm; + Scalar pnorm, xnorm, fnorm1; int nslow1, nslow2; int ncfail; - T actred, prered; + Scalar actred, prered; int info; /* Parameter adjustments */ @@ -78,7 +78,7 @@ L20: if (iflag < 0) { goto L300; } - fnorm = ei_enorm<T>(n, &fvec[1]); + fnorm = ei_enorm<Scalar>(n, &fvec[1]); /* initialize iteration counter and monitors. */ @@ -133,7 +133,7 @@ L50: wa3[j] = diag[j] * x[j]; /* L60: */ } - xnorm = ei_enorm<T>(n, &wa3[1]); + xnorm = ei_enorm<Scalar>(n, &wa3[1]); delta = factor * xnorm; if (delta == 0.) { delta = factor; @@ -243,7 +243,7 @@ L190: wa3[j] = diag[j] * wa1[j]; /* L200: */ } - pnorm = ei_enorm<T>(n, &wa3[1]); + pnorm = ei_enorm<Scalar>(n, &wa3[1]); /* on the first iteration, adjust the initial step bound. */ @@ -258,7 +258,7 @@ L190: if (iflag < 0) { goto L300; } - fnorm1 = ei_enorm<T>(n, &wa4[1]); + fnorm1 = ei_enorm<Scalar>(n, &wa4[1]); /* compute the scaled actual reduction. */ @@ -284,7 +284,7 @@ L190: wa3[i__] = qtf[i__] + sum; /* L220: */ } - temp = ei_enorm<T>(n, &wa3[1]); + temp = ei_enorm<Scalar>(n, &wa3[1]); prered = 0.; if (temp < fnorm) { /* Computing 2nd power */ @@ -337,7 +337,7 @@ L240: fvec[j] = wa4[j]; /* L250: */ } - xnorm = ei_enorm<T>(n, &wa2[1]); + xnorm = ei_enorm<Scalar>(n, &wa2[1]); fnorm = fnorm1; ++iter; L260: @@ -371,7 +371,7 @@ L260: } /* Computing MAX */ d__1 = p1 * delta; - if (p1 * max(d__1,pnorm) <= epsilon<T>() * xnorm) { + if (p1 * max(d__1,pnorm) <= epsilon<Scalar>() * xnorm) { info = 3; } if (nslow2 == 5) { diff --git a/unsupported/Eigen/src/NonLinear/hybrj1.h b/unsupported/Eigen/src/NonLinear/hybrj1.h index 04548467f..66a7db9b7 100644 --- a/unsupported/Eigen/src/NonLinear/hybrj1.h +++ b/unsupported/Eigen/src/NonLinear/hybrj1.h @@ -1,19 +1,19 @@ -template<typename T> -int hybrj1_template(minpack_funcder_nn fcn, void *p, int n, T *x, T * - fvec, T *fjac, int ldfjac, T tol, - T *wa, int lwa) +template<typename Scalar> +int hybrj1_template(minpack_funcder_nn fcn, void *p, int n, Scalar *x, Scalar * + fvec, Scalar *fjac, int ldfjac, Scalar tol, + Scalar *wa, int lwa) { /* Initialized data */ - const T factor = 100.; + const Scalar factor = 100.; /* System generated locals */ int fjac_dim1, fjac_offset, i__1; /* Local variables */ int j, lr, mode, nfev, njev; - T xtol; + Scalar xtol; int maxfev, nprint; int info; diff --git a/unsupported/Eigen/src/NonLinear/lmder.h b/unsupported/Eigen/src/NonLinear/lmder.h index 99b912f4b..4d5757427 100644 --- a/unsupported/Eigen/src/NonLinear/lmder.h +++ b/unsupported/Eigen/src/NonLinear/lmder.h @@ -1,27 +1,27 @@ -template<typename T> -int lmder_template(minpack_funcder_mn fcn, void *p, int m, int n, T *x, - T *fvec, T *fjac, int ldfjac, T ftol, - T xtol, T gtol, int maxfev, T * - diag, int mode, T factor, int nprint, - int *nfev, int *njev, int *ipvt, T *qtf, - T *wa1, T *wa2, T *wa3, T *wa4) +template<typename Scalar> +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, + Scalar *wa1, Scalar *wa2, Scalar *wa3, Scalar *wa4) { /* Initialized data */ /* System generated locals */ int fjac_dim1, fjac_offset, i__1, i__2; - T d__1, d__2, d__3; + Scalar d__1, d__2, d__3; /* Local variables */ int i__, j, l; - T par, sum; + Scalar par, sum; int iter; - T temp, temp1, temp2; + Scalar temp, temp1, temp2; int iflag; - T delta; - T ratio; - T fnorm, gnorm, pnorm, xnorm, fnorm1, actred, dirder, prered; + Scalar delta; + Scalar ratio; + Scalar fnorm, gnorm, pnorm, xnorm, fnorm1, actred, dirder, prered; int info; /* Parameter adjustments */ @@ -71,7 +71,7 @@ L20: if (iflag < 0) { goto L300; } - fnorm = ei_enorm<T>(m, &fvec[1]); + fnorm = ei_enorm<Scalar>(m, &fvec[1]); /* initialize levenberg-marquardt parameter and iteration counter. */ @@ -136,7 +136,7 @@ L60: wa3[j] = diag[j] * x[j]; /* L70: */ } - xnorm = ei_enorm<T>(n, &wa3[1]); + xnorm = ei_enorm<Scalar>(n, &wa3[1]); delta = factor * xnorm; if (delta == 0.) { delta = factor; @@ -242,7 +242,7 @@ L200: wa3[j] = diag[j] * wa1[j]; /* L210: */ } - pnorm = ei_enorm<T>(n, &wa3[1]); + pnorm = ei_enorm<Scalar>(n, &wa3[1]); /* on the first iteration, adjust the initial step bound. */ @@ -257,7 +257,7 @@ L200: if (iflag < 0) { goto L300; } - fnorm1 = ei_enorm<T>(m, &wa4[1]); + fnorm1 = ei_enorm<Scalar>(m, &wa4[1]); /* compute the scaled actual reduction. */ @@ -283,7 +283,7 @@ L200: } /* L230: */ } - temp1 = ei_enorm<T>(n, &wa3[1]) / fnorm; + temp1 = ei_enorm<Scalar>(n, &wa3[1]) / fnorm; temp2 = sqrt(par) * pnorm / fnorm; /* Computing 2nd power */ d__1 = temp1; @@ -351,7 +351,7 @@ L260: fvec[i__] = wa4[i__]; /* L280: */ } - xnorm = ei_enorm<T>(n, &wa2[1]); + xnorm = ei_enorm<Scalar>(n, &wa2[1]); fnorm = fnorm1; ++iter; L290: @@ -377,13 +377,13 @@ L290: if (*nfev >= maxfev) { info = 5; } - if (fabs(actred) <= epsilon<T>() && prered <= epsilon<T>() && p5 * ratio <= 1.) { + if (fabs(actred) <= epsilon<Scalar>() && prered <= epsilon<Scalar>() && p5 * ratio <= 1.) { info = 6; } - if (delta <= epsilon<T>() * xnorm) { + if (delta <= epsilon<Scalar>() * xnorm) { info = 7; } - if (gnorm <= epsilon<T>()) { + if (gnorm <= epsilon<Scalar>()) { info = 8; } if (info != 0) { diff --git a/unsupported/Eigen/src/NonLinear/lmder1.h b/unsupported/Eigen/src/NonLinear/lmder1.h index 2cbaa5b93..51f1a479f 100644 --- a/unsupported/Eigen/src/NonLinear/lmder1.h +++ b/unsupported/Eigen/src/NonLinear/lmder1.h @@ -1,20 +1,19 @@ - -template<typename T> -int lmder1_template(minpack_funcder_mn fcn, void *p, int m, int n, T *x, - T *fvec, T *fjac, int ldfjac, T tol, - int *ipvt, T *wa, int lwa) +template<typename Scalar> +int lmder1_template(minpack_funcder_mn fcn, void *p, int m, int n, Scalar *x, + Scalar *fvec, Scalar *fjac, int ldfjac, Scalar tol, + int *ipvt, Scalar *wa, int lwa) { /* Initialized data */ - const T factor = 100.; + const Scalar factor = 100.; /* System generated locals */ int fjac_dim1, fjac_offset; /* Local variables */ int mode, nfev, njev; - T ftol, gtol, xtol; + Scalar ftol, gtol, xtol; int maxfev, nprint; int info; diff --git a/unsupported/Eigen/src/NonLinear/lmdif.h b/unsupported/Eigen/src/NonLinear/lmdif.h index da04caacf..4dd4c19b3 100644 --- a/unsupported/Eigen/src/NonLinear/lmdif.h +++ b/unsupported/Eigen/src/NonLinear/lmdif.h @@ -1,30 +1,29 @@ - -template<typename T> -int lmdif_template(minpack_func_mn fcn, void *p, int m, int n, T *x, - T *fvec, T ftol, T xtol, T - gtol, int maxfev, T epsfcn, T *diag, int - mode, T factor, int nprint, int * - nfev, T *fjac, int ldfjac, int *ipvt, T * - qtf, T *wa1, T *wa2, T *wa3, T * +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 * + qtf, Scalar *wa1, Scalar *wa2, Scalar *wa3, Scalar * wa4) { /* Initialized data */ /* System generated locals */ int fjac_dim1, fjac_offset, i__1, i__2; - T d__1, d__2, d__3; + Scalar d__1, d__2, d__3; /* Local variables */ int i__, j, l; - T par, sum; + Scalar par, sum; int iter; - T temp, temp1, temp2; + Scalar temp, temp1, temp2; int iflag; - T delta; - T ratio; - T fnorm, gnorm; - T pnorm, xnorm, fnorm1, actred, dirder, prered; + Scalar delta; + Scalar ratio; + Scalar fnorm, gnorm; + Scalar pnorm, xnorm, fnorm1, actred, dirder, prered; int info; /* Parameter adjustments */ @@ -73,7 +72,7 @@ L20: if (iflag < 0) { goto L300; } - fnorm = ei_enorm<T>(m, &fvec[1]); + fnorm = ei_enorm<Scalar>(m, &fvec[1]); /* initialize levenberg-marquardt parameter and iteration counter. */ @@ -139,7 +138,7 @@ L60: wa3[j] = diag[j] * x[j]; /* L70: */ } - xnorm = ei_enorm<T>(n, &wa3[1]); + xnorm = ei_enorm<Scalar>(n, &wa3[1]); delta = factor * xnorm; if (delta == 0.) { delta = factor; @@ -245,7 +244,7 @@ L200: wa3[j] = diag[j] * wa1[j]; /* L210: */ } - pnorm = ei_enorm<T>(n, &wa3[1]); + pnorm = ei_enorm<Scalar>(n, &wa3[1]); /* on the first iteration, adjust the initial step bound. */ @@ -260,7 +259,7 @@ L200: if (iflag < 0) { goto L300; } - fnorm1 = ei_enorm<T>(m, &wa4[1]); + fnorm1 = ei_enorm<Scalar>(m, &wa4[1]); /* compute the scaled actual reduction. */ @@ -286,7 +285,7 @@ L200: } /* L230: */ } - temp1 = ei_enorm<T>(n, &wa3[1]) / fnorm; + temp1 = ei_enorm<Scalar>(n, &wa3[1]) / fnorm; temp2 = sqrt(par) * pnorm / fnorm; /* Computing 2nd power */ d__1 = temp1; @@ -354,7 +353,7 @@ L260: fvec[i__] = wa4[i__]; /* L280: */ } - xnorm = ei_enorm<T>(n, &wa2[1]); + xnorm = ei_enorm<Scalar>(n, &wa2[1]); fnorm = fnorm1; ++iter; L290: @@ -380,13 +379,13 @@ L290: if (*nfev >= maxfev) { info = 5; } - if (fabs(actred) <= epsilon<T>() && prered <= epsilon<T>() && p5 * ratio <= 1.) { + if (fabs(actred) <= epsilon<Scalar>() && prered <= epsilon<Scalar>() && p5 * ratio <= 1.) { info = 6; } - if (delta <= epsilon<T>() * xnorm) { + if (delta <= epsilon<Scalar>() * xnorm) { info = 7; } - if (gnorm <= epsilon<T>()) { + if (gnorm <= epsilon<Scalar>()) { info = 8; } if (info != 0) { diff --git a/unsupported/Eigen/src/NonLinear/lmdif1.h b/unsupported/Eigen/src/NonLinear/lmdif1.h index 8f8610067..8dfd59db7 100644 --- a/unsupported/Eigen/src/NonLinear/lmdif1.h +++ b/unsupported/Eigen/src/NonLinear/lmdif1.h @@ -1,16 +1,16 @@ -template<typename T> -int lmdif1_template(minpack_func_mn fcn, void *p, int m, int n, T *x, - T *fvec, T tol, int *iwa, - T *wa, int lwa) +template<typename Scalar> +int lmdif1_template(minpack_func_mn fcn, void *p, int m, int n, Scalar *x, + Scalar *fvec, Scalar tol, int *iwa, + Scalar *wa, int lwa) { /* Initialized data */ - const T factor = 100.; + const Scalar factor = 100.; int mp5n, mode, nfev; - T ftol, gtol, xtol; - T epsfcn; + Scalar ftol, gtol, xtol; + Scalar epsfcn; int maxfev, nprint; int info; diff --git a/unsupported/Eigen/src/NonLinear/lmstr.h b/unsupported/Eigen/src/NonLinear/lmstr.h index 015e0bd13..4bb594380 100644 --- a/unsupported/Eigen/src/NonLinear/lmstr.h +++ b/unsupported/Eigen/src/NonLinear/lmstr.h @@ -1,28 +1,28 @@ -template<typename T> -int lmstr_template(minpack_funcderstr_mn fcn, void *p, int m, int n, T *x, - T *fvec, T *fjac, int ldfjac, T ftol, - T xtol, T gtol, int maxfev, T * - diag, int mode, T factor, int nprint, - int *nfev, int *njev, int *ipvt, T *qtf, - T *wa1, T *wa2, T *wa3, T *wa4) +template<typename Scalar> +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, + Scalar *wa1, Scalar *wa2, Scalar *wa3, Scalar *wa4) { /* Initialized data */ /* System generated locals */ int fjac_dim1, fjac_offset, i__1, i__2; - T d__1, d__2, d__3; + Scalar d__1, d__2, d__3; /* Local variables */ int i__, j, l; - T par, sum; + Scalar par, sum; int sing; int iter; - T temp, temp1, temp2; + Scalar temp, temp1, temp2; int iflag; - T delta; - T ratio; - T fnorm, gnorm, pnorm, xnorm, fnorm1, actred, dirder, prered; + Scalar delta; + Scalar ratio; + Scalar fnorm, gnorm, pnorm, xnorm, fnorm1, actred, dirder, prered; int info; /* Parameter adjustments */ @@ -72,7 +72,7 @@ L20: if (iflag < 0) { goto L340; } - fnorm = ei_enorm<T>(m, &fvec[1]); + fnorm = ei_enorm<Scalar>(m, &fvec[1]); /* initialize levenberg-marquardt parameter and iteration counter. */ @@ -136,7 +136,7 @@ L40: sing = TRUE_; } ipvt[j] = j; - wa2[j] = ei_enorm<T>(j, &fjac[j * fjac_dim1 + 1]); + wa2[j] = ei_enorm<Scalar>(j, &fjac[j * fjac_dim1 + 1]); /* L80: */ } if (! sing) { @@ -194,7 +194,7 @@ L150: wa3[j] = diag[j] * x[j]; /* L160: */ } - xnorm = ei_enorm<T>(n, &wa3[1]); + xnorm = ei_enorm<Scalar>(n, &wa3[1]); delta = factor * xnorm; if (delta == 0.) { delta = factor; @@ -269,7 +269,7 @@ L240: wa3[j] = diag[j] * wa1[j]; /* L250: */ } - pnorm = ei_enorm<T>(n, &wa3[1]); + pnorm = ei_enorm<Scalar>(n, &wa3[1]); /* on the first iteration, adjust the initial step bound. */ @@ -284,7 +284,7 @@ L240: if (iflag < 0) { goto L340; } - fnorm1 = ei_enorm<T>(m, &wa4[1]); + fnorm1 = ei_enorm<Scalar>(m, &wa4[1]); /* compute the scaled actual reduction. */ @@ -310,7 +310,7 @@ L240: } /* L270: */ } - temp1 = ei_enorm<T>(n, &wa3[1]) / fnorm; + temp1 = ei_enorm<Scalar>(n, &wa3[1]) / fnorm; temp2 = sqrt(par) * pnorm / fnorm; /* Computing 2nd power */ d__1 = temp1; @@ -378,7 +378,7 @@ L300: fvec[i__] = wa4[i__]; /* L320: */ } - xnorm = ei_enorm<T>(n, &wa2[1]); + xnorm = ei_enorm<Scalar>(n, &wa2[1]); fnorm = fnorm1; ++iter; L330: @@ -404,13 +404,13 @@ L330: if (*nfev >= maxfev) { info = 5; } - if (abs(actred) <= epsilon<T>() && prered <= epsilon<T>() && p5 * ratio <= 1.) { + if (abs(actred) <= epsilon<Scalar>() && prered <= epsilon<Scalar>() && p5 * ratio <= 1.) { info = 6; } - if (delta <= epsilon<T>() * xnorm) { + if (delta <= epsilon<Scalar>() * xnorm) { info = 7; } - if (gnorm <= epsilon<T>()) { + if (gnorm <= epsilon<Scalar>()) { info = 8; } if (info != 0) { diff --git a/unsupported/Eigen/src/NonLinear/lmstr1.h b/unsupported/Eigen/src/NonLinear/lmstr1.h index 27392fd53..58c248f11 100644 --- a/unsupported/Eigen/src/NonLinear/lmstr1.h +++ b/unsupported/Eigen/src/NonLinear/lmstr1.h @@ -1,19 +1,19 @@ -template<typename T> -int lmstr1_template(minpack_funcderstr_mn fcn, void *p, int m, int n, T *x, - T *fvec, T *fjac, int ldfjac, T tol, - int *ipvt, T *wa, int lwa) +template<typename Scalar> +int lmstr1_template(minpack_funcderstr_mn fcn, void *p, int m, int n, Scalar *x, + Scalar *fvec, Scalar *fjac, int ldfjac, Scalar tol, + int *ipvt, Scalar *wa, int lwa) { /* Initialized data */ - const T factor = 100.; + const Scalar factor = 100.; /* System generated locals */ int fjac_dim1, fjac_offset; /* Local variables */ int mode, nfev, njev; - T ftol, gtol, xtol; + Scalar ftol, gtol, xtol; int maxfev, nprint; int info; |