aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/Eigen/src/NonLinear/lmstr1.h
blob: 19df28394760cdd1129e70229e15baa2dfd285d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

template<typename FunctorType, typename Scalar>
int ei_lmstr1(
        const FunctorType &Functor,
        Matrix< Scalar, Dynamic, 1 >  &x,
        Matrix< Scalar, Dynamic, 1 >  &fvec,
        VectorXi &ipvt,
        Scalar tol = ei_sqrt(epsilon<Scalar>())
        )
{
    const int n = x.size(), m=fvec.size();
    int info, nfev=0, njev=0;
    Matrix< Scalar, Dynamic, Dynamic > fjac(m, n);
    Matrix< Scalar, Dynamic, 1> diag, qtf;

    /* check the input parameters for errors. */
    if (n <= 0 || m < n || tol < 0.) {
        printf("ei_lmstr1 bad args : m,n,tol,...");
        return 0;
    }

    ipvt.resize(n);
    info = ei_lmstr(
        Functor,
        x, fvec,
        nfev, njev,
        fjac, ipvt, qtf, diag,
        1,
        100.,
        (n+1)*100,
        tol, tol, Scalar(0.)
    );
    return (info==8)?4:info;
}