我在 BOOST 中使用了一些数值积分包(参见下面的代码)。任何人都可以解释以下含义:
double operator()(double x) {return x/std::log(x);}
这是什么“运算符()(双x)”?
quadrature::adaptive()(f(), 0., 1., answer, error_estimate);
这里的“f()”是什么?
#include <boost/numeric/quadrature/adaptive.hpp>
#include <boost/numeric/quadrature/kronrodgauss.hpp>
#include <iostream>
#include <cmath>
namespace quadrature=boost::numeric::quadrature;
struct f
{
double operator()(double x) const { return x/std::log(x); }
};
int main()
{
double answer, error_estimate;
// integrate x/log(x) on [0,1]
quadrature::adaptive()(f(), 0., 1., answer, error_estimate);
std::cout << "integtral(x/log(x)) on [0,1] is " << answer
<< " with error estimate " << error_estimate
<< std::endl;
return EXIT_SUCCESS;
}