From b3f8d02df4286385597588c6c2a5585e30b256bd Mon Sep 17 00:00:00 2001 From: Thomas Capricelli Date: Sat, 22 Aug 2009 07:31:14 +0200 Subject: [PATCH] use const for machine constants --- unsupported/Eigen/src/NonLinear/dogleg.h | 7 ++----- unsupported/Eigen/src/NonLinear/fdjac1.h | 6 +----- unsupported/Eigen/src/NonLinear/fdjac2.h | 7 ++----- unsupported/Eigen/src/NonLinear/lmpar.h | 7 ++----- unsupported/Eigen/src/NonLinear/qrfac.h | 6 +----- unsupported/Eigen/src/NonLinear/r1updt.h | 7 ++----- 6 files changed, 10 insertions(+), 30 deletions(-) diff --git a/unsupported/Eigen/src/NonLinear/dogleg.h b/unsupported/Eigen/src/NonLinear/dogleg.h index 3ca406c6a..94433824f 100644 --- a/unsupported/Eigen/src/NonLinear/dogleg.h +++ b/unsupported/Eigen/src/NonLinear/dogleg.h @@ -7,7 +7,7 @@ void ei_dogleg(int n, const Scalar *r__, int /* lr*/ , /* Local variables */ int i, j, k, l, jj, jp1; Scalar sum, temp, alpha, bnorm; - Scalar gnorm, qnorm, epsmch; + Scalar gnorm, qnorm; Scalar sgnorm; /* Parameter adjustments */ @@ -19,10 +19,7 @@ void ei_dogleg(int n, const Scalar *r__, int /* lr*/ , --r__; /* Function Body */ - -/* epsmch is the machine precision. */ - - epsmch = epsilon(); + const Scalar epsmch = epsilon(); /* first, calculate the gauss-newton direction. */ diff --git a/unsupported/Eigen/src/NonLinear/fdjac1.h b/unsupported/Eigen/src/NonLinear/fdjac1.h index 9d12b231f..43951ff11 100644 --- a/unsupported/Eigen/src/NonLinear/fdjac1.h +++ b/unsupported/Eigen/src/NonLinear/fdjac1.h @@ -12,7 +12,6 @@ int ei_fdjac1(minpack_func_nn fcn, void *p, int n, Scalar *x, const Scalar * int i, j, k; Scalar eps, temp; int msum; - Scalar epsmch; int iflag = 0; /* Parameter adjustments */ @@ -25,10 +24,7 @@ int ei_fdjac1(minpack_func_nn fcn, void *p, int n, Scalar *x, const Scalar * fjac -= fjac_offset; /* Function Body */ - -/* epsmch is the machine precision. */ - - epsmch = epsilon(); + const Scalar epsmch = epsilon(); eps = ei_sqrt((std::max(epsfcn,epsmch))); msum = ml + mu + 1; diff --git a/unsupported/Eigen/src/NonLinear/fdjac2.h b/unsupported/Eigen/src/NonLinear/fdjac2.h index b1c52bddf..5dfa1ddb6 100644 --- a/unsupported/Eigen/src/NonLinear/fdjac2.h +++ b/unsupported/Eigen/src/NonLinear/fdjac2.h @@ -10,7 +10,7 @@ int ei_fdjac2(minpack_func_mn fcn, void *p, int m, int n, Scalar *x, /* Local variables */ Scalar h__; int i, j; - Scalar eps, temp, epsmch; + Scalar eps, temp; int iflag; /* Parameter adjustments */ @@ -22,10 +22,7 @@ int ei_fdjac2(minpack_func_mn fcn, void *p, int m, int n, Scalar *x, fjac -= fjac_offset; /* Function Body */ - -/* epsmch is the machine precision. */ - - epsmch = epsilon(); + const Scalar epsmch = epsilon(); eps = ei_sqrt((std::max(epsfcn,epsmch))); for (j = 1; j <= n; ++j) { diff --git a/unsupported/Eigen/src/NonLinear/lmpar.h b/unsupported/Eigen/src/NonLinear/lmpar.h index 8fe5dcff6..1c21fd7d3 100644 --- a/unsupported/Eigen/src/NonLinear/lmpar.h +++ b/unsupported/Eigen/src/NonLinear/lmpar.h @@ -15,7 +15,7 @@ void ei_lmpar(int n, Scalar *r__, int ldr, int jm1, jp1; Scalar sum, parc, parl; int iter; - Scalar temp, paru, dwarf; + Scalar temp, paru; int nsing; Scalar gnorm; Scalar dxnorm; @@ -33,10 +33,7 @@ void ei_lmpar(int n, Scalar *r__, int ldr, r__ -= r_offset; /* Function Body */ - -/* dwarf is the smallest positive magnitude. */ - - dwarf = std::numeric_limits::min(); + const Scalar dwarf = std::numeric_limits::min(); /* compute and store in x the gauss-newton direction. if the */ /* jacobian is rank-deficient, obtain a least squares solution. */ diff --git a/unsupported/Eigen/src/NonLinear/qrfac.h b/unsupported/Eigen/src/NonLinear/qrfac.h index 3a669bbc4..829ea0d11 100644 --- a/unsupported/Eigen/src/NonLinear/qrfac.h +++ b/unsupported/Eigen/src/NonLinear/qrfac.h @@ -13,7 +13,6 @@ void ei_qrfac(int m, int n, Scalar *a, int int kmax; Scalar temp; int minmn; - Scalar epsmch; Scalar ajnorm; /* Parameter adjustments */ @@ -26,10 +25,7 @@ void ei_qrfac(int m, int n, Scalar *a, int --ipvt; /* Function Body */ - -/* epsmch is the machine precision. */ - - epsmch = epsilon(); + const Scalar epsmch = epsilon(); /* compute the initial column norms and initialize several arrays. */ diff --git a/unsupported/Eigen/src/NonLinear/r1updt.h b/unsupported/Eigen/src/NonLinear/r1updt.h index 947a0e1e3..7d9d13e67 100644 --- a/unsupported/Eigen/src/NonLinear/r1updt.h +++ b/unsupported/Eigen/src/NonLinear/r1updt.h @@ -6,7 +6,7 @@ void ei_r1updt(int m, int n, Scalar *s, int /* ls */, const Scalar *u, Scalar *v int i, j, l, jj, nm1; Scalar tan__; int nmj; - Scalar cos__, sin__, tau, temp, giant, cotan; + Scalar cos__, sin__, tau, temp, cotan; /* Parameter adjustments */ --w; @@ -15,10 +15,7 @@ void ei_r1updt(int m, int n, Scalar *s, int /* ls */, const Scalar *u, Scalar *v --s; /* Function Body */ - -/* giant is the largest magnitude. */ - - giant = std::numeric_limits::max(); + const Scalar giant = std::numeric_limits::max(); /* initialize the diagonal element pointer. */