- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我一直在使用 VC++ 2010 Express,以及 Windows SDK 7.1 附带的 64 位编译器。我的 boost 包版本是 boost_1_55_0。
找到boost包odeint的示例代码here并且如下:
#include <iostream>
#include <boost/numeric/odeint.hpp>
using namespace std;
using namespace boost::numeric::odeint;
/* we solve the simple ODE x' = 3/(2t^2) + x/(2t)
* with initial condition x(1) = 0.
* Analytic solution is x(t) = sqrt(t) - 1/t
*/
void rhs( const double x , double &dxdt , const double t )
{
dxdt = 3.0/(2.0*t*t) + x/(2.0*t);
}
void write_cout( const double &x , const double t )
{
cout << t << '\t' << x << endl;
}
// state_type = double
typedef runge_kutta_dopri5< double > stepper_type;
int main()
{
double x = 0.0;
integrate_adaptive( make_controlled( 1E-12 , 1E-12 , stepper_type() ) ,
rhs , x , 1.0 , 10.0 , 0.1 , write_cout );
}
但是,这不会编译。错误信息如下:
1>------ Build started: Project: LearnBoost, Configuration: Debug x64 ------
1> test_odeint.cpp
1>C:\boost_1_55_0\boost/format/alt_sstream_impl.hpp : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
1>C:\boost_1_55_0\boost/range/iterator.hpp(63): error C2039: 'type' : is not a member of 'boost::mpl::eval_if_c<C,F1,F2>'
1> with
1> [
1> C=true,
1> F1=boost::range_const_iterator<double>,
1> F2=boost::range_mutable_iterator<const double>
1> ]
1> C:\boost_1_55_0\boost/numeric/odeint/algebra/range_algebra.hpp(52) : see reference to class template instantiation 'boost::range_iterator<C>' being compiled
1> with
1> [
1> C=const double
1> ]
1> C:\boost_1_55_0\boost/numeric/odeint/stepper/controlled_runge_kutta.hpp(81) : see reference to function template instantiation 'void boost::numeric::odeint::range_algebra::for_each3<Err,const State,const Deriv,boost::numeric::odeint::default_operations::rel_error<Fac1>>(S1 &,S2 &,S3 &,Op)' being compiled
1> with
1> [
1> Err=double,
1> State=double,
1> Deriv=double,
1> Fac1=double,
1> S1=double,
1> S2=double,
1> S3=double,
1> Op=boost::numeric::odeint::default_operations::rel_error<double>
1> ]
1> C:\boost_1_55_0\boost/numeric/odeint/stepper/controlled_runge_kutta.hpp(710) : see reference to function template instantiation 'double boost::numeric::odeint::default_error_checker<Value,Algebra,Operations>::error<StateIn,DerivIn,V,double>(boost::numeric::odeint::range_algebra &,const State &,const Deriv &,Err &,Time) const' being compiled
1> with
1> [
1> Value=double,
1> Algebra=boost::numeric::odeint::range_algebra,
1> Operations=boost::numeric::odeint::default_operations,
1> StateIn=double,
1> DerivIn=double,
1> V=double,
1> State=double,
1> Deriv=double,
1> Err=double,
1> Time=double
1> ]
1> C:\boost_1_55_0\boost/numeric/odeint/stepper/controlled_runge_kutta.hpp(660) : see reference to function template instantiation 'boost::numeric::odeint::controlled_step_result boost::numeric::odeint::controlled_runge_kutta<ErrorStepper>::try_step<void(__cdecl *)(double,double &,double),StateInOut,DerivInOut,V,V>(System,const StateIn &,const DerivIn &,double &,StateOut &,DerivOut &,double &)' being compiled
1> with
1> [
1> ErrorStepper=boost::numeric::odeint::runge_kutta_dopri5<double>,
1> StateInOut=double,
1> DerivInOut=double,
1> V=double,
1> System=void (__cdecl *)(double,double &,double),
1> StateIn=double,
1> DerivIn=double,
1> StateOut=double,
1> DerivOut=double
1> ]
1> C:\boost_1_55_0\boost/numeric/odeint/stepper/controlled_runge_kutta.hpp(853) : see reference to function template instantiation 'boost::numeric::odeint::controlled_step_result boost::numeric::odeint::controlled_runge_kutta<ErrorStepper>::try_step<void(__cdecl *)(double,double &,double),StateInOut,V>(System,StateInOut &,DerivInOut &,double &,double &)' being compiled
1> with
1> [
1> ErrorStepper=boost::numeric::odeint::runge_kutta_dopri5<double>,
1> StateInOut=double,
1> V=double,
1> System=void (__cdecl *)(double,double &,double),
1> DerivInOut=double
1> ]
1> C:\boost_1_55_0\boost/numeric/odeint/stepper/controlled_runge_kutta.hpp(561) : see reference to function template instantiation 'boost::numeric::odeint::controlled_step_result boost::numeric::odeint::controlled_runge_kutta<ErrorStepper>::try_step_v1<void(__cdecl *)(double,double &,double),StateInOut>(System,StateInOut &,double &,double &)' being compiled
1> with
1> [
1> ErrorStepper=boost::numeric::odeint::runge_kutta_dopri5<double>,
1> StateInOut=double,
1> System=void (__cdecl *)(double,double &,double)
1> ]
1> C:\boost_1_55_0\boost/numeric/odeint/integrate/detail/integrate_adaptive.hpp(98) : see reference to function template instantiation 'boost::numeric::odeint::controlled_step_result boost::numeric::odeint::controlled_runge_kutta<ErrorStepper>::try_step<void(__cdecl *)(double,double &,double),State>(System,StateInOut &,double &,double &)' being compiled
1> with
1> [
1> ErrorStepper=boost::numeric::odeint::runge_kutta_dopri5<double>,
1> State=double,
1> System=void (__cdecl *)(double,double &,double),
1> StateInOut=double
1> ]
1> C:\boost_1_55_0\boost/numeric/odeint/integrate/integrate_adaptive.hpp(44) : see reference to function template instantiation 'size_t boost::numeric::odeint::detail::integrate_adaptive<Stepper,void(__cdecl *)(double,double &,double),State,Time,void(__cdecl *)(const double &,double)>(Stepper,System,State &,Time &,Time,Time &,Observer,boost::numeric::odeint::controlled_stepper_tag)' being compiled
1> with
1> [
1> Stepper=boost::numeric::odeint::controlled_runge_kutta<boost::numeric::odeint::runge_kutta_dopri5<double>>,
1> State=double,
1> Time=double,
1> System=void (__cdecl *)(double,double &,double),
1> Observer=void (__cdecl *)(const double &,double)
1> ]
1> test_odeint.cpp(31) : see reference to function template instantiation 'size_t boost::numeric::odeint::integrate_adaptive<boost::numeric::odeint::controlled_runge_kutta<ErrorStepper>,void(__cdecl *)(double,double &,double),double,double,void(__cdecl *)(const double &,double)>(Stepper,System,State &,Time,Time,Time,Observer)' being compiled
1> with
1> [
1> ErrorStepper=boost::numeric::odeint::runge_kutta_dopri5<double>,
1> Stepper=boost::numeric::odeint::controlled_runge_kutta<boost::numeric::odeint::runge_kutta_dopri5<double>>,
1> System=void (__cdecl *)(double,double &,double),
1> State=double,
1> Time=double,
1> Observer=void (__cdecl *)(const double &,double)
1> ]
1>C:\boost_1_55_0\boost/range/iterator.hpp(63): error C2039: 'type' : is not a member of 'boost::mpl::eval_if_c<C,F1,F2>'
1> with
1> [
1> C=false,
1> F1=boost::range_const_iterator<double>,
1> F2=boost::range_mutable_iterator<double>
1> ]
1> C:\boost_1_55_0\boost/numeric/odeint/algebra/range_algebra.hpp(52) : see reference to class template instantiation 'boost::range_iterator<C>' being compiled
1> with
1> [
1> C=double
1> ]
1>C:\boost_1_55_0\boost/numeric/odeint/algebra/range_algebra.hpp(52): error C2664: 'boost::numeric::odeint::detail::for_each3' : cannot convert parameter 1 from 'boost::type' to 'boost::type'
1> The target type has no constructors
1>C:\boost_1_55_0\boost/numeric/odeint/algebra/range_algebra.hpp(130): error C2664: 'boost::numeric::odeint::detail::reduce' : cannot convert parameter 1 from 'boost::type' to 'boost::type'
1> The target type has no constructors
1> C:\boost_1_55_0\boost/numeric/odeint/stepper/controlled_runge_kutta.hpp(84) : see reference to function template instantiation 'Value boost::numeric::odeint::range_algebra::reduce<double,Err,boost::numeric::odeint::default_operations::maximum<Value>>(const S &,Red,Value)' being compiled
1> with
1> [
1> Value=double,
1> Err=double,
1> S=double,
1> Red=boost::numeric::odeint::default_operations::maximum<double>
1> ]
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
最佳答案
成功了。我使用这一行:
// state_type = value_type = deriv_type = time_type = double
typedef runge_kutta_dopri5< double , double , double , double , vector_space_algebra , default_operations , never_resizer > stepper_type;
替换这一行:
// state_type = double
typedef runge_kutta_dopri5< double > stepper_type;
现在已经修复了。基本上,示例已过时,示例代码文件夹中有正确的代码。
关于c++ - boost odeint 包示例代码中的错误 C2309,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21342636/
我正在通过 odeint 集成生化常微分方程(见下图),但是主输入函数似乎在调用时用奇怪的数字重新设置(或替换)输入参数。尽管参数“iu”(v 的感应率,应在整个过程中保持恒定)和“v”(结果之一,应
我一直在努力使用新版本的 boost。我正在使用多精度的 odeint。下面这段代码可以用boost version 1.67.0编译成功。但是,自 1.68.0 及更新版本以来,我无法再编译。在版本
我最近偶然发现了 boost.odeint 库,我对可能性和可配置性的数量感到惊讶。但是,在广泛使用 scipy.integrate.odeint(它本质上是 Fortran 中 ODEPACK 的包
我刚开始使用 Boost Odeint 来集成一个 ODE 系统。为方便起见,我想将它与 Armadillo 一起使用,因为两者都是具有方便 API 的现代 C++ 库。但是,如果我指定 arma::
我想使用 scipy 的 odeint 函数求解具有 15 个时间相关系数的 7 个常微分方程 (ODE) 系统。 我将系数存储在字典中,以便可以通过我定义为与 odeint() 一起使用的函数 (f
我尝试在 Mac OS X 10.9.2 g++ 5.1 上的 boost_1_55_0 中运行 [odeint 复杂状态类型示例代码。 下面的代码是网站上解决 Stuart-Landau 振荡器的拷
所以我试图求解一个包含三个 ODE 的系统,并开发了以下代码来使用 ODEint 求解它们。但是当我运行时,ODEint 在调用我的方程组函数时出现问题。 from scipy.integrate i
我有以下 odeint 程序: #include #include using namespace std; typedef boost::array state_type; void eqsys
我有一个使用“odeint”模拟种群动态的程序。我想设置一个 if 条件来禁止我的颂歌的结果为负。这是我的代码摘要: class Communities { public : type
我正在尝试求解一个简单的方程:dM/dr = r*p(r) 在 python 中。 我在 r 的某些值处有 p 的值: p(0)=1, p(1)=3, p(2)=5, p( 3)=7, p(4)=9,
我正在尝试使用 scipy 的 odeint 来求解一些常微分方程。唯一的问题是我只想定义一个参数,看来要组成一个元组,你至少需要两个值。 我的代码是这样的: def system(state, t,
我正在尝试用 odeint 求解微分方程。这里一些常量参数是固定的,一些在列表中。 from scipy.integrate import odeint import matplotl
使用Python 2.7.8。 我正在使用的微分方程是 x'=2-3*x。没那么难。正确的解是 y 截距为 2/3 的衰减指数。运动有三个初始条件。还必须在同一地 block 上有一个带有解决方案的斜
我想将 scipy 的 odeint 与一个函数一起使用 def func(y,t,a=123,b=456) 然后将其用作 odeint(func,y0,t) 如果我想使用 args 改变值 a 和
我对使用隐式方案使用 odeint 库求解 ODE 系统很感兴趣,但我很难实现一个简单的 implicit_euler 示例。 查看文档,我设法使工作显式步进器、自适应步进器以及 rosenbrock
我刚刚实现了一组耦合 ODE 的数值积分来自使用 odeint C++ 库的离散 PDE。它很好用并且快如闪电,但有一个问题: 我的 ODE 系统具有所谓的吸收边界条件:时间我的状态变量 n 的导数,
运行以下代码: #include #include using namespace std; using namespace boost::numeric::odeint; class CSyst
显然,getting a non-negative solution from an ODE solver is non-trivial .在 Matlab 中,有 NonNegative optio
我在使用受控错误步进器和复杂状态类型的 odeint 库时遇到了问题。我对具有复杂斯图尔特朗道方程的示例中的代码进行了修改,使其包含自适应积分器。代码现在看起来像这样: #include #incl
有一些使用 arbitrary precision 的例子和 matrices在 boost.odeint( boost 常微分方程求解器)中。 我想在不同类型的坐标(笛卡尔、极坐标或作用角)中使用
我是一名优秀的程序员,十分优秀!