Exemple #1
0
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;
		}
	}	
}
Exemple #2
0
/** 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;
}