This example show how to use the hydra::Plain numerical integration algorithm to calculate the integral of a five dimensional Gaussian.
#ifndef PLAIN_MC_INL_
#define PLAIN_MC_INL_
#include <iostream>
#include <assert.h>
#include <time.h>
#include <string>
#include <vector>
#include <array>
#include <chrono>
#include <limits>
#include <tclap/CmdLine.h>
{
size_t calls = 0;
try {
TCLAP::CmdLine cmd("Command line arguments for plain mc", '=');
TCLAP::ValueArg<size_t> NCallsArg("n", "number-of-calls", "Number of call.", true, 1, "size_t");
cmd.add(NCallsArg);
calls = NCallsArg.getValue();
}
catch (TCLAP::ArgException &e)
{
std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl;
}
constexpr size_t N = 2;
for(size_t i=0; i< N; i++){
}
double g = 1.0;
double f = 0.0;
double X[2]{x,y};
for(size_t i=0; i<N; i++){
double m2 = (X[i] -
mean )*(X[i] -
mean );
g *= f;
}
return g;
};
{
auto start = std::chrono::high_resolution_clock::now();
auto result = PlainMC_d.Integrate(
gaussian);
auto end = std::chrono::high_resolution_clock::now();
std::cout << std::endl;
std::cout << "----------------- Device ----------------"<< std::endl;
std::cout << ">>> [Plain]: Gaussian<"<< N << ">" << std::endl;
std::cout << "Result: " << result.first << " +/- " << result.second <<std::endl
<<
"Time (ms): " <<
elapsed.count() <<std::endl;
std::cout << "-----------------------------------------"<< std::endl;
}
return 0;
}
#endif