This example show how to use the hydra::GaussKronrodQuadrature static numerical integration algorithm to calculate the integral of a Gaussian.
#ifndef GAUSS_KRONROD_INL_
#define GAUSS_KRONROD_INL_
#include <iostream>
#include <assert.h>
#include <time.h>
#include <string>
#include <chrono>
{
double f =
exp(-m2/(2.0 * s2 ))/(
sqrt(2.0*s2*
PI));
return f;
};
{
auto start = std::chrono::high_resolution_clock::now();
auto result = GKQ61_d.Integrate(
gaussian);
auto end = std::chrono::high_resolution_clock::now();
std::cout << ">>>l [ Gauss-Kronrod 61 ]"<< std::endl;
std::cout << "Result: " << result.first << " +- " << result.second <<std::endl;
std::cout << "Result2: " << result2.first << " +- " << result2.second <<std::endl
<<
" Time (ms): "<<
elapsed.count() <<std::endl;
}
return 0;
}
#endif