Opened 8 years ago
Closed 5 years ago
#10680 closed Bugs (fixed)
Cannot use Eigen vector as state type in integrate?
Reported by: | Owned by: | karsten | |
---|---|---|---|
Milestone: | To Be Determined | Component: | odeint |
Version: | Boost 1.56.0 | Severity: | Problem |
Keywords: | Cc: |
Description
The program
#include "boost/numeric/odeint.hpp" #include "Eigen/Core" using namespace boost::numeric::odeint; int main() { Eigen::Vector3d state(0, 0, 0); integrate( [](const auto& state, auto& change, const double /*time*/){ change = Eigen::Vector3d(1, 0, 0); }, state, 0.0, 1.0, 0.1 ); return 0; }
does not compile with Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn) using -std=c++1y
In file included from /Users/iljah/include/boost/numeric/odeint.hpp:67: /Users/iljah/include/boost/numeric/odeint/integrate/integrate.hpp:59:12: error: no matching function for call to 'integrate' return integrate( system , start_state , start_time , end_time , dt , null_observer() ); ^~~~~~~~~ odeint1.cpp:9:2: note: in instantiation of function template specialization 'boost::numeric::odeint::integrate<<lambda at odeint1.cpp:10:3>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, double>' requested here integrate( ^ /Users/iljah/include/boost/numeric/odeint/integrate/integrate.hpp:44:28: note: candidate template ignored: disabled by 'enable_if' [with System = <lambda at odeint1.cpp:10:3>, State = Eigen::Matrix<double, 3, 1, 0, 3, 1>, Time = double, Observer = boost::numeric::odeint::null_observer] typename boost::enable_if< typename has_value_type<State>::type , size_t >::type ^ /Users/iljah/include/boost/numeric/odeint/integrate/integrate.hpp:57:8: note: candidate function template not viable: requires 5 arguments, but 6 were provided size_t integrate( System system , State &start_state , Time start_time , Time end_time , Time dt ) ^ 1 error generated.
Based on "disabled by 'enable_if'" I'd guess the problem is in odeint not Eigen, or this a user error? I get many more errors if the state type is e.g. a std::array of Eigen vectors but I'll create another ticket if that issue persists.
Change History (7)
follow-up: 3 comment:1 by , 8 years ago
comment:2 by , 8 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
comment:3 by , 8 years ago
#include "boost/numeric/odeint/external/eigen/eigen.hpp"
I don't have that file in boost-1.57.0, only eigen_algebra.hpp and eigen_resize.hpp. I just downloaded the bz2 tarball again from sourceforge and still nothing.
comment:4 by , 8 years ago
Resolution: | wontfix |
---|---|
Status: | closed → reopened |
comment:5 by , 8 years ago
Ok, I see. Can you use the odeint version from github: https://github.com/headmyshoulder/odeint-v2. It will be included in 1.58. Be sure to set the include path to odeint-v2/include before the boost include path.
comment:7 by , 5 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
There are two problems with your code. First, eigen is not support by default, you need to include the eigen adaption of odeint. And secondly, integrate can not determine the value from the eigen vector by itself. If you change the example to
everything should work.