本文整理汇总了C++中Quad::integrate方法的典型用法代码示例。如果您正苦于以下问题:C++ Quad::integrate方法的具体用法?C++ Quad::integrate怎么用?C++ Quad::integrate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quad
的用法示例。
在下文中一共展示了Quad::integrate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_orthonormality
void test_orthonormality(Quad& q){
struct f_ho_radial_params p;
p.l1 = 0;
p.l2 = 0;
for (int n1=0; n1<10; n1++){
for (int n2=n1; n2<10; n2++){
p.n1 = n1;
p.n2 = n2;
std::cout << " (n1,l1,n2,l2) = (" << p.n1 << "," << p.l1 << "," << p.n2 << "," << p.l2 << ") = " << q.integrate(f_ho_radial,&p) << std::endl;
}
}
}
示例2: test_various_integrands
/** here we make use of the nice lambda functions introduced in c++11 */
void test_various_integrands(Quad& q){
std::cout << std::fixed;
std::cout << " (0,inf) exp(-x) = " << std::setw(12) << std::setprecision(10) << q.integrate( [](double x,void* p){ return exp(-x); },NULL) << " exact = 1 " << std::endl;
std::cout << " (0,inf) x*exp(-x) = " << std::setw(12) << std::setprecision(10) << q.integrate( [](double x,void* p){ return x*exp(-x);},NULL) << " exact = 1 " << std::endl;
std::cout << " (0,inf) 1/6*x^3*exp(-x) = " << std::setw(12) << std::setprecision(10) << q.integrate( [](double x,void* p){ return 1./6.*x*x*x*exp(-x); },NULL) << " exact = 1 " << std::endl;
std::cout << " (0,inf) 2./sqrt(pi)*exp(-x^2) = " << std::setw(12) << std::setprecision(10) << q.integrate( [](double x,void* p){ return 2./sqrt(M_PI)*exp(-x*x); },NULL) << " exact = 1 " << std::endl;
std::cout << "\n\n";
std::cout << " 4./pi*(0,inf)(0,inf) exp(-x*x-y*y) = " << std::setw(12) << std::setprecision(10) << q.integrate( [](double x, double y,void* p){ return 4./M_PI*exp(-x*x-y*y); },NULL) << " exact = 1" << std::endl;
std::cout << " 4.*(0,inf)(0,inf) x*y*exp(-x*x-y*y) = " << std::setw(12) << std::setprecision(10) << q.integrate( [](double x, double y,void* p){ return 4.*x*y*exp(-x*x-y*y); },NULL) << " exact = 1" << std::endl;
std::cout << " 4.*(0,inf)(0,inf) sin(x)*sin(y)*exp(-x-y) = " << std::setw(12) << std::setprecision(10) << q.integrate( [](double x, double y,void* p){ return 4.*sin(x)*sin(y)*exp(-x-y); },NULL) << " exact = 1" << std::endl;
}