Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/135.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 为什么新版本的odeint会失败?_C++_Boost_Odeint_Boost Multiprecision - Fatal编程技术网

C++ 为什么新版本的odeint会失败?

C++ 为什么新版本的odeint会失败?,c++,boost,odeint,boost-multiprecision,C++,Boost,Odeint,Boost Multiprecision,我正在为新版boost而挣扎。我使用的是精度很高的odeint。下面的代码可以用boost 1.67.0版成功编译。但是,由于版本1.68.0和更新版本,我无法再编译。在版本1.68.0中引入了复杂的多精度数,我希望在代码中也使用这种数据类型。有人能告诉我代码中的错误在哪里吗 #包括 #包括 #包括 #包括 使用名称空间std; 使用名称空间boost::numeric::odeint; typedef boost::多精度::mpf\u float\u 100 mpf; typedef boo

我正在为新版boost而挣扎。我使用的是精度很高的odeint。下面的代码可以用boost 1.67.0版成功编译。但是,由于版本1.68.0和更新版本,我无法再编译。在版本1.68.0中引入了复杂的多精度数,我希望在代码中也使用这种数据类型。有人能告诉我代码中的错误在哪里吗

#包括
#包括
#包括
#包括
使用名称空间std;
使用名称空间boost::numeric::odeint;
typedef boost::多精度::mpf\u float\u 100 mpf;
typedef boost::数组状态类型;
无效rhs(常数状态类型和x、状态类型和dxdt、常数mpf t)
{
dxdt[0]=(-x[0]*sin(t)+2.0*tan(t))*x[0];
}
无效注销(常数状态类型和x、常数强积金t)
{
计算精度(50);

问题似乎是,
boost::multiprecision::number
mpf\u float\u 100
(以及其他每种boost.multiprecision类型)自Boost 1.68以来,work有一个相关的
值\u类型
,因此Boost.Numeric.Odeint将其视为容器,而不是容器。Odeint检查类型是否为容器的方法是使用特征:
具有值\u类型
,将该特征专门化为
数字
,应该可以:

#include <iostream>

#include <boost/array.hpp>
#include <boost/numeric/odeint.hpp>

#include <boost/multiprecision/gmp.hpp>

template< typename Backend, boost::multiprecision::expression_template_option Option >
struct has_value_type<boost::multiprecision::number<Backend,Option> >:boost::mpl::false_{}; //ADDED

using namespace std;
using namespace boost::numeric::odeint;

namespace mp=boost::multiprecision;

typedef boost::multiprecision::mpf_float_100 mpf;
typedef boost::array< mpf , 1 > state_type;

void rhs( const state_type &x , state_type &dxdt , const mpf t )
{
    dxdt[0] = ( - x[0] * sin( t ) + 2.0 * tan( t ) ) * x[0];
}

void write_out( const state_type &x , const mpf t )
{
    cout.precision(50);
    cout << t << '\t' << x[0] << endl;
}

int main()
{
    bulirsch_stoer< state_type , mpf , state_type , mpf > stepper( 1E-20 , 0 , 0 , 0 );

    state_type x;

    mpf t = mpf("0.2");
    mpf dt = mpf("0.01");
    mpf t_end = mpf("1.5");

    x[0] = 1.15;

    integrate_adaptive( stepper , rhs , x , t , t_end , dt , write_out );
} 
#包括
#包括
#包括
#包括
模板
结构具有\u值\u类型:boost::mpl::false\u{};//已添加
使用名称空间std;
使用名称空间boost::numeric::odeint;
名称空间mp=boost::multiprecision;
typedef boost::多精度::mpf\u float\u 100 mpf;
typedef boost::数组状态类型;
无效rhs(常数状态类型和x、状态类型和dxdt、常数mpf t)
{
dxdt[0]=(-x[0]*sin(t)+2.0*tan(t))*x[0];
}
无效注销(常数状态类型和x、常数强积金t)
{
计算精度(50);

不能(在你的问题中)添加你得到的编译错误(逐字)以及关于你正在使用的编译器(和版本)以及在什么平台上的信息,这会有所帮助。请参阅此错误报告:非常感谢。你是否也有关于multiprecision和OpenMP的线索?我在这里发布了此问题:
#include <iostream>

#include <boost/array.hpp>
#include <boost/numeric/odeint.hpp>

#include <boost/multiprecision/gmp.hpp>

template< typename Backend, boost::multiprecision::expression_template_option Option >
struct has_value_type<boost::multiprecision::number<Backend,Option> >:boost::mpl::false_{}; //ADDED

using namespace std;
using namespace boost::numeric::odeint;

namespace mp=boost::multiprecision;

typedef boost::multiprecision::mpf_float_100 mpf;
typedef boost::array< mpf , 1 > state_type;

void rhs( const state_type &x , state_type &dxdt , const mpf t )
{
    dxdt[0] = ( - x[0] * sin( t ) + 2.0 * tan( t ) ) * x[0];
}

void write_out( const state_type &x , const mpf t )
{
    cout.precision(50);
    cout << t << '\t' << x[0] << endl;
}

int main()
{
    bulirsch_stoer< state_type , mpf , state_type , mpf > stepper( 1E-20 , 0 , 0 , 0 );

    state_type x;

    mpf t = mpf("0.2");
    mpf dt = mpf("0.01");
    mpf t_end = mpf("1.5");

    x[0] = 1.15;

    integrate_adaptive( stepper , rhs , x , t , t_end , dt , write_out );
}