aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/Eigen/src/NonLinear
diff options
context:
space:
mode:
authorGravatar Thomas Capricelli <orzel@freehackers.org>2009-08-19 19:56:51 +0200
committerGravatar Thomas Capricelli <orzel@freehackers.org>2009-08-19 19:56:51 +0200
commit01622e9855734a35def4f88e2645423c90b8959b (patch)
tree211532c0ebca0b716e4d7d6c9b4f8edebe05519b /unsupported/Eigen/src/NonLinear
parent3093e92da5f0fea5a7325a573b5c19dd83e71f72 (diff)
use machine precision from eigen instead of the one from cminpack. The test
pass though they would not if using a value of 2.220e-16 (the real value for 'double' is 2.22044604926e-16). How sensitive those tests are :)
Diffstat (limited to 'unsupported/Eigen/src/NonLinear')
-rw-r--r--unsupported/Eigen/src/NonLinear/chkder.h12
-rw-r--r--unsupported/Eigen/src/NonLinear/hybrd.h8
-rw-r--r--unsupported/Eigen/src/NonLinear/hybrj.h8
-rw-r--r--unsupported/Eigen/src/NonLinear/lmder.h13
-rw-r--r--unsupported/Eigen/src/NonLinear/lmdif.h12
-rw-r--r--unsupported/Eigen/src/NonLinear/lmstr.h13
6 files changed, 20 insertions, 46 deletions
diff --git a/unsupported/Eigen/src/NonLinear/chkder.h b/unsupported/Eigen/src/NonLinear/chkder.h
index acf025cc2..89552d530 100644
--- a/unsupported/Eigen/src/NonLinear/chkder.h
+++ b/unsupported/Eigen/src/NonLinear/chkder.h
@@ -14,7 +14,7 @@ void chkder_template(int m, int n, const T *x,
/* Local variables */
int i__, j;
- T eps, epsf, temp, epsmch;
+ T eps, epsf, temp;
T epslog;
/* Parameter adjustments */
@@ -29,11 +29,7 @@ void chkder_template(int m, int n, const T *x,
/* Function Body */
-/* epsmch is the machine precision. */
-
- epsmch = dpmpar(1);
-
- eps = sqrt(epsmch);
+ eps = ei_sqrt(epsilon<T>());
if (mode == 2) {
goto L20;
@@ -56,7 +52,7 @@ L20:
/* mode = 2. */
- epsf = chkder_factor * epsmch;
+ epsf = chkder_factor * epsilon<T>();
epslog = chkder_log10e * log(eps);
i__1 = m;
for (i__ = 1; i__ <= i__1; ++i__) {
@@ -87,7 +83,7 @@ L20:
fabs(fvecp[i__]));
}
err[i__] = 1.;
- if (temp > epsmch && temp < eps) {
+ if (temp > epsilon<T>() && 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 b9eb540fb..53019a003 100644
--- a/unsupported/Eigen/src/NonLinear/hybrd.h
+++ b/unsupported/Eigen/src/NonLinear/hybrd.h
@@ -28,7 +28,7 @@ int hybrd_template(minpack_func_nn fcn, void *p, int n, T *x, T *
T pnorm, xnorm, fnorm1;
int nslow1, nslow2;
int ncfail;
- T actred, epsmch, prered;
+ T actred, prered;
int info;
/* Parameter adjustments */
@@ -47,10 +47,6 @@ int hybrd_template(minpack_func_nn fcn, void *p, int n, T *x, T *
/* Function Body */
-/* epsmch is the machine precision. */
-
- epsmch = dpmpar(1);
-
info = 0;
iflag = 0;
*nfev = 0;
@@ -382,7 +378,7 @@ L260:
}
/* Computing MAX */
d__1 = p1 * delta;
- if (p1 * max(d__1,pnorm) <= epsmch * xnorm) {
+ if (p1 * max(d__1,pnorm) <= epsilon<T>() * xnorm) {
info = 3;
}
if (nslow2 == 5) {
diff --git a/unsupported/Eigen/src/NonLinear/hybrj.h b/unsupported/Eigen/src/NonLinear/hybrj.h
index 6f5fc38d3..30712e5db 100644
--- a/unsupported/Eigen/src/NonLinear/hybrj.h
+++ b/unsupported/Eigen/src/NonLinear/hybrj.h
@@ -28,7 +28,7 @@ int hybrj_template(minpack_funcder_nn fcn, void *p, int n, T *x, T *
T pnorm, xnorm, fnorm1;
int nslow1, nslow2;
int ncfail;
- T actred, epsmch, prered;
+ T actred, prered;
int info;
/* Parameter adjustments */
@@ -47,10 +47,6 @@ int hybrj_template(minpack_funcder_nn fcn, void *p, int n, T *x, T *
/* Function Body */
-/* epsmch is the machine precision. */
-
- epsmch = dpmpar(1);
-
info = 0;
iflag = 0;
*nfev = 0;
@@ -375,7 +371,7 @@ L260:
}
/* Computing MAX */
d__1 = p1 * delta;
- if (p1 * max(d__1,pnorm) <= epsmch * xnorm) {
+ if (p1 * max(d__1,pnorm) <= epsilon<T>() * xnorm) {
info = 3;
}
if (nslow2 == 5) {
diff --git a/unsupported/Eigen/src/NonLinear/lmder.h b/unsupported/Eigen/src/NonLinear/lmder.h
index 492b3d649..6df4dcbb2 100644
--- a/unsupported/Eigen/src/NonLinear/lmder.h
+++ b/unsupported/Eigen/src/NonLinear/lmder.h
@@ -21,8 +21,7 @@ int lmder_template(minpack_funcder_mn fcn, void *p, int m, int n, T *x,
int iflag;
T delta;
T ratio;
- T fnorm, gnorm, pnorm, xnorm, fnorm1, actred, dirder,
- epsmch, prered;
+ T fnorm, gnorm, pnorm, xnorm, fnorm1, actred, dirder, prered;
int info;
/* Parameter adjustments */
@@ -41,10 +40,6 @@ int lmder_template(minpack_funcder_mn fcn, void *p, int m, int n, T *x,
/* Function Body */
-/* epsmch is the machine precision. */
-
- epsmch = dpmpar(1);
-
info = 0;
iflag = 0;
*nfev = 0;
@@ -382,13 +377,13 @@ L290:
if (*nfev >= maxfev) {
info = 5;
}
- if (fabs(actred) <= epsmch && prered <= epsmch && p5 * ratio <= 1.) {
+ if (fabs(actred) <= epsilon<T>() && prered <= epsilon<T>() && p5 * ratio <= 1.) {
info = 6;
}
- if (delta <= epsmch * xnorm) {
+ if (delta <= epsilon<T>() * xnorm) {
info = 7;
}
- if (gnorm <= epsmch) {
+ if (gnorm <= epsilon<T>()) {
info = 8;
}
if (info != 0) {
diff --git a/unsupported/Eigen/src/NonLinear/lmdif.h b/unsupported/Eigen/src/NonLinear/lmdif.h
index 894203be6..136451a09 100644
--- a/unsupported/Eigen/src/NonLinear/lmdif.h
+++ b/unsupported/Eigen/src/NonLinear/lmdif.h
@@ -24,7 +24,7 @@ int lmdif_template(minpack_func_mn fcn, void *p, int m, int n, T *x,
T delta;
T ratio;
T fnorm, gnorm;
- T pnorm, xnorm, fnorm1, actred, dirder, epsmch, prered;
+ T pnorm, xnorm, fnorm1, actred, dirder, prered;
int info;
/* Parameter adjustments */
@@ -43,10 +43,6 @@ int lmdif_template(minpack_func_mn fcn, void *p, int m, int n, T *x,
/* Function Body */
-/* epsmch is the machine precision. */
-
- epsmch = dpmpar(1);
-
info = 0;
iflag = 0;
*nfev = 0;
@@ -384,13 +380,13 @@ L290:
if (*nfev >= maxfev) {
info = 5;
}
- if (fabs(actred) <= epsmch && prered <= epsmch && p5 * ratio <= 1.) {
+ if (fabs(actred) <= epsilon<T>() && prered <= epsilon<T>() && p5 * ratio <= 1.) {
info = 6;
}
- if (delta <= epsmch * xnorm) {
+ if (delta <= epsilon<T>() * xnorm) {
info = 7;
}
- if (gnorm <= epsmch) {
+ if (gnorm <= epsilon<T>()) {
info = 8;
}
if (info != 0) {
diff --git a/unsupported/Eigen/src/NonLinear/lmstr.h b/unsupported/Eigen/src/NonLinear/lmstr.h
index c49b1c977..17aba6865 100644
--- a/unsupported/Eigen/src/NonLinear/lmstr.h
+++ b/unsupported/Eigen/src/NonLinear/lmstr.h
@@ -22,8 +22,7 @@ int lmstr_template(minpack_funcderstr_mn fcn, void *p, int m, int n, T *x,
int iflag;
T delta;
T ratio;
- T fnorm, gnorm, pnorm, xnorm, fnorm1, actred, dirder,
- epsmch, prered;
+ T fnorm, gnorm, pnorm, xnorm, fnorm1, actred, dirder, prered;
int info;
/* Parameter adjustments */
@@ -42,10 +41,6 @@ int lmstr_template(minpack_funcderstr_mn fcn, void *p, int m, int n, T *x,
/* Function Body */
-/* epsmch is the machine precision. */
-
- epsmch = dpmpar(1);
-
info = 0;
iflag = 0;
*nfev = 0;
@@ -409,13 +404,13 @@ L330:
if (*nfev >= maxfev) {
info = 5;
}
- if (abs(actred) <= epsmch && prered <= epsmch && p5 * ratio <= 1.) {
+ if (abs(actred) <= epsilon<T>() && prered <= epsilon<T>() && p5 * ratio <= 1.) {
info = 6;
}
- if (delta <= epsmch * xnorm) {
+ if (delta <= epsilon<T>() * xnorm) {
info = 7;
}
- if (gnorm <= epsmch) {
+ if (gnorm <= epsilon<T>()) {
info = 8;
}
if (info != 0) {