#ifndef VEGAS_INL_
#define VEGAS_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;
size_t iterations = 0;
double max_error = 0;
try {
TCLAP::CmdLine cmd("Command line arguments for vegas", '=');
TCLAP::ValueArg<size_t> NCallsArg("n", "number-of-calls", "Number of call.", true, 5000, "size_t");
cmd.add(NCallsArg);
TCLAP::ValueArg<double> MaxErrorArg("e", "max-error", "Maximum error.", false, 1.0e-3, "double");
cmd.add(MaxErrorArg);
TCLAP::ValueArg<size_t> IterationsArg("i", "max-iterations", "Maximum maximum number of iterations.",false, 10, "size_t");
cmd.add(IterationsArg);
calls = NCallsArg.getValue();
iterations = IterationsArg.getValue();
max_error = MaxErrorArg.getValue();
}
catch (TCLAP::ArgException &e)
{
std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl;
}
constexpr size_t N = 5;
for(size_t i=0; i< N; i++){
}
auto GAUSSIAN = [=]
__hydra_dual__ (
double x,
double y,
double z,
double w,
double v ){
double g = 1.0;
double f = 0.0;
double X[5]{x,y,z,w,v};
for(size_t i=0; i<N; i++){
double m2 = (X[i] -
mean )*(X[i] -
mean );
g *= f;
}
return g;
};
{
State_d.SetVerbose(-2);
State_d.SetAlpha(1.5);
State_d.SetIterations( iterations );
State_d.SetUseRelativeError(1);
State_d.SetMaxError( max_error );
State_d.SetCalls( calls );
State_d.SetTrainingCalls( calls/10 );
State_d.SetTrainingIterations(2);
auto start_vegas = std::chrono::high_resolution_clock::now();
auto result = Vegas_d.Integrate(
gaussian);
auto end_vegas = std::chrono::high_resolution_clock::now();
std::chrono::duration<double, std::milli> elapsed_vegas = end_vegas - start_vegas;
std::cout << std::endl;
std::cout << "----------------- Device ----------------"<< std::endl;
std::cout << ">>> [Vegas]: Gaussian<"<< N << ">" << std::endl;
std::cout << "Result: " << Vegas_d.GetState().GetResult() << " +/- " << Vegas_d.GetState().GetSigma() <<std::endl
<< "Time (ms): " << elapsed_vegas.count() <<std::endl;
std::cout << "-----------------------------------------"<< std::endl;
}
return 0;
}
#endif