#include "hep/mc-mpi.hpp"
#include <mpi.h>
#include <cstddef>
#include <iostream>
#include <vector>
{
}
int main(int argc, char* argv[])
{
MPI_Init(&argc, &argv);
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank == 0)
{
std::cout << ">> computing integral of 3*x^2 from 0 to 1 which is 1.0"
"\n\n";
}
MPI_COMM_WORLD,
hep::make_integrand<double>(square, 1),
std::vector<std::size_t>(5, 10000000)
).results();
auto result = hep::accumulate<hep::weighted_with_variance>(
results.begin() + 1, results.end());
double chi_square_dof = hep::chi_square_dof<hep::weighted_with_variance>(
results.begin() + 1, results.end());
if (rank == 0)
{
std::cout << ">> cumulative result (excluding first iteration):\n>> N="
<< result.calls() << " I=" << result.value() << " +- "
}
MPI_Finalize();
return 0;
}