0

I have the following code for integration by boost library. Iam tried to change the double operator to cpp_dec_float_50 operator.

#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;
}

if it changed to :

cpp_dec_float_50 operator()(cpp_dec_float_50 x) const {

and change all the related thing to cpp_dec_float_50, then a list of errors appear see them here

can any one fix that ?

for users who does not have Boost Quadrature library, u can download it from here https://github.com/coolfluid/coolfluid3/tree/master/include/boost/numeric

Sarah
  • 19
  • 3
  • 1
    Please, fix the indentation of your code sample, this mess is almost impossible to follow. – Dan Mašek May 20 '16 at 18:47
  • First of all, `boost/numeric/quadrature` seem to be obsolete, https://groups.google.com/forum/#!topic/boost-list/VOlLH8D4x44. – vsoftco May 20 '16 at 18:54
  • so what ? @vsoftco – Sarah May 20 '16 at 19:52
  • 1
    @Sarah So for example I cannot test your code, and probably a large majority of other users cannot either. – vsoftco May 20 '16 at 19:53
  • @vsoftco i had recently download it. i will search for the site – Sarah May 20 '16 at 20:24
  • https://github.com/coolfluid/coolfluid3/tree/master/include/boost/numeric – Sarah May 20 '16 at 20:36
  • Haha. "for users who does not have Boost Quadrature library" - you mean, ***everyone***. You really think it wasn't important to mention your libs in the first place? – sehe May 21 '16 at 12:22
  • @sehe which libraries ? i am really new to these things, did u mean that there are problems in this library ? – Sarah May 21 '16 at 13:23
  • @Sarah I can definitely compile stuff using `cpp_dec_float_50`, see e.g. [here](http://coliru.stacked-crooked.com/a/a04f27876f09ecd7). The problem seems to be buried somewhere into the `boost::quadrature` library, and I doubt you will find some answer, as the latter is not anymore supported by boost. Try perhaps to reduce your example to a minimal one, and see whether `boost::quadrature` is indeed the culprit. My guess is that the new versions of boost don't play nicely with the obsolete `boost::quadrature`. Then try getting rid of `boost::quadrature` and replace it with standard boost. – vsoftco May 21 '16 at 19:17
  • @vsoftco yes, it seems as u said. In fact, i took the file which is named Quadrature and insert it to boost file and to the lib file. I do not know if that legitimate ! ! May the problem from this point ? – Sarah May 21 '16 at 19:26
  • @Sarah Yes, probably. Since the library is old, it is not anymore compatible with new versions of Boost. If you really want to try it, my suggestion is to go back to a boost version that had it integrated, see [http://boost.org](http://boost.org) for the official boost site where you can find older versions. – vsoftco May 21 '16 at 19:31

0 Answers0