#include "hep/mc.hpp"
#include <cstddef>
#include <fstream>
#include <vector>
template <typename T>
{
T const x = point.point().at(0);
T const v = x;
projector.add(0, x, v);
return v;
}
void create_chkpt(std::string const& file)
{
hep::make_integrand<double>(
function<double>,
1,
hep::make_dist_params<double>(10, 0.0, 1.0, "distribution #1")
),
std::vector<std::size_t>(5, 1000),
hep::make_plain_chkpt<double>(std::mt19937())
);
std::ofstream out(file);
chkpt.serialize(out);
}
int main()
{
create_chkpt("chkpt");
std::ifstream in("chkpt");
auto const chkpt_from_disk = hep::make_plain_chkpt<double, std::mt19937>(in);
hep::make_integrand<double>(
function<double>,
1,
hep::make_dist_params<double>(10, 0.0, 1.0, "distribution #1")
),
std::vector<std::size_t>(5, 1000),
chkpt_from_disk
);
std::cout << "result using five iterations from a chkpt and five addtional iterations:\n ";
std::cout << std::scientific << std::setprecision(16)
<< chkpt.results().back().value() << " +- " << chkpt.results().back().error() << '\n';
hep::make_integrand<double>(
function<double>,
1,
hep::make_dist_params<double>(10, 0.0, 1.0, "distribution #1")
),
std::vector<std::size_t>(10, 1000)
).results().back();
std::cout << "result using a single integration with ten iterations:\n ";
std::cout << std::scientific << std::setprecision(16)
<< chkpt.results().back().value() << " +- " << chkpt.results().back().error() << '\n';
}