I am trying to use the Eigen implementation of the Levenberg Marquardt algorithm in an Android application. To use Eigen, I use Android NDK and jni. I already tested Eigen with simple calculations (e.g. matrix creation and vector sums) and it works great. However, when I tried to use the Levenberg Marquardt algorithm, I got some errors in the LevenbergMarquardt.h file from the Eigen library.
Firstly, here is my code. I was based on this code :
Eigen::MatrixXd matrix(count, 3); for (int i = 0; i < count; i++) { Eigen::VectorXd t(3); t << x[i], y[i], accuracy[i]; matrix.row(i) = t; } distance_functor functor(matrix, count); Eigen::NumericalDiff<distance_functor> numDiff(functor); Eigen::LevenbergMarquardt<Eigen::NumericalDiff<distance_functor>,double> lm(numDiff); lm.parameters.maxfev = 2000; lm.parameters.xtol = 1.49012e-08; lm.parameters.ftol = 1.49012e-08; lm.parameters.gtol = 0; lm.parameters.epsfcn = 0; Eigen::LevenbergMarquardtSpace::Status ret = lm.minimize(poseResult);
And this is the error I received. The first two errors are in the Eigen library, and the last is in creating the LevenbergMarquardt object. I also included the corresponding line of error code, following the message:
Incorrect template arguments LevenbergMarquardt.h / jnimath / jni / unsupported / Eigen / src / LevenbergMarquardt line 121 Semantic error
typedef PermutationMatrix<Dynamic,Dynamic> PermutationType;
Incorrect template arguments LevenbergMarquardt.h / jnimath / jni / unsupported / Eigen / src / NonLinear Optimization 103 Semantic error
PermutationMatrix<Dynamic,Dynamic> permutation;
Invalid template arguments test.cpp / jnimath / jni line 47 Semantic Error
Eigen :: LevenbergMarquardt, double> lm (numDiff);
The first two errors are really strange, because there are some other typedefs that use Dynamic, and they don't throw errors.
In addition, I noticed that I received some character errors in compilation, which:
The symbol 'YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY' could not be resolved. Matrix.h / jnimath / jni / Eigen / src / Core line 277 Semantic error
Character 'YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX' cannot be resolved Matrix.h / jnimath / jni / Eigen / src / Core line 224 Semantic error
So, I have two questions:
Why am I getting errors on these lines?
Does anyone know how to fix this problem?
thanks