当前位置: 首页>>代码示例>>C++>>正文


C++ Quad::integrate方法代码示例

本文整理汇总了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;
		}
	}	
}
开发者ID:noemirocco,项目名称:TALENT,代码行数:12,代码来源:test.cpp

示例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;
}
开发者ID:noemirocco,项目名称:TALENT,代码行数:12,代码来源:test.cpp


注:本文中的Quad::integrate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。