我有以下代码用于通过boost库进行集成。我试图将double运算符更改为cpp_dec_float_50运算符。
#include <iostream>
#include <boost/numeric/quadrature/adaptive.hpp>
#include <boost/numeric/quadrature/kronrodgauss.hpp>
#include <boost/numeric/quadrature/epsilon.hpp>
#include <boost/math/constants/constants.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace std;
using boost::multiprecision::cpp_dec_float_50;
namespace quadrature = boost::numeric::quadrature;
double polynomial(int k , int n);
struct f
{
vector<double> poly;
double polysum(double x) const {
double s = 0;
double p = 1;
for (int i = 1; i < poly.size(); i++) {
p = p * x;
s += p * poly[i];
}
return s;
}
double operator()(double x)const {
return polysum(x) * log(x) / (1 + x);
}
};
int main()
{
int n = 2;
f fun;
double p = 0;
for (int i = 0; i <= n; i++)
{
p = polynomial(i, n);
fun.poly.push_back(p);
}
double answer, error_estimate;
quadrature::adaptive().relative_accuracy(1e-5).absolute_accuracy(1e-7)
(fun, 0., 1., answer, error_estimate);
cout << "ans" << answer << endl;
return 0;
}
double polynomial(int k , int n)
{
return k;
}
如果改为:
cpp_dec_float_50 operator()(cpp_dec_float_50 x)const {
并将所有相关内容更改为cpp_dec_float_50,然后显示错误列表see them here
任何人都可以解决这个问题吗?
对于没有Boost Quadrature库的用户,可以从这里下载https://github.com/coolfluid/coolfluid3/tree/master/include/boost/numeric