aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--unsupported/Eigen/NonLinear2
-rw-r--r--unsupported/Eigen/src/NonLinear/MathFunctions.h14
-rw-r--r--unsupported/Eigen/src/NonLinear/hybrd1.h85
3 files changed, 29 insertions, 72 deletions
diff --git a/unsupported/Eigen/NonLinear b/unsupported/Eigen/NonLinear
index dbb9e8703..cd2bd5920 100644
--- a/unsupported/Eigen/NonLinear
+++ b/unsupported/Eigen/NonLinear
@@ -128,7 +128,6 @@ Scalar ei_enorm ( int n, const Scalar *x ){
}
#include "src/NonLinear/lmder.h"
-#include "src/NonLinear/hybrd1.h"
#include "src/NonLinear/hybrd.h"
#include "src/NonLinear/lmstr.h"
#include "src/NonLinear/lmdif1.h"
@@ -139,6 +138,7 @@ Scalar ei_enorm ( int n, const Scalar *x ){
#include "src/NonLinear/MathFunctions.h"
#include "src/NonLinear/lmder1.h"
#include "src/NonLinear/lmstr1.h"
+#include "src/NonLinear/hybrd1.h"
//@}
diff --git a/unsupported/Eigen/src/NonLinear/MathFunctions.h b/unsupported/Eigen/src/NonLinear/MathFunctions.h
index d7e221ba1..82bea39e4 100644
--- a/unsupported/Eigen/src/NonLinear/MathFunctions.h
+++ b/unsupported/Eigen/src/NonLinear/MathFunctions.h
@@ -26,20 +26,6 @@
#define EIGEN_NONLINEAR_MATHFUNCTIONS_H
template<typename Functor, typename Scalar>
-int ei_hybrd1(
- Matrix< Scalar, Dynamic, 1 > &x,
- Matrix< Scalar, Dynamic, 1 > &fvec,
- Scalar tol = ei_sqrt(epsilon<Scalar>())
- )
-{
- int lwa = (x.size()*(3*x.size()+13))/2;
- Matrix< Scalar, Dynamic, 1 > wa(lwa);
-
- fvec.resize(x.size());
- return hybrd1_template<Scalar>(Functor::f, 0, x.size(), x.data(), fvec.data(), tol, wa.data(), lwa);
-}
-
-template<typename Functor, typename Scalar>
int ei_hybrd(
Matrix< Scalar, Dynamic, 1 > &x,
Matrix< Scalar, Dynamic, 1 > &fvec,
diff --git a/unsupported/Eigen/src/NonLinear/hybrd1.h b/unsupported/Eigen/src/NonLinear/hybrd1.h
index 71feb64b1..b8ab8d13b 100644
--- a/unsupported/Eigen/src/NonLinear/hybrd1.h
+++ b/unsupported/Eigen/src/NonLinear/hybrd1.h
@@ -1,63 +1,34 @@
-template<typename Scalar>
-int hybrd1_template(minpack_func_nn fcn, void *p, int n, Scalar *x, Scalar *
- fvec, Scalar tol, Scalar *wa, int lwa)
+template<typename Functor, typename Scalar>
+int ei_hybrd1(
+ Matrix< Scalar, Dynamic, 1 > &x,
+ Matrix< Scalar, Dynamic, 1 > &fvec,
+ Scalar tol = ei_sqrt(epsilon<Scalar>())
+ )
{
- /* Initialized data */
-
- const Scalar factor = 100.;
-
- /* System generated locals */
- int i__1;
-
- /* Local variables */
- int j, ml, lr, mu, mode, nfev;
- Scalar xtol;
- int index;
- Scalar epsfcn;
- int maxfev, nprint;
- int info;
-
- /* Parameter adjustments */
- --fvec;
- --x;
- --wa;
-
- /* Function Body */
- info = 0;
-
-/* check the input parameters for errors. */
-
- if (n <= 0 || tol < 0. || lwa < n * (n * 3 + 13) / 2) {
- /* goto L20; */
- return info;
- }
-
-/* call hybrd. */
-
- maxfev = (n + 1) * 200;
- xtol = tol;
- ml = n - 1;
- mu = n - 1;
- epsfcn = 0.;
- mode = 2;
- i__1 = n;
- for (j = 1; j <= i__1; ++j) {
- wa[j] = 1.;
-/* L10: */
- }
- nprint = 0;
- lr = n * (n + 1) / 2;
- index = n * 6 + lr;
- info = hybrd(fcn, p, n, &x[1], &fvec[1], xtol, maxfev, ml, mu, epsfcn, &
- wa[1], mode, factor, nprint, &nfev, &wa[index + 1], n, &
- wa[n * 6 + 1], lr, &wa[n + 1], &wa[(n << 1) + 1], &wa[n * 3
- + 1], &wa[(n << 2) + 1], &wa[n * 5 + 1]);
- if (info == 5) {
- info = 4;
+ const int n = x.size();
+ int info, nfev;
+ Matrix< Scalar, Dynamic, Dynamic > fjac;
+ Matrix< Scalar, Dynamic, 1> R, qtf, diag;
+
+ /* check the input parameters for errors. */
+ if (n <= 0 || tol < 0.) {
+ printf("ei_hybrd1 bad args : n,tol,...");
+ return 0;
}
-/* L20: */
- return info;
+ diag.setConstant(n, 1.);
+ info = ei_hybrd<Functor,Scalar>(
+ x, fvec,
+ nfev,
+ fjac,
+ R, qtf, diag,
+ 2,
+ -1, -1,
+ (n+1)*200,
+ 100.,
+ tol, Scalar(0.)
+ );
+ return (info==5)?4:info;
}