Проблема с выстраиванием типов аргументов для Integr_const() в BOOST ODEint.C++

Программы на C++. Форум разработчиков
Anonymous
Проблема с выстраиванием типов аргументов для Integr_const() в BOOST ODEint.

Сообщение Anonymous »

Я новичок в C++, поэтому, пожалуйста, будьте терпеливы :)
Я пытаюсь разобраться в использовании библиотеки ODEint из BOOST для решения систем ОДУ, но до сих пор у меня возникают проблемы с простым применением степпер к одному одномерному ОДУ. Прикрепленный код - это то, что я понимаю более или менее то, что необходимо (обратите внимание, что функция odeSolver() предназначена для вывода значения решения в указанной точке (x,t)).
Приносим извинения, если Мне не хватает чего-то, что должно быть очевидно, но когда я пытаюсь построить свой проект, я получаю серию сообщений об ошибках, которые будут подробно описаны после кода.

Код: Выделить всё

#define ODEINT boost::numeric::odeint

// Global variables to store time and state values
std::vector times;
std::vector states;

// Define initial condition and time range
double x0 = 1.0; // initial condition
double t_start = 0.0;
double t_end = 5.0;
double dt = 0.1; // time step
int numSteps = (t_start - t_end) / dt;

void odeSystem(const double x, double& dxdt, const double t) {
// Define simple ODE
dxdt = -x;
}

float odeSolver(double X, double T) {

auto denseStepper = ODEINT::make_dense_output(1.0e-6, 1.0e-6);

ODEINT::integrate_const(
denseStepper,
odeSystem,
x0,
t_start,
t_end,
dt,
std::function([](const double& x, const double t) {
times.push_back(t);
states.push_back(x);
})
);

int currentPt = (X - t_start) / dt;

return states[currentPt];
}

Код: Выделить всё

1>D:\BOOST\boost_1_84_0\boost\numeric\odeint\stepper\generation\make_dense_output.hpp(60,55):
error C2039: 'type': is not a member of 'boost::numeric::odeint::get_dense_output'
with
[
Stepper=boost::numeric::odeint::runge_kutta_cash_karp54
]

2>D:\BOOST\boost_1_84_0\boost\numeric\odeint\stepper\generation\make_dense_output.hpp(60,26):
see declaration of 'boost::numeric::odeint::get_dense_output'
with
[
Stepper=boost::numeric::odeint::runge_kutta_cash_karp54
]

3>D:\BOOST\boost_1_84_0\boost\numeric\odeint\stepper\generation\make_dense_output.hpp(60,55):
the template instantiation context (the oldest one first) is
D:\Visual Studio\source\repos\TestFiles\main.cpp(48,106):
see reference to class template instantiation 'boost::numeric::odeint::result_of::make_dense_output' being compiled
with
[
State=double,
Value=double,
StateType=double
]

4>D:\Visual Studio\source\repos\TestFiles\main.cpp(48,23):
error C2514: 'boost::type': class template cannot be constructed

5>D:\BOOST\boost_1_84_0\boost\type.hpp(14,3):
see declaration of 'boost::type'

6>D:\Visual Studio\source\repos\TestFiles\main.cpp(50,13): error C2664:
'size_t boost::numeric::odeint::integrate_const(Stepper,System,State &,Time,Time,Time,Observer)': cannot convert argument 1 from 'boost::type' to 'Stepper'
with
[
Stepper=boost::type,
System=void (__cdecl *)(double,double &,double),
State=double,
Time=double,
Observer=std::function
]
and
[
Stepper=boost::type
]

7>D:\Visual Studio\source\repos\TestFiles\main.cpp(51,9):
The target type has no constructors

8>D:\BOOST\boost_1_84_0\boost\numeric\odeint\integrate\integrate_const.hpp(104,8):
see declaration of 'boost::numeric::odeint::integrate_const'

9>D:\Visual Studio\source\repos\TestFiles\main.cpp(50,13):
while trying to match the argument list '(boost::type, overloaded-function, double, double, double, double, std::function)'

Я много раз проверял, что всё правильно включено и версии совпадают, поэтому мне кажется, что проблема кроется в степпере" DensentStepper" не имеет того типа, который хочет использовать Integr_const, но я не могу понять, что в моем коде не соответствует документации. Буду очень признателен за любую помощь, которая поможет мне двигаться примерно в правильном направлении, спасибо :))

Подробнее здесь: https://stackoverflow.com/questions/781 ... ost-odeint

Вернуться в «C++»