From 054652b7896394558b070ca403845291c93eefae Mon Sep 17 00:00:00 2001 From: Thomas Capricelli Date: Fri, 21 Aug 2009 00:04:41 +0200 Subject: [PATCH] use math function adapted to the Scalar type instead of hardcoding float or double --- unsupported/Eigen/src/NonLinear/chkder.h | 4 ++-- unsupported/Eigen/src/NonLinear/hybrd.h | 2 +- unsupported/Eigen/src/NonLinear/hybrj.h | 2 +- unsupported/Eigen/src/NonLinear/lmder.h | 8 ++++---- unsupported/Eigen/src/NonLinear/lmdif.h | 8 ++++---- unsupported/Eigen/src/NonLinear/lmstr.h | 8 ++++---- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/unsupported/Eigen/src/NonLinear/chkder.h b/unsupported/Eigen/src/NonLinear/chkder.h index 677d97194..913727227 100644 --- a/unsupported/Eigen/src/NonLinear/chkder.h +++ b/unsupported/Eigen/src/NonLinear/chkder.h @@ -15,7 +15,7 @@ void ei_chkder( { const Scalar eps = ei_sqrt(epsilon()); const Scalar epsf = chkder_factor * epsilon(); - const Scalar epslog = chkder_log10e * log(eps); + const Scalar epslog = chkder_log10e * ei_log(eps); Scalar temp; int i,j; @@ -52,7 +52,7 @@ void ei_chkder( } err[i] = 1.; if (temp > epsilon() && temp < eps) { - err[i] = (chkder_log10e * log(temp) - epslog) / epslog; + err[i] = (chkder_log10e * ei_log(temp) - epslog) / epslog; } if (temp >= eps) { err[i] = 0.; diff --git a/unsupported/Eigen/src/NonLinear/hybrd.h b/unsupported/Eigen/src/NonLinear/hybrd.h index 54131aa82..3995e4299 100644 --- a/unsupported/Eigen/src/NonLinear/hybrd.h +++ b/unsupported/Eigen/src/NonLinear/hybrd.h @@ -295,7 +295,7 @@ L230: ++ncsuc; if (ratio >= p5 || ncsuc > 1) /* Computing MAX */ delta = max(delta, pnorm / p5); - if (fabs(ratio - 1.) <= p1) { + if (ei_abs(ratio - 1.) <= p1) { delta = pnorm / p5; } L240: diff --git a/unsupported/Eigen/src/NonLinear/hybrj.h b/unsupported/Eigen/src/NonLinear/hybrj.h index 1aaae9f97..a9a4fbf4e 100644 --- a/unsupported/Eigen/src/NonLinear/hybrj.h +++ b/unsupported/Eigen/src/NonLinear/hybrj.h @@ -289,7 +289,7 @@ L230: ++ncsuc; if (ratio >= p5 || ncsuc > 1) /* Computing MAX */ delta = max(delta, pnorm / p5); - if (fabs(ratio - 1.) <= p1) { + if (ei_abs(ratio - 1.) <= p1) { delta = pnorm / p5; } L240: diff --git a/unsupported/Eigen/src/NonLinear/lmder.h b/unsupported/Eigen/src/NonLinear/lmder.h index e58f3de2e..2d11445b2 100644 --- a/unsupported/Eigen/src/NonLinear/lmder.h +++ b/unsupported/Eigen/src/NonLinear/lmder.h @@ -182,7 +182,7 @@ L120: /* L140: */ } /* Computing MAX */ - gnorm = max(gnorm, fabs(sum / wa2[l])); + gnorm = max(gnorm, ei_abs(sum / wa2[l])); L150: /* L160: */ ; @@ -325,13 +325,13 @@ L290: /* tests for convergence. */ - if (fabs(actred) <= ftol && prered <= ftol && p5 * ratio <= 1.) { + if (ei_abs(actred) <= ftol && prered <= ftol && p5 * ratio <= 1.) { info = 1; } if (delta <= xtol * xnorm) { info = 2; } - if (fabs(actred) <= ftol && prered <= ftol && p5 * ratio <= 1. && info + if (ei_abs(actred) <= ftol && prered <= ftol && p5 * ratio <= 1. && info == 2) { info = 3; } @@ -344,7 +344,7 @@ L290: if (*nfev >= maxfev) { info = 5; } - if (fabs(actred) <= epsilon() && prered <= epsilon() && p5 * ratio <= 1.) { + if (ei_abs(actred) <= epsilon() && prered <= epsilon() && p5 * ratio <= 1.) { info = 6; } if (delta <= epsilon() * xnorm) { diff --git a/unsupported/Eigen/src/NonLinear/lmdif.h b/unsupported/Eigen/src/NonLinear/lmdif.h index d6f06935b..f13f6c974 100644 --- a/unsupported/Eigen/src/NonLinear/lmdif.h +++ b/unsupported/Eigen/src/NonLinear/lmdif.h @@ -184,7 +184,7 @@ L120: /* L140: */ } /* Computing MAX */ - gnorm = max(gnorm, fabs(sum / wa2[l])); + gnorm = max(gnorm, ei_abs(sum / wa2[l])); L150: /* L160: */ ; @@ -327,13 +327,13 @@ L290: /* tests for convergence. */ - if (fabs(actred) <= ftol && prered <= ftol && p5 * ratio <= 1.) { + if (ei_abs(actred) <= ftol && prered <= ftol && p5 * ratio <= 1.) { info = 1; } if (delta <= xtol * xnorm) { info = 2; } - if (fabs(actred) <= ftol && prered <= ftol && p5 * ratio <= 1. && info + if (ei_abs(actred) <= ftol && prered <= ftol && p5 * ratio <= 1. && info == 2) { info = 3; } @@ -346,7 +346,7 @@ L290: if (*nfev >= maxfev) { info = 5; } - if (fabs(actred) <= epsilon() && prered <= epsilon() && p5 * ratio <= 1.) { + if (ei_abs(actred) <= epsilon() && prered <= epsilon() && p5 * ratio <= 1.) { info = 6; } if (delta <= epsilon() * xnorm) { diff --git a/unsupported/Eigen/src/NonLinear/lmstr.h b/unsupported/Eigen/src/NonLinear/lmstr.h index b9e94e1ac..bb544e451 100644 --- a/unsupported/Eigen/src/NonLinear/lmstr.h +++ b/unsupported/Eigen/src/NonLinear/lmstr.h @@ -206,7 +206,7 @@ L170: /* L180: */ } /* Computing MAX */ - gnorm = max(gnorm, abs(sum/wa2[l])); + gnorm = max(gnorm, ei_abs(sum/wa2[l])); L190: /* L200: */ ; @@ -350,13 +350,13 @@ L330: /* tests for convergence. */ - if (abs(actred) <= ftol && prered <= ftol && p5 * ratio <= 1.) { + if (ei_abs(actred) <= ftol && prered <= ftol && p5 * ratio <= 1.) { info = 1; } if (delta <= xtol * xnorm) { info = 2; } - if (abs(actred) <= ftol && prered <= ftol && p5 * ratio <= 1. && info + if (ei_abs(actred) <= ftol && prered <= ftol && p5 * ratio <= 1. && info == 2) { info = 3; } @@ -369,7 +369,7 @@ L330: if (*nfev >= maxfev) { info = 5; } - if (abs(actred) <= epsilon() && prered <= epsilon() && p5 * ratio <= 1.) { + if (ei_abs(actred) <= epsilon() && prered <= epsilon() && p5 * ratio <= 1.) { info = 6; } if (delta <= epsilon() * xnorm) {