Types error: invalid operands to binary expression ('double' and 'state_type')
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Reproduce the provided C++ example and inspect boost/numeric/odeint/algebra/default_operations.hpp around line 443, especially the controlled-step error expression. Trace the types of m_eps_abs, m_eps_rel, and get_unit_value(...) to determine whether the formula supports vector_space_algebra. Done means the example no longer requires scalar-plus-state_type solely to satisfy the error estimate, with the behavior verified.
Written by the indexing model from the issue text.
Description
I defined new state type as
struct state_type { double x; };
and vector space operators
state_type operator * (const state_type &a, double k) { return {a.x * k}; }
state_type operator * (double k, const state_type &a) { return {a.x * k}; }
state_type operator + (const state_type &a, const state_type &b) { return {a.x + b.x}; }
state_type operator - (const state_type &a, const state_type &b) { return {a.x - b.x}; }
state_type operator / (const state_type &a, const state_type &b) { return {a.x / b.x}; }
state_type abs(state_type const& v) { return {fabs(v.x)}; }
The main function is
int main()
{
state_type x0 {1.};
double t0 = 0, t1 = 1, dt = 1e-3;
using Stepper = runge_kutta_dopri5<state_type, double, state_type, double, vector_space_algebra>;
auto f = [](state_type const& x, state_type& dx, double t) {
dx = x;
};
integrate_adaptive(make_controlled<Stepper>(1e-10, 1e-10), f, x0, t0, t1, dt);
}
During compilation I am getting the error
/usr/include/boost/numeric/odeint/algebra/default_operations.hpp:443:76: error: invalid operands to binary expression ('double' and 'state_type')
[build] set_unit_value( t3 , abs( get_unit_value( t3 ) ) / ( m_eps_abs + m_eps_rel * ( m_a_x * abs( get_unit_value( t1 ) ) + m_a_dxdt * abs( get_unit_value( t2 ) ) ) ) );
If I add the requested operator
state_type operator + (double k, const state_type &a) { return {a.x + k}; }
the compilation works well. It seems that the formula
set_unit_value( t3 , abs( get_unit_value( t3 ) ) / ( m_eps_abs + m_eps_rel * ( m_a_x * abs( get_unit_value( t1 ) ) + m_a_dxdt * abs( get_unit_value( t2 ) ) ) ) );
is wrong, or type of m_eps_abs is wrong. In a vector space there must not be operator + between elements of state_type and and coefficients. Moreover the operator / between state_type elements is questionable.
- Dominant language
- C++
- Stars
- 55
- Forks
- 59
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/odeint
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 43/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NVIDIA/cuda-samples#453 ·