**Problem** : I am using the Levenberg Marquardt class from the Eigen library in order to find the intrinsic matrix elements for a Camera matrix.

**Expected** : I assumed that the algorithm would iterate until the error in my parameter vector was minimized.

**Observed** : The algorithm does not converge to the correct minimum and it stops after six iterations.

**Parameter Settings** :

```
lm.parameters.factor = 0.1;
lm.parameters.ftol = 0.0001;
lm.parameters.gtol = 0;
lm.parameters.maxfev = 2000;
lm.parameters.xtol = 0;
```

**Eigen Documentation** : here

**Parameter Documentation** : here. This documentation has better definitions for the parameters.

**Levenberg Marquardt Defition** : here

The levenberg marquardt class is unsupported. I would really appreciate any help with this dilemma.

**Inputs**:

**From the cpp**

```
Eigen::VectorXd tT(3);
Eigen::VectorXd tP(5);
tT = aSixDof.translation();
tP(0) = mFx;
tP(1) = mFy;
tP(2) = mCx;
tP(3) = mCy;
tP(4) = mInitialZ0;
MatCalLMFunctor tFunctor;
tFunctor.m_inputs = (int)tP.rows();
tFunctor.m_values = 2 * (int)aObjectPoints.size();
Eigen::LevenbergMarquardt<MatCalLMFunctor> lm(tFunctor);
lm.parameters.factor = 0.1;
lm.parameters.ftol = 0.0001;
lm.parameters.gtol = 0;
lm.parameters.maxfev = 2000;
lm.parameters.xtol = 0;
lm.minimize(tP);
```

**From the h file**

```
template<typename _Scalar, int tDimX = Eigen::Dynamic, int tDimY =
Eigen::Dynamic>
struct Functor
{
typedef _Scalar Scalar;
enum { InputsAtCompileTime = tDimX, ValuesAtCompileTime = tDimY};
typedef Eigen::Matrix<Scalar,tDimX,1> InputType;
typedef Eigen::Matrix<Scalar,tDimY,1> ValueType;
typedef Eigen::Matrix<Scalar,tDimY,tDimX> JacobianType;
int m_inputs, m_values;
Functor() : m_inputs(InputsAtCompileTime), m_values(ValuesAtCompileTime)
{}
Functor(int inputs, int values) : m_inputs(inputs), m_values(values) {}
int inputs() const
{
return m_inputs;
}
int values() const
{
return m_values;
}
};
struct MatCalLMFunctor : Functor<double>
{
MatCalLMFunctor(void): Functor<double>(5,5) {}
int operator()(const Eigen::VectorXd &aP, //Input
Eigen::VectorXd &aH) const; //Output
int df(const InputType &aP, //Input
JacobianType& aFjac); //Output
};
```