kthohr / optim

OptimLib: a lightweight C++ library of numerical optimization methods for nonlinear functions

Home Page:https://optimlib.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Header-only version doesn't work with Eigen 3.3.9

dburov190 opened this issue · comments

commented

Hi,

The header-only version doesn't seem to work with Eigen 3.3.9. gcc prints two errors:

/home/dburov/.local/include/optimlib/unconstrained/nm.hpp: In function ‘bool optim::internal::nm_impl(optim::Vec_t&, std::function<double(const Eigen::Matrix<double, -1, 1>&, Eigen::Matrix<double, -1, 1>*, void*)>, void*, optim::algo_settings_t*)’:
/home/dburov/.local/include/optimlib/unconstrained/nm.hpp:202:69: error: no match for call to ‘(optim::Vec_t {aka Eigen::Matrix<double, -1, 1>}) (optim::VecInt_t&)’
  202 |         simplex_fn_vals = OPTIM_MATOPS_EVAL(simplex_fn_vals(sort_vec));

and

/home/dburov/.local/include/optimlib/misc/matrix_ops/access.hpp:35:50: error: ‘all’ is not a member of ‘Eigen’
   35 |     #define OPTIM_MATOPS_ROWS(x, v) (x)(v,Eigen::all) // v is a vector

The second error is relatively well-known: all is only defined in Eigen's master branch (maybe the latest RC) but not in the latest stable version, which currently is 3.3.9.

The first one is not quite clear to me. It seems like it's trying to convert vector of ints into an int, and fails (output from one of the candidates):

include/eigen3/Eigen/src/Core/DenseCoeffsBase.h:178:22: note:   no known conversion for argument 1 from ‘optim::VecInt_t’ {aka ‘Eigen::Matrix<int, -1, 1>’} to ‘Eigen::Index’ {aka ‘long int’}
  178 |     operator()(Index index) const

Unrelated, is there any way to NOT use Eigen or Arma? Those are horrible, clumsy, bloated libraries that I try to avoid like the plague. Thanks!

commented

Eigen 3.4.0 has been released on August 18, 2021. I compiled the lbgfgs test program with no error.

g++ tests/unconstrained/lbfgs.cpp -I./header_only_version -I./eigen-3.4.0 -DOPTIM_ENABLE_EIGEN_WRAPPERS